Search This Blog

Tutorial # 7. Lists

A LISTS is a R-Object contains multiple types of element inside it.

It combines all the Elements, Boolean values , Vectors, Matrix, Arrays and also another list in itself

Example:

my_lists1 = list(c(2,4,6) , "Hello" , cos(0))
print(my_lists1)

my_lists2 = list( c(1,2,3),
TRUE,
matrix(1:9,nrow=3,ncol=3),
array(c('I','Am','Best') , dim=c(3,3,3) , 
dimnames=list(c('R1','R2','R3') , c('C1','C2','C3') ,
c('M-1','M-2','M-3')))
)

print(my_lists2)


Output:

[[1]]
[1] 2 4 6

[[2]]
[1] "Hello"

[[3]]
[1] 1

[[1]]
[1] 1 2 3

[[2]]
[1] TRUE

[[3]]
     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9


[[4]]
, , M-1

   C1     C2     C3    
R1 "I"    "I"    "I"   
R2 "Am"   "Am"   "Am"  
R3 "Best" "Best" "Best"

, , M-2

   C1     C2     C3    
R1 "I"    "I"    "I"   
R2 "Am"   "Am"   "Am"  
R3 "Best" "Best" "Best"

, , M-3

   C1     C2     C3    
R1 "I"    "I"    "I"   
R2 "Am"   "Am"   "Am"  
R3 "Best" "Best" "Best"



You may also interested in:

An Introduction to language R
Tutorial # 1.Data Type & Variable  Declaration
Tutorial # 2.Operators
Tutorial # 3.Vector  & Element Access
Tutorial # 4.Matrix
Tutorial # 5.Data Frame
Tutorial # 6.Arrays
Tutorial # 7.Lists
Tutorial # 8.Factors
Tutorial # 9.Data import
Tutorial # 10.Machine Learning
Tutorial # 11.Visualization


Post a Comment

0 Comments