0
0
R Programmingprogramming~10 mins

Running R code 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 "Hello, world!" in R.

R Programming
print([1])
Drag options to blanks, or click blank then click option'
AHello, world!
B"Hello, world!"
Cprint("Hello, world!")
Decho "Hello, world!"
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the text
Using print without quotes
Using echo instead of print
2fill in blank
medium

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

R Programming
[1] <- 10
Drag options to blanks, or click blank then click option'
Avalue
B10
Cassign
Dx
Attempts:
3 left
💡 Hint
Common Mistakes
Putting 10 on the left side
Using = instead of <-
Using assign() function incorrectly
3fill in blank
hard

Fix the error in the code to calculate the sum of numbers 1 to 5.

R Programming
total <- [1](1:5)
Drag options to blanks, or click blank then click option'
Asum
Brange
Cadd
Dtotal
Attempts:
3 left
💡 Hint
Common Mistakes
Using add() instead of sum()
Using range() which returns min and max
Using variable names instead of functions
4fill in blank
hard

Fill both blanks to create a vector of numbers from 1 to 10 and get its length.

R Programming
numbers <- [1](1, 10)
length_of_numbers <- [2](numbers)
Drag options to blanks, or click blank then click option'
Aseq
Blength
Csum
Dc
Attempts:
3 left
💡 Hint
Common Mistakes
Using c() instead of seq() for sequence
Using sum() instead of length()
Mixing up function names
5fill in blank
hard

Fill all three blanks to create a named vector with scores and get the names of the vector.

R Programming
scores <- c([1] = 90, [2] = 85, [3] = 88)
names(scores)
Drag options to blanks, or click blank then click option'
AMath
BScience
CEnglish
DHistory
Attempts:
3 left
💡 Hint
Common Mistakes
Using numbers instead of names
Using incorrect subject names
Forgetting to name the vector elements