Home > Net >  Naming N sublists in R
Naming N sublists in R

Time:09-03

This was my first enter image description here

So for every list level, I do have a vector, for the names these are the vectors:

spaces = 5;
low_mu0 = 0.005; high_mu0 = 0.01;
low_sigma_e = 0.0001; high_sigma_e = 0.001;
low_tau0 = 10; high_tau0 = 20;
low_phi1 = 0.5; high_phi1 = 2;
low_phi2 = -0.5; high_phi2 = 0.5;
low_sigma_n = 0.0001; high_sigma_n = 0.001;
low_c0 = -0.1; high_c0 = 0.1;
low_c1 = -0.1; high_c1 = 0.1


range_mu0 <- seq(low_mu0, high_mu0, length.out = spaces)
range_sigma_e <- seq(low_sigma_e, high_sigma_e, length.out = spaces)
range_tau0 <- seq(low_tau0, high_tau0, length.out = spaces)
range_phi1 <- seq(low_phi1, high_phi1, length.out = spaces)
range_phi2 <- seq(low_phi2, high_phi2, length.out = spaces)
range_sigma_n <- seq(low_sigma_n, high_sigma_n, length.out = spaces)
range_c0 <- seq(low_c0, high_c0, length.out = spaces)
range_c1 <- seq(low_c1, high_c1, length.out = spaces)

For naming each level I tried this:

a2 <- setNames(lapply(a, function(x) 
  setNames(x, nm = paste("mu =", range_mu0))),
  setNames(x, paste("sigma_e =", range_sigma_e)),
  setNames(x, paste("tau =", range_tau0)),
  setNames(x, paste("phi1 =", range_phi1)),
  setNames(x, paste("phi2 =", range_phi2)),
  setNames(x, paste("sigma_n =", range_sigma_n)),
  setNames(x, paste("c0 =", range_c0)),
  paste("c1 =", range_c1))

But gives me an error, is there any way to have a general naming version of enter image description here

  • Related