Hi,
I am trying to use bind_rows to combine content from a list of dataframes. It usaully works, but this time it provide lots of NAs in rows and also adds several extra columns/variables.
I couldn't make a reprex showing list itself. I could only create it for a dataframe. Please guide me on that as well if you can.
For now, I am showing the screenshot to give an idea with how values are behaving when using bind_rows. List df contains various regions and each dataframe within the list looks like this:
USA <- datapasta::df_paste(df1$USA)
data.frame(
stringsAsFactors = FALSE,
check.names = FALSE,
Country = c("USA", "USA"),
Awareness = c("UBA", "PBA"),
`Total (N = 10930)` = c("0.68", "0.96199999999999997"),
`2020 - 2 (N = 1211)` = c("0.72599999999999998",
"0.96399999999999997")
)data.frame(
stringsAsFactors = FALSE,
check.names = FALSE,
Country = c("USA", "USA"),
Awareness = c("UBA", "PBA"),
`Total (N = 10930)` = c("0.68", "0.96199999999999997"),
`2020 - 2 (N = 1211)` = c("0.72599999999999998","0.96399999999999997",
NA)
)
Canada <- datapasta::df_paste(df1$Canada)
data.frame(
stringsAsFactors = FALSE,
check.names = FALSE,
Country = c("Canada", "Canada"),
Awareness = c("UBA", "PBA"),
`Total (N = 7467)` = c("0.623", "0.95499999999999996"),
`2020 - 2 (N = 842)` = c("0.65600000000000003","0.94699999999999995",
NA)
)
Columbia <- datapasta::df_paste(df1$Colombia)
data.frame(
stringsAsFactors = FALSE,
check.names = FALSE,
Country = c("Colombia", "Colombia"),
Awareness = c("UBA", "PBA"),
`Total (N = 4704)` = c("0.83899999999999997","0.97399999999999998",
NA),
`2020 - 2 (N = 598)` = c("0.871", "0.97399999999999998")
)
All the columns in each of the variables are same. When I try to combine them all using
df <- bind_rows(df), it provide lots of NAs in rows and also adds several extra columns/variables. Any help to solve this issue is appreciated.
Thanks!