开始使用免费开始使用

创建列表

让我们来创建第一个列表!要构造列表,请使用函数 list()

my_list <- list(comp1, comp2 ...)

传给 list 函数的参数就是列表的各个组件。请记住,这些组件可以是矩阵、向量、其他列表等。

本练习是课程的一部分

R 入门

查看课程

练习说明

构建一个名为 my_list 的列表,其中包含变量 my_vectormy_matrixmy_df 作为列表组件。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Vector with numerics from 1 up to 10
my_vector <- 1:10 

# Matrix with numerics from 1 up to 9
my_matrix <- matrix(1:9, ncol = 3)

# First 10 elements of the built-in data frame mtcars
my_df <- mtcars[1:10,]

# Construct list with these different elements:
my_list <-
编辑并运行代码