Slip 29 - E) Write a script in R to create a list of students and perform the following 1) Give names to the students in the list. 2) Add a student at the end of the list. 3) Remove the firstStudent. 4) Update the second last student.

Solution:

list_student<-list("Javed",c("Tushar","harsh","mihir"),"anurag","anhishek")
print(list_student)
names(list_student)<-c("a","b","c","d")
print(list_student)
#ADDING ELEMENT at END 
list_student[5]="amod"
print(list_student)
#remove 1st student
list_student[1]=NULL
print(list_student)
#update second last student
list_student[3]="Taha"
print(list_student)

Post a Comment

0 Comments