私は数週間前にRを手にした初心者で、apply
家族を学ぼうとしています。使い方がわからずlapply
、気が狂います。はい、私は一言で言えばRとRクック?lapply
ブックを含むいくつかの本を調べましたが、それでも私が何を間違っているのか理解できません。
lapply(X = c("ggplot2", "gtable", "grid"), library)
## Error: 'package' must be of length 1
lapply(X = c("ggplot2", "gtable", "grid"), FUN = function(x) library(x))
## Error: there is no package called 'x'
lapply(X = c("ggplot2", "gtable", "grid"), FUN = library)
## Error: 'package' must be of length 1
x = c("ggplot2", "gtable", "grid")
lapply(x, library)
## Error: 'package' must be of length 1
lapply(x, FUN = function(x) library(x))
## Error: there is no package called 'x'