Complete the code to print "Hello, world!" in R.
print([1])
In R, to print text, you use the print() function with the text inside quotes.
Complete the code to assign the number 10 to a variable named x.
x [1] 10
In R, the preferred way to assign a value to a variable is using the <- operator.
Fix the error in the code to print the value of variable y.
y <- 5 print([1])
To print the value of y, just put y inside print(). Quotes would print the letter y, not its value.
Fill both blanks to create a vector of numbers from 1 to 5 and print it.
numbers <- c([1]) print([2])
The c() function combines values into a vector. We assign it to 'numbers' and then print 'numbers'.
Fill all three blanks to create a sequence from 1 to 10, filter even numbers, and print them.
seq <- [1] even_nums <- seq[seq [2] 2 == 0] print([3])
1:10 creates a sequence from 1 to 10. The modulo operator %% checks for even numbers. We print the filtered vector.