List

 x <- list(1, "a", TRUE)

x <- vector("list", length = 3) 

x


rollno = c(101,102,103)

snames = c('John','Jonny','Jack')


Code

marks = c(78.25,59.45,63.85)

students = list(rollno,snames,marks)

students

students = list(c(101,102,103),c('John','Jonny','Jack'),c(78.25,59.45,63.85))

students

id = c(101,'102',103)

name = c('John','Jonny','Jack')

marks = c(78.25,59.45,63.85)

students = list(id, name, marks)

students


rollno = c(101,102,103)

snames = c('John','Jonny','Jack')

marks = c(78.25,59.45,63.85)

students = list(rollno, snames, marks)

students

students[1]

students[2]

students[3]

students[[1]]

students[[2]]

students[[3]]

students[[1]][2]

students[[2]][1]

students[[3]][3]

students[[3]]

students[[3]][2] = 89.65

students[[3]]


# $ subset operator, indexing

students = list('ids'=rollno,'names'=snames,'score'=marks)

print(students$ids)

print(students$names)

print(students$score)

students[c('ids','score')]

students[c(1,3)]


#Concate List

id = c(101,102,103)

name = c('John','Jonny','Jack')

marks = c(78.25,59.45,63.85)

students = list(id,name,marks)

students

age = list(c(19,20,18))

students = c(students,age)

students


Comments

Popular posts from this blog

Probability: Binomial Distribution

Probability: Normal Distribution

Hypothesis testing