I am trying to read multiple csv. files and join them into one.
So I originally have:
d <- list.files(path="data/", full.names = TRUE, pattern = "\\.csv$") %>%
lapply(read_csv) %>%
bind_rows
I get the following error:
Error: Can't combine rt character and rt double.
I imagine this must be because rt is a variable which sometimes is a number and otherwise is null.
I tried to change rt into double with mutate, like this:
d <- list.files(path="data/", full.names = TRUE, pattern = "\\.csv$") %>%
lapply(read_csv) %>%as.data.table()%>%mutate(across(rt, as.double))%>%
bind_rows
However when I do that I run into a more complicated problem. I get the following message:
Item 1 has 541 rows but longest item has 583; recycled with remainder.Item 3 has 561 rows but longest item has 583; recycled with remainder.Item 4 has 473 rows but longest item has 583; recycled with remainder.Item 5 has 575 rows but longest item has 583; recycled with remainder.Item 6 has 4 rows but longest item has 583; recycled with remainder.Problem with mutate() input ..1.
i NAs introduced by coercion
i Input ..1 is across(rt, as.double).NAs introduced by coercion
it seems (from my understanding) that one of the csv files is longer than the other and for this reason only one of them is mutated and only one of them is binded.