Last active
August 29, 2015 14:21
-
-
Save oleon12/f09e44056040037c537b to your computer and use it in GitHub Desktop.
If you need change numbers treat as characters in a data frame to numeric class, this function will be useful.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
toNum <- function(x){ | |
for (i in 1:length(x)){ | |
matrix <- as.matrix(x) | |
x[,i] <- as.numeric(matrix[,i]) | |
} | |
} | |
#At the end, all characters in the data frame will be numeric type variables. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment