Convert Character to Numeric in R (Example)
This article explains how to convert a vector of character strings to numeric in the R programming language.
Example Vector
vec <- c("5", "7", "2", "55", "100") # Create character vector |
vec <- c("5", "7", "2", "55", "100") # Create character vector
Conversion of Character Strings to Numeric
vec_num <- as.numeric(vec) # Convert to numeric vec_num # Print updated vector # 5 7 2 55 100 |
vec_num <- as.numeric(vec) # Convert to numeric vec_num # Print updated vector # 5 7 2 55 100
Video Examples
The video below explains how to change characters and factors to numeric in some live examples:

By loading the video, you agree to YouTube’s privacy policy.
Learn more