R 生成列表的两种方式

  1. 第一种方法,直接用list() 函数生成列表
#method one
a <- "my first list"
b <- 1:3
c <- matrix(0, ncol=3,nrow=4)
mylist <- list(name=a, other=b,c)
  1. 第二种方法 先生成一个空文件,然后用[[i]] 生成列表,第二种方法在循环生成列表中用的很多
a <- "my first list"
b <- 1:3
c <- matrix(0, ncol=3,nrow=4)
mylist <- NULL
mylist[[1]] <- a
mylist[[2]] <- b
mylist[[3]] <- c

猜你喜欢

转载自blog.csdn.net/YJJ18636810884/article/details/83183930
R
R: