我有两个dataframes,我想他们在一个列表文件结合 我的第一个数据帧是如何转换两个数据帧到一个自定义列表文件
df1 <-structure(list(Countries = structure(c(4L, 2L, 7L, 3L, 6L, 5L,
1L), .Label = c("Argentina", "Bangladesh", "Germany", "India",
"Italy", "Spain", "USA"), class = "factor"), score = c(5L, 3L,
3L, 36L, 27L, 38L, 42L), prescore = c(14L, 2L, 9L, 30L, 23L,
28L, 30L), Here = c(1.654426641, 0.317580534, 1.198132543, 1.159607938,
0.502336763, 0.258959426, 3.590781184), There = c(0.929521231,
0.263531469, 0.856353826, 1.492219621, 0.446449268, 0.295339446,
2.365211352), Thevalue = c(1.309899094, 0.165288467, 1.150147005,
1.622165884, 0.528522213, 0.634062442, 1.733429701)), .Names = c("Countries",
"score", "prescore", "Here", "There", "Thevalue"), class = "data.frame", row.names = c(NA,
-7L))
,并在下面
df2<-structure(list(Countries = structure(c(1L, 3L, 7L, 6L, 5L, 4L,
2L), .Label = c("Brazil", "cuba", "holand", "Italy", "Spain",
"UK", "USA"), class = "factor"), score = c(4L, 3L, 2L, 1L, 28L,
36L, 15L), prescore = c(1L, 25L, 9L, 24L, 65L, 27L, 31L), Here = c(1.654426641,
0.317580534, 1.198132543, 1.159607938, 0.502336763, 0.258959426,
3.590781184), There = c(0.929521231, 0.263531469, 0.856353826,
1.492219621, 0.446449268, 0.295339446, 2.365211352), Thevalue = c(1.309899094,
0.165288467, 1.150147005, 1.622165884, 0.528522213, 0.634062442,
1.733429701)), .Names = c("Countries", "score", "prescore", "Here",
"There", "Thevalue"), class = "data.frame", row.names = c(NA,
-7L))
的DF2
我想将它转化成它看起来像这样
List of 2
$ df1 :'data.frame': 7 obs. of 6 variables:
..$ countries : chr [1:7] "India" "Bangladesh" "USA" "Germany" ...
..$ score : int [1:7] 5 3 3 36 ...
..$ prescore : int [1:7] 14 2 9 30 ...
..$ here : num [1:7] 1.654 0.317 1.198 ...
..$ there : num [1:7] 0.929 0.263 0.856 ...
..$ Thevalue : num [1:7] 1.309 0.165 1.150 ...
$ df2 :'data.frame': 7 obs. of 6 variables:
..$ countries : chr [1:7] "Brazil" "holand" "USA" "UK" ...
..$ score : int [1:7] 4 3 2 1 ...
..$ prescore : int [1:7] 1 25 9 24 ...
..$ here : num [1:7] 1.654 0.317 1.198 ...
..$ there : num [1:7] 0.929 0.263 0.856 ...
..$ Thevalue : num [1:7] 1.309 0.165 1.150 ...
有人回答,因为LIS列表T(DF1,DF2),但如果我这样做,它会第一个转换的因素
看看这里是什么我想
.. $国家:字符[1:7]“巴西”,“荷兰” “USA”“UK”...
@Db如果我这样做,那么第一个将是因素 – nik
@db谢谢你解决了这个问题,我很欣赏它很多,感谢教我 – nik
@ d.b只是一件事。如何使df1和df2出现在列表中?看看输出列表df1:'data.frame': – nik