Im trying to convert the following factor to number in RStudio, can I use this commands?
NewFactor <- factor(c(31, 764, 9.6, 513, 125.344, 3131.657, 9853));as.numeric(NewFactor)
Im trying to convert the following factor to number in RStudio, can I use this commands?
NewFactor <- factor(c(31, 764, 9.6, 513, 125.344, 3131.657, 9853));as.numeric(NewFactor)
 
    
    We need to convert it to character and then to numeric
new <- as.numeric(as.character(NewFactor))
new
#[1]   31.000  764.000    9.600  513.000  125.344 3131.657 9853.000
is.numeric(new)
#[1] TRUE
Or a faster
new <- as.numeric(levels(NewFactor)[NewFactor])
new
#[1]   31.000  764.000    9.600  513.000  125.344 3131.657 9853.000
because by directly applying as.numeric, the numbers that we get are the integer storage mode values
