I am trying to load in some data - a list of CSV files. The code below has worked for other data sets of mine, but not for this one.
setwd("~/Dropbox/prime/word/data")
file.age <- setwd("~/Dropbox/prime/word/data")
age_names <- dir(file.age)
one <- do.call(bind_rows,lapply(age_names,read.csv))
I get the following:
Error:
! Can't combine ..1$Reaction.Time
and ..2$Reaction.Time
.
Backtrace:
- base::do.call(bind_rows, lapply(age_names, read.csv))
- dplyr (local)
<fn>
(...) - vctrs::vec_rbind(!!!dots, .names_to = .id)
Having a look through some of the data... in the "reaction time" column there is sometimes a "LOADING DELAY" value rather than a numerical value... might this be the issue?
If it is, is there a way to filter that out on the way in? I've tried appending "%>% filter(reaction_time != "LOADING DELAY")" to the code, but I get the same issue.
Thanks a lot in advance!
CodePudding user response:
We could specify the column type of the specific column as character
while reading and then it should work
library(dplyr)
library(readr)
library(purrr)
map_dfr(age_names, ~ read_csv(.x, col_types = cols(Reaction.Time = "c")))