Quiz
This lesson is called Quiz, part of the R in 3 Months (Spring 2026) course. This lesson is called Quiz, part of the R in 3 Months (Spring 2026) course.
Quiz
What is the difference between as.numeric() and parse_number()?
parse_number() extracts the last number it finds, dropping any non-numeric characters before the last number.
as.numeric() turns values that contain strings into NA;parse_number() extracts the last number it finds, dropping any non-numeric characters before the last number.
To see the difference, run the code below, line-by-line:
x <- c(1, 2, NA, 4, "cat1989dog", 5)
as.numeric(x)
readr::parse_number(x)
as.numeric() turns values that contain strings into NA;parse_number() extracts the last number it finds, dropping any non-numeric characters before the last number.
To see the difference, run the code below, line-by-line:
x <- c(1, 2, NA, 4, "cat1989dog", 5)
as.numeric(x)
readr::parse_number(x)
parse_number() extracts the last number it finds, dropping any non-numeric characters before the last number.
Have any questions? Put them below and we will help you out!
Course Content
144 Lessons
You need to be signed-in to comment on this post. Login.