R List
R Lists In R, lists are the second type of vector. Lists are the objects of R which contain elements of different types such as number, vectors, string and another list inside it. It can also contain a function or a matrix as its elements. A list is a data structure which has components of mixed data types. We can say, a list is a generic vector which contains other objects. Example vec < - c(3,4,5,6) char_vec < -c ("shubham","nishka","gunjan","sumit") logic_vec < -c (TRUE,FALSE,FALSE,TRUE) out_list < -list (vec,char_vec,logic_vec) out_list ADVERTISEMENT ADVERTISEMENT Output: [[1]] [1] 3 4 5 6 [[2]] [1] "shubham" "nishka" "gunjan" "sumit" [[3]] [1] TRUE FALSE FALSE TRUE Lists creation The process of creating a list is the same as a vector. In R, the vector is created with the help of c() function. Like c() function, there is another function, i.e., list() which is used to create ...
This comment has been removed by the author.
ReplyDelete