Recall & Review
beginner
What is a numeric type in R?
A numeric type in R represents numbers that can have decimal points. It is used to store real numbers like 3.14 or 2.0.
Click to reveal answer
beginner
How do you create a numeric variable in R?
You can create a numeric variable by assigning a number with or without decimals, for example:
x <- 5 or y <- 3.14.Click to reveal answer
beginner
What function checks if a value is numeric in R?
The function
is.numeric() returns TRUE if the value is numeric, otherwise FALSE.Click to reveal answer
intermediate
What happens if you add a numeric and an integer in R?
R automatically converts the integer to numeric and performs the addition, returning a numeric result.
Click to reveal answer
intermediate
How can you convert a character string to numeric in R?
Use the
as.numeric() function to convert a character string that represents a number into a numeric type.Click to reveal answer
Which of these is a numeric value in R?
✗ Incorrect
3.14 is a numeric value. "3.14" is a character string, TRUE is logical, and factor(3) is a factor.
What does
is.numeric(5L) return in R?✗ Incorrect
5L is an integer, but integers are considered numeric in R, so is.numeric returns TRUE.
How do you convert a character "42" to numeric in R?
✗ Incorrect
The correct function to convert character to numeric is as.numeric().
What is the result of 2 + 3.5 in R?
✗ Incorrect
R converts 2 (integer) to numeric and adds 3.5, resulting in 5.5.
Which function checks if a value is numeric?
✗ Incorrect
is.numeric() checks if a value is numeric.
Explain what a numeric type is in R and how it differs from integer.
Think about numbers with and without decimal points.
You got /4 concepts.
Describe how to convert a character string to a numeric value in R and why this might be useful.
Conversion helps when data is read as text but you need numbers.
You got /4 concepts.