Creating a list with a vector,matrix and list lis<-list(c(1:10),matrix((1:12),3,4,TRUE),list((10:20),matrix(1:6),2,3)) print(lis) #Giving names for list names(lis)<-c("VECT","MAT","LISS") print(lis$VECT) #Adding an element at the end of the list lis[4]<-"NEW ELEMENT" print(lis[4]) #Removing the last element lis[4]=NULL print(lis) #Updating the 3rd element lis[3]<-"UPDATED ELEMENT" print(lis) #Creating a second list lis2<-list(c(20:30)) print(lis2) #Merging 2 lists merg_lis<-list(lis,lis2) print(merg_lis)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter