speed<- c("15","20","30")
factor <- factor(speed, ordered= TRUE, levels = c("15","20","30"))
I'm trying to calculate mean, sum, min of the factor. How do I do it when I used as.numeric()
? It's giving the sum as 6, min as 1.
speed<- c("15","20","30")
factor <- factor(speed, ordered= TRUE, levels = c("15","20","30"))
I'm trying to calculate mean, sum, min of the factor. How do I do it when I used as.numeric()
? It's giving the sum as 6, min as 1.
The problem is that as.numeric
is not doing what you are expecting.
as.numeric(factor)
[1] 1 2 3
The answers that you got are correct for these numbers. But what I think you wanted was:
as.numeric(as.character(factor))
[1] 15 20 30