# Question 1 x = c(1,2,3) sum(x) mean(x) sqrt(x) # Question 2 s = c(14.2,4,9,10,14,28,52) mean(s) median(s) sd(s) # Question 3 x = c('A','B','C','A','B','A','A','B') s = fact(x) print(s) levels(s) table(s) # Question 4 A = matrix(c(1,2,3,4),2,2) B = matrix(c(2,1,3,1),2,2) c = rbind(A,B) d = cbind(A,B) print(c) print(d) # Question 5 x<-1,4 y<-2 x3=x+y print(x3) ---------------------------------------------------------------------- # Long Answers # Question 6 Write about the Different data types in r There are 5 data types # Question 7 Write a function to check if a number is a prime number # Question 8 Maybe this stuff { x <- c(1,3,5) y <- c(3,2,10) z1 = rbind(x,y) z2 = cbind(x,y) print(dim(z1)) print(dim(z2)) } Def this stuff A <- matrix(c(1,3,5),3) B <- matrix(c(2,3,10),3) # Question 9 H = c(66,62,63,70,74) G = c(3.80,3,78,3.88,3.72,3.69) st = data.frame(H,G) print(st) ---------------------------------------------------------------------- #Functions adi <- function(x,y) { res = x+y print(res) } adi(5,9)