我不确定这是不是 R 语言故意为之?查看函数帮助 ?rep
发现这么一个例子,它复制列表的操作是这样的
## replicate a list
fred <- list(happy = 1:10, name = "squash")
rep(fred, 5)
实际结果却是这样的,感觉并没有四个 list,我原想的是 list(list,list,list,list)
$happy
[1] 1 2 3 4 5 6 7 8 9 10
$name
[1] "squash"
$happy
[1] 1 2 3 4 5 6 7 8 9 10
$name
[1] "squash"
$happy
[1] 1 2 3 4 5 6 7 8 9 10
$name
[1] "squash"
$happy
[1] 1 2 3 4 5 6 7 8 9 10
$name
[1] "squash"
$happy
[1] 1 2 3 4 5 6 7 8 9 10
$name
[1] "squash"
我的测试环境
sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8.1 x64 (build 9600)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936
[2] LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936
[4] LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.936
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.6.0 tools_3.6.0