0
0
R Programmingprogramming~10 mins

Code chunks and output 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 print the number 5.

R Programming
print([1])
Drag options to blanks, or click blank then click option'
Afive
Bx
C"5"
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around 5 prints it as text, not number.
Using a variable name without defining it causes an error.
2fill in blank
medium

Complete the code to assign the value 10 to variable x.

R Programming
[1] <- 10
Drag options to blanks, or click blank then click option'
Ay
Bx
C10
Dprint(x)
Attempts:
3 left
💡 Hint
Common Mistakes
Using the value 10 on the left side instead of variable name.
Using print instead of variable name causes syntax error.
3fill in blank
hard

Fix the error in the code to calculate the sum of 3 and 4.

R Programming
result <- 3 [1] 4
Drag options to blanks, or click blank then click option'
A+
B-
C*
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using minus or other operators changes the result.
Leaving the operator blank causes syntax error.
4fill in blank
hard

Fill both blanks to create a vector of numbers from 1 to 5.

R Programming
numbers <- c([1]:[2])
Drag options to blanks, or click blank then click option'
A1
Bc
C5
Dseq
Attempts:
3 left
💡 Hint
Common Mistakes
Using function names instead of numbers inside the colon.
Swapping the numbers changes the sequence.
5fill in blank
hard

Fill all three blanks to create a named vector with scores greater than 50.

R Programming
scores <- c(Alice=60, Bob=45, Carol=75)
passed <- scores[scores [1] [2]]
result <- [3](names(passed))
Drag options to blanks, or click blank then click option'
A>
B50
Csort
Dmean
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators like < or =.
Using mean() instead of sort() for names.