0
0
R Programmingprogramming~10 mins

Numeric type in R Programming - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a numeric variable with value 10.

R Programming
num <- [1]
Drag options to blanks, or click blank then click option'
Ac(10)
B"10"
CTRUE
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the number, which makes it a string.
Using TRUE which is logical, not numeric.
2fill in blank
medium

Complete the code to check if variable x is numeric.

R Programming
is.numeric([1])
Drag options to blanks, or click blank then click option'
Ax
B10
C"x"
DTRUE
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the variable name as a string.
Passing a literal number instead of the variable.
3fill in blank
hard

Fix the error in the code to convert a string to numeric.

R Programming
num <- as.numeric([1])
Drag options to blanks, or click blank then click option'
ATRUE
Bnum
C"10"
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a numeric value directly to as.numeric().
Passing a logical value instead of a string.
4fill in blank
hard

Fill both blanks to create a numeric vector and check its type.

R Programming
vec <- c([1], [2])
is.numeric(vec)
Drag options to blanks, or click blank then click option'
A5
B"5"
C10
D"10"
Attempts:
3 left
💡 Hint
Common Mistakes
Using quoted numbers which create character vectors.
Mixing numeric and character values in the vector.
5fill in blank
hard

Fill all three blanks to create a numeric vector, convert a string to numeric, and check types.

R Programming
vec <- c([1], [2])
num <- as.numeric([3])
is.numeric(vec) && is.numeric(num)
Drag options to blanks, or click blank then click option'
A3
B"7"
Attempts:
3 left
💡 Hint
Common Mistakes
Using quoted numbers in the vector.
Passing numeric values directly to as.numeric() unnecessarily.