2
train <- read.csv("train.csv")
train$color <- as.numeric(as.factor(train$color))
train.scale <- scale(train[,2:5])
train.scale$color <- train$color
ERROR:
In Train.Scale$color <- Train$color : Coercing LHS to a list
structure(list(id = c(0L, 1L, 2L, 4L), bone_length = c(0.354512184582154,
0.575559905025466, 0.467875498742323, 0.776652460655474), rotting_flesh =
c(0.35083902671065,
0.425868432210585, 0.354330420391775, 0.508722549943229), hair_length =
c(0.465760891829121,
0.531401378709141, 0.811616089668924, 0.636765579959788), has_soul =
c(0.78114166586219,
0.439898877037289, 0.791224973337769, 0.884463692097697), color = c(4,
5, 1, 1), type = structure(c(2L, 3L, 2L, 2L), .Label = c("Ghost",
"Ghoul", "Goblin"), class = "factor")), .Names = c("id", "bone_length",
"rotting_flesh", "hair_length", "has_soul", "color", "type"), row.names =
c(NA,
4L), class = "data.frame")
Warning message: In cbind(Train.Scale, newColumn = Train$color) : number of Rows of result is not a Multiple of vector length (Arg 2)
– Pedro Teixeira
In the sample I made, I did not get this error. If you want me to reproduce your errors you will have to post part of your data in your question.
– Willian Vieira
How do I put the Summary() of the data in the question?
– Pedro Teixeira
or I can put a head(). As you see fit
– Pedro Teixeira
utilize
head(train)
and then paste the result into the question.– Willian Vieira
I cannot use how you put it, look at this explanation: https://stackoverflow.com/a/5963610/6532002
– Willian Vieira
Let’s go continue this discussion in chat.
– Willian Vieira
The best way to post data is
dput(head(train, 20))
. Post the output of this on question, not in a comment.– Rui Barradas