R Programming Assignment Question
R Programming Assignment Question
A. Eg.: A<-c(9,4,3)
B<-c(2,4,3)
Sum<-A+B
Sum
B. Eg.: A<-c(9,4,3)
B<-c(2,4,3)
Product<-A*B
Product
A. Eg.: any(grep(9,A))
A. Eg.:
List=list(c("Name","place","Animal","Thing"),matrix(c(34,6,33,67,9
6,22),nrow=2),list(23,44,56.23))
List[4]=list(c(34,45,57))
List
A. List_1=list(23,45,22,67,87)
List_2=list("Name","place","Animal","Thing")
List_3=list("SAS","R")
List=list(List_1,List_2,List_3)
List
A. Levels: 1 2 3 4 5 NA
A. X=c('Jan','July','Apr','Dec')
Y=factor(X,levels=c('Jan','Feb','Mar','Apr','May','June','July','Sept','
Oct','Nov','Dec'),ordered=TRUE)
V1 = 10,30,40,90
V2 = 0.5,0.8.1.5.1.9
Logi=TRUE,FALSE,TRUE,TRUE
A. Dataframe=data.frame(name=c("RX","TX","VX"
"FX")
V1=c(10,30,40,90)
V2=c(0.5,0.8.1.5.1.9)
Logi=c(TRUE,FALSE,TRUE,TRUE))
Print(str(Dataframe))
10) Write a R program to find the maximum and the minimum
value of a given vector.
nums = c(10, 20, 30, 40, 50, 60)
A. print(min(nums))
print(max(nums))
11) How to create an array with three columns, three rows, and
two "tables", taking two vectors as input to the array.
A. A=c(23,55,22,67,89,5,6)
B=c(66,9,23,56,20,34,22)
Z=array(c(A,B),dim=c(3,3,2))
A. Dataframe=data.frame()
exam_data = data.frame(
A.print(str(exam_data))
A. print(summary(exam_data))
A. Eg.: print(exam_data$score)
17) Write a R program to extract first two rows from a given data
frame.
exam_data = data.frame(
A. print(exam_data[,c(1,2)])
18)How to extract 3rd and 5th rows with 1st and 3rd columns from a
given data frame.
exam_data = data.frame(
A. print(exam_data[c(3,5),c(1,3)])
A. Age=c(20,19,22,23,19,18,21,21,22,23)
cbind(exam_data,Age)
exam_data = data.frame(
A. X=list(‘Agna’,20,3,’yes’)
rbind(exam_data,X)
exam_data = data.frame(
A. exam_data$attempts=NULL
22) How to drop 2nd & 4th row(s) from a given data frame.
exam_data = data.frame(
A. print(exam_data[c(-2,-4),])