0
0
R Programmingprogramming~10 mins

Type checking and conversion 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 check if the variable x is numeric.

R Programming
is_numeric <- is[1](x)
Drag options to blanks, or click blank then click option'
Anumeric
Attempts:
3 left
💡 Hint
Common Mistakes
Using is.integer() instead of is.numeric()
Using typeof() instead of is.numeric()
2fill in blank
medium

Complete the code to convert the variable y to a character type.

R Programming
y_char <- as[1](y)
Drag options to blanks, or click blank then click option'
Anumeric
Bcharacter
Clogical
Dinteger
Attempts:
3 left
💡 Hint
Common Mistakes
Using as.numeric() instead of as.character()
Using as.logical() instead of as.character()
3fill in blank
hard

Fix the error in the code to check if z is a logical type.

R Programming
is_logical <- is[1](z)
Drag options to blanks, or click blank then click option'
Alogical
Bnumeric
Ccharacter
Dinteger
Attempts:
3 left
💡 Hint
Common Mistakes
Using is.numeric() instead of is.logical()
Using is.character() instead of is.logical()
4fill in blank
hard

Fill both blanks to create a named vector with names as characters and values as numeric.

R Programming
vec <- c([1] = 1, [2] = 2)
Drag options to blanks, or click blank then click option'
A"a"
B"1"
C"b"
D"2"
Attempts:
3 left
💡 Hint
Common Mistakes
Using numbers as names without quotes
Using unquoted names
5fill in blank
hard

Fill all three blanks to create a list with a numeric, a character, and a logical element.

R Programming
my_list <- list(num = [1], char = [2], logi = [3])
Drag options to blanks, or click blank then click option'
A42
B"hello"
CTRUE
DFALSE
Attempts:
3 left
💡 Hint
Common Mistakes
Putting numbers inside quotes for numeric
Using FALSE instead of TRUE for logical