建立清單
來建立你的第一個清單吧!要建立清單,請使用 list() 函式:
my_list <- list(comp1, comp2 ...)
傳給 list 函式的引數就是清單的各個組成元件。請記住,這些元件可以是矩陣、向量、其他清單,等等。
本練習屬於課程
R 入門
練習說明
建立一個名為 my_list 的清單,並將變數 my_vector、my_matrix 和 my_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 <-