I have these two datasets that I am trying to append:
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")
When I tried:
rbind(data1, data2)
I got a list instead of a dataframe. I have checked the class of each column and they seem consistent with each other. Can someone explain to me? Thanks!