You are on page 1of 2

Q.1 Create a vector with the first 5 even numbers in R.

Q.2 Create a vector containing the numbers 1 to 100 with different ways.

Q.3 Write and explain the method and output of the following codes:

a<-c(1, 2, 3, 4, 5)

a <- c(50, 60, 70, 80, 90)

a -> c(20, 31, 42, 53, 64)

c(5, 6, 7, 9, 10) <- a

c(101, 102, 103, 104, 105) -> a

a < - c(11, 12, 13, 14, 15)

a < -c(100, 99, 88, 77, 66)

assign(a, c(1000, 2000, 3000, 4000, 5000))

assign('a', c(83, 16, 35, 58, 3))

Q.4 Assign the following vectors to a meaningful variable name:

c(2, 4, 6, 8, 10, 12, 14, 16, 20)

3.141593

c(1, 10, 100, 1000, 10000, 100000)

Q.5 Create vectors that correspond to the following variables names:

 bmi
 age
 daysPerMonth
 firstFivePrimeNumbers

Q.6 Make a vector of 1,2,3,5 and 10 using c(), and assign it to the vec variable.

Q.7 Check the length of your vector with length().

Q.8 Make a vector of 4 repeated 10 times using the rep() function.

Q.9 Make a character vector of the gene names PAX6,ZIC2,OCT4 and SOX2. Print the class of the
vector.

Q.10 Describe whether each of these are valid or invalid assignment:

myvar <- "John"

my_var <- "John"

myVar <- "John"

my-var <- "John"


my var <- "John"

_my_var <- "John"

my_v@ar <- "John"

Q.11 Write a R program to create a sequence of numbers from 20 to 50 and find the mean of
numbers from 20 to 60 and sum of numbers from 51 to 91.

Q.12 Write a R program to compute sum, mean and product of a given vector element with 5
numeric values.

Q.13 Explain the difference between | , || , & and && with the help of a program.

Q.14 Write a program to explain the arithmetic, logical & relational operators.

You might also like