Reputation: 11
Declaring variable types separately using colclasses parameters
varTypes <- c(
Sepal.Length = 'Numeric',
Sepal.Width = 'Numeric',
Petal.Length = 'Numeric',
Petal.Width = 'Numeric',
Species = "Factor",
Name = "Character"
)
Flowers <- read.table(
"C:/Study/JIGSAW/irisone.csv",
header=FALSE,
sep=",",
skip = 1,
col.names=names(varTypes),
colClasses = varTypes
)
Error message is displayed below:
Error in methods::as(data[[i]], colClasses[i]) :
no method or default for coercing “character” to “Numeric”
Upvotes: 1
Views: 617
Reputation: 7592
Try numeric
with a lower case "n" in varTypes (same for Factor and Character, while you're at it)
Upvotes: 2