NEW
Font size
WorksheetsIntroduction to R
Total questions: 18
Worksheet time: 9mins
How do you create a variable named x with the numeric value 5?
x : 5
x <- 5
int x = 5
The value of a string variable can be surrounded by single quotes.
True
False
The following values: 10.5, 55 and 787, belongs to which data type?
numeric
All elements of an atomic vector can be of different types.
You can construct a list using c( )
True
False
Not sure
Matrices and arrays are created with matrix( ) and array( ), or by using the assignment form of dim( )
True
False
Not sure
Consider the R code below, what is the type of vector a:
a <- c("r", 1)
numeric
character
logical
Integer
Which of the type of data structures below is not homogeneous?
atomic vector
matrix
array
list
A data frame is a list of equal-length vectors.
Consider the R code below. How many factor levels are there?
(x <- factor(c("a","b","b","a","c")))
1
2
3
How can you assign the same value to multiple variables in one line?
var1, var2, var3 <- "orange"
var1, var2, var3 = "orange"
var1 <- var2 <- var3 <- "orange"
How do you create a function in R?
my_function <- function( )
my_function <- function.
my_function <- function[ ]
How do you call a function in R?
my_function( )
my_function[ ]
my_function;
(my_function)
What is the correct way to create a vector of strings?
fruits <- c("banana", "apple", "orange")
fruits <- v("banana", "apple", "orange")
fruits <- list("banana", "apple", "orange")
fruits <- listOf("banana", "apple", "orange")
What is the correct way to create a list of strings?
fruits <- c("banana", "apple", "orange")
fruits <- v("banana", "apple", "orange")
fruits <- list("banana", "apple", "orange")
fruits <- listOf("banana", "apple", "orange")
Which function can be used to create a data frame?
dataframe( )
data.frame( )
df( )
dframe( )
What is the output of the following code fragment?
n = 10;
typeof(n);
class(n);
[1] "double"
[1] "numeric"
[1] "integer"
[1] "numeric"
[1] "integer"
[1] "integer"
Which of the following commands creates the vector
0, 0.2, 0.4, 0.6, 0.8, 1?
x <- c(0, 0.2, 0.4, 0.6, 0.8, 1)
seq(0, 1, by = 0.2)
{0, 0.2, 0.4, 0.6, 0.8, 1}
seq(0, 1, length=5)
