Reputation: 629
I'm trying to figure out how to fix the following issues. Here is a code example:
fileName <- "data.csv"
colClasses <- sapply(read.csv(fileName, nrows=100),class)
colClasses["time"] = "POSIXct"
colClasses["userName"] = colClasses["clientHost"] = "character"
data <- fread(input = fileName, sep = ",", sep2 = NULL,
colClasses = colClasses, nrows = 2, header=TRUE, drop=c(15,16))
The following error occurs:
Error in fread(input = fileName, sep = ",", sep2 = NULL, nrows = 2, colClasses = colClasses, :
Column name 'userName' in colClasses[[1]] not found
I'm using the R 3.1.2 with data.tables package 1.9.4
The second issue is that when I don't specify the colClasses variable, then data is imported, but the header is equal to the the first row of the data, and not the names of the columns in the file.
Upvotes: 1
Views: 901