0
0
R Programmingprogramming~10 mins

First R program 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'
Aprint("Hello, world!")
BHello, world!
C'Hello, world!'
D"Hello, world!"
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the text
Putting the whole print statement inside print()
2fill in blank
medium

Complete the code to assign the number 10 to a variable named x.

R Programming
x [1] 10
Drag options to blanks, or click blank then click option'
A==
B=
C<-
D->
Attempts:
3 left
💡 Hint
Common Mistakes
Using == which is for comparison
Using -> which assigns in the opposite direction
3fill in blank
hard

Fix the error in the code to print the value of variable y.

R Programming
y <- 5
print([1])
Drag options to blanks, or click blank then click option'
Ay
B"y"
Cprint(y)
DY
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around y
Using uppercase Y instead of y
Putting print() inside print()
4fill in blank
hard

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

R Programming
numbers <- c([1])
print([2])
Drag options to blanks, or click blank then click option'
A1, 2, 3, 4, 5
Bnumbers
Cc(1, 2, 3, 4, 5)
D1:5
Attempts:
3 left
💡 Hint
Common Mistakes
Putting c() inside the print statement
Printing the vector creation expression instead of the variable
5fill in blank
hard

Fill all three blanks to create a sequence from 1 to 10, filter even numbers, and print them.

R Programming
seq <- [1]
even_nums <- seq[seq [2] 2 == 0]
print([3])
Drag options to blanks, or click blank then click option'
A1:10
B%%
Ceven_nums
D%/%
Attempts:
3 left
💡 Hint
Common Mistakes
Using %/% which is integer division
Printing the original sequence instead of filtered even numbers