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

Conversion of Character Strings to Numeric

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:

YouTube

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

Load video

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top