0
0
R Programmingprogramming~10 mins

Integer 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 an integer variable with value 10.

R Programming
x <- [1]
Drag options to blanks, or click blank then click option'
A"10"
B10L
C10.0
Das.character(10)
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes makes it a string, not an integer.
Using a decimal point makes it a numeric (double), not an integer.
2fill in blank
medium

Complete the code to check if variable y is of integer type.

R Programming
is.integer([1])
Drag options to blanks, or click blank then click option'
A10
B"y"
Cas.integer(y)
Dy
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the value 10 instead of the variable.
Passing the variable name as a string.
3fill in blank
hard

Fix the error in the code to convert a numeric value to integer.

R Programming
z <- [1](5.7)
Drag options to blanks, or click blank then click option'
Aas.integer
Bas.character
Cas.numeric
Das.logical
Attempts:
3 left
💡 Hint
Common Mistakes
Using as.character() converts to string, not integer.
Using as.logical() converts to TRUE/FALSE, not integer.
4fill in blank
hard

Fill both blanks to create a vector of integers from 1 to 5 and check its type.

R Programming
vec <- [1](1:5)
is_int <- [2](vec)
Drag options to blanks, or click blank then click option'
Aas.integer
Bis.integer
Cas.numeric
Dis.numeric
Attempts:
3 left
💡 Hint
Common Mistakes
Using as.numeric instead of as.integer.
Using is.numeric instead of is.integer.
5fill in blank
hard

Fill all three blanks to create an integer vector, convert a number to integer, and check if it is integer.

R Programming
int_vec <- [1](c(2.5, 3.7, 4.1))
num <- [2](5.9)
check <- [3](num)
Drag options to blanks, or click blank then click option'
Aas.numeric
Bas.integer
Cis.integer
Dis.numeric
Attempts:
3 left
💡 Hint
Common Mistakes
Using as.numeric() instead of as.integer().
Using is.numeric() instead of is.integer().