This is a follow-up on the question: read.csv falsly converts string to integer
I have a CSV file (toy example):
V1,V2,V3
1,00010,a
2,10010,v
I want to read the second column as a string value.
I am aware of the colClasses method in the read.csv falsly converts string to integer question.
However, my data files contain 5,000+ columns with mixed variable types, while only one column is problematic. I can do something like this:
df <- read.csv("data.csv"); temp <- sapply(df,class); temp[2] <- "character"; df <- read.csv("data.csv",colClasses=temp)
But this is so ugly way of coding. Is there any more diligent way of doing this?
read.csv(....., colClasses = c("numeric", "character", "character"))- onyambu