0

I have a list object (results) and am trying to compact it in a tidy data frame. But I am not sure how to achieve that.

[[varying from 1to 3nsim][[varying from 1 to 9]][[varying from 1to 3]][[varying from 1to 3]]

I have such nested list and I want to compact it into a tidy data frame of dimension nrow =nsimx9x3x3 et ncol = 26 . any idea how to achieve it?

Thanks in advance

Ibrahima
  • 11
  • 3
  • 1
    Can you please share in your question a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example#5963610) to showcase your data and expected output? It's really hard to imagine what you want to achieve. Also it seems that you are describing a four dimensional structure, which doesn't sound like a data frame at all – alex_jwb90 Sep 18 '20 at 17:19

1 Answers1

0

Since you have nsimx9x3x3 rows (but I have no clue how you get 26 columns), maybe this could work for you

as.data.frame(t(as.data.frame(lst)))

where lst is your nested list

ThomasIsCoding
  • 96,636
  • 9
  • 24
  • 81
  • Sorry, It seems I was not very clear in the post. from the nested lists. I want to have a dataframe with nsimx9x3x3 and 26 columns (outputs of the analysis function) – Ibrahima Sep 20 '20 at 07:36
  • @Ibrahima Could you provide a small example of the nested list as well as the expected output. I have no picture in my mind what you are looking for – ThomasIsCoding Sep 20 '20 at 10:01
  • [[2]] [[2]][[1]] [[2]][[1]][[1]] [[2]][[1]][[1]][[1]] i rho_theorique rho_xy rho_xz rho_yz rho_xy_cca rho_xz_cca rho_yz_cca prop_miss method mech SimType estimate std.error statistic df p.value x 2 0.25 0.1982005 0.5 0.05232742 0.2159688 0.5 0.06095765 0.05 norm MCAR MyTest 0.2213937 0.1147183 1.92989 48.04456 0.0595361 X2.5.. X97.5.. riv lambda fmi ubar b t dfcom x -0.009257401 0.4520447 0.1530611 0.1327432 0.1667236 0.01141335 0.001310204 0.01316029 98 – Ibrahima Sep 22 '20 at 19:27