为什么不能rbind追加这两个数据集?

时间:2019-10-10 21:24:33

标签: r

我有两个要添加的数据集:

data1 = structure(list(year = c(2017, 2018), flow = c("Export", "Export"
), EUR = c(4, 3.44), Home = c(3.09, 3.03), Not_reported = c(0.12, 
0), USD = c(92.29, 93.04), country = c("Brazil", "Brazil"), Other = c(0.499999999999994, 
0.489999999999994)), row.names = c(NA, -2L), vars = c("year", 
"flow"), drop = TRUE, indices = list(0L, 1L), group_sizes = c(1L, 
1L), biggest_group_size = 1L, labels = structure(list(year = c(2017, 
2018), flow = c("Export", "Export")), row.names = c(NA, -2L), vars = c("year", 
"flow"), drop = TRUE, indices = list(0L, 1L), group_sizes = c(1L, 
1L), biggest_group_size = 1L, labels = structure(list(year = c(2017, 
2018), flow = c("EXP", "EXP")), class = "data.frame", row.names = c(NA, 
-2L), vars = c("year", "flow"), drop = TRUE), class = "data.frame"), class = c("grouped_df", 
"tbl_df", "tbl", "data.frame"))
data2 = structure(list(flow = c("Export", "Export", "Export", "Export", 
"Export", "Import"), country = structure(c(6L, 6L, 6L, 6L, 6L, 
6L), .Label = c("Algeria", "Argentina", "Australia", "Austria", 
"Belgium", "Brazil", "Bulgaria", "Canada", "China", "Colombia", 
"Cyprus", "Czech Republic", "Denmark", "Estonia", "Euro", "Finland", 
"France", "Germany", "Greece", "Hungary", "Iceland", "India", 
"Indonesia", "Ireland", "Israel", "Italy", "Japan", "Latvia", 
"Lithuania", "Luxembourg", "Malaysia", "Malta", "Morocco", "Netherlands", 
"Pakistan", "Poland", "Portugal", "Romania", "Slovakia", "Slovenia", 
"South Africa", "South Korea", "Spain", "Sweden", "Switzerland", 
"Thailand", "Ukraine", "United Kingdom", "United States"), class = "factor"), 
    year = c(2007, 2008, 2009, 2010, 2011, 2007), EUR = c(4.76, 
    4.95, 4.51, 4.28, 3.8, 11.1), Home = c(0.13, 0.16, 1.11, 
    0.82, NA, 0.48), Not_reported = c(NA_real_, NA_real_, NA_real_, 
    NA_real_, NA_real_, NA_real_), USD = c(94.7, 94.4, 93.8, 
    94.3, 94.5, 85.5), Other = c(NA_real_, NA_real_, NA_real_, 
    NA_real_, NA_real_, NA_real_)), row.names = c(NA, 6L), class = "data.frame")

当我尝试时:

rbind(data1, data2)

我得到了一个列表,而不是一个数据框。我检查了每列的类,它们看起来彼此一致。有人可以向我解释吗?谢谢!

0 个答案:

没有答案