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”
尝试numeric
与varTypes一个小写的“n”(同为因素和性格,而你在它)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.