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

PRACTICE QUESTIONS: UNIT 1

1. Find square root of 30


2. Find exponential of 2
3. Find the data type of “Welcome”
4. Find the data type of 5>3
5. Create a vector b as b <- c(45,67,34,24,12,42). Access the 3rd and 6th element of vector
b
6. Add two vectors c <- c(3,4,2,1) and d <- c(7,8,9,3)
7. Create a 4X2 matrix with values as (45,67,23,45,89,12,9,89). Keep the matrix elements
row-wise. Then
a) access the elements present in 2nd column
b) access the elements in 3rd row
c) access the element present in 2nd row and 1st column
8. Write two vectors Age <- c(12,45,32) & Height <-c(2.1,6.7,5.3) and create a dataframe
“health” by using data.frame function
9. Use the in built dataset mtcars and
Use following command to load the dataset mtcars
library(datasets)
data<-datasets::mtcars
After running this code data would contain the mtcars dataset. Once the dataset is
loaded perform the following operations
a) extract the 6th column of the mtcars dataset
b) Access the first two columns from mtcars dataset
c) Access first four rows from mtcars
d) Find the mean value of mpg (miles per gallon) of all cars in the dataset
e) Find the max value of wt (weight). Which car is the heaviest?
10. Create a function which takes two arguments a,b and prints the whether the square
root of a is greater than b

You might also like