wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

R STARTER

Total questions: 20

Worksheet time: 3mins

Name
Class
Date
1.
What is a correct syntax to output "Hello World" in R?
a)
print(“Hello World”)
b)
“Hello World”
c)
‘Hello World’
d)
All are correct
2.
R is an alias of React
a)
True
b)
False
3.
How do you insert COMMENTS in R code?
a)
// This is a comment
b)
/* This is a comment
c)
# This is a comment
4.
In R, you must declare the data type of a variable
a)
True
b)
False
5.
How do you create a variable named x with the numeric value 5?
a)
x : 5
b)
x <- 5
c)
int x = 5
6.
Which function is often used to concatenate elements?
a)
join()
b)
paste()
c)
merge()
d)
concat()
7.
How can you assign the same value to multiple variables in one line?
a)
var1, var2, var 3 = “Orange”
b)
var1 <- var2 <- var3 <- “Orange”
c)
var1, var2, var3 <- “Orange”
8.
Which operator is used to add together two values?
a)
The & sign
b)
The + sign
c)
The * sign
9.
The value of a string variable can be surrounded by single quotes.
a)
True
b)
False
10.
The following values: 10.5, 55 and 787, belongs to which data type:
a)
integer
b)
numeric
c)
complex
11.
Which operator can be used to compare two values?
a)
<>
b)
><
c)
==
d)
=
12.
Which function can be used to return the square root of a number?
a)
sqroot()
b)
sqrt()
c)
square_root()
d)
sr()
13.
What will the following function do with the str string: nchar(str)
a)
Insert an escape character before the str string
b)
Add spaces to each word inside the str string
c)
Find the number of characters in the str string
d)
Add a new line for each word inside the str string
14.
What is the correct way to create a vector of strings?
a)
fruits <- c(“banana”, “apple”, “orange”)
b)
fruits <- list(“banana”, ”apple”, ”orange”)
c)
fruits <- v(“banana”, ”apple”, ”orange”)
d)
fruits <- listOf(“banana”, ”apple”, ”orange”)
15.
Which function is used to draw points (markers) in a diagram?
a)
canvas()
b)
plot()
c)
draw()
d)
d()
16.
How do you start writing an if statement in R?
a)
if (x>y)
b)
if x>y:
c)
if x>y then:
17.
Which function can be used to create a data frame?
a)
df()
b)
dataframe()
c)
data.frame()
d)
dframe()
18.
Consider the following code: for (x 1:10). Which keyword is missing inside the for loop to output the numbers 1 to 10?
a)
list
b)
inside
c)
seq
d)
in
19.

Which function is used to add additional columns in a matrix?

a)

add()

b)

cbind()

c)

append_item()

d)

join()

20.
Which statement is used to stop a loop?
a)
return
b)
break
c)
stop
d)
exit