Let I have a list(list1) which consists data frames(df1,df2,..,dfn):
Each data frame consist different number of columns. As an example
list1[[1]]=df1
where df1:
x y
---- -----
45 6
65 87
12 90
and
list1[[2]]=df2
where df2:
a b c
---- ---- ----
23 67 43
71 13 8
2 9 12
I want to unlist list1 as returns df1 and df2
df1:
a1 a2
---- -----
45 6
65 87
12 90
df2:
b1 b2 b3
---- ---- ----
23 67 43
71 13 8
2 9 12
Namely,
first data frame(df1) will headers as a1,a2,a3.....
second data frame(df2) will headers as b1,b2,b3.....
third data frame(df3) will headers as c1,c2,c3.....
and goes on.
How can I do that in R? I will be very glad for any help. Thanks a lot.
list2env
andsetNames
for what it sounds like you're asking for. – A5C1D2H2I1M1N2O1R2T1lapply
instead of creating a lot of objects in your workspace. Anyway,list2env
will do what you are calling an "unlist" activity. – A5C1D2H2I1M1N2O1R2T1setNames
. – A5C1D2H2I1M1N2O1R2T1