Section 1 Test Solution

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Section 1 Test

Question 1: What is the difference in the output of these two commands? One of these is in
single quote and other in double quote.
a <- "R Studio"
b <- 'R Studio'

Answer: There is no difference. You can provide character type data in either single or
double quote. It does not make any difference.
Question 2: Create a vector with the following values and find the mean of these: 253, 635,
365
a <- c(253, 635, 365)
mean(a)

## [1] 417.6667

Question 3: What will be output of the following code.(12 or 20)


5*2+2

## [1] 12

Hint: When evaluating a function, R follows the BODMAS rule. The BODMAS acronym is for:
-Brackets (parts of a calculation inside brackets always come first).
-Orders (numbers involving powers or square roots).
-Division.
-Multiplication.
-Addition.
-Subtraction.
In this example the first operation was the multiplication of 5 and 2 = 10 and then 2 was
added to that.

You might also like