我无法按名称从data.frame
对tools::CRAN_package_db()
进行子集化:
apkgs <- tools::CRAN_package_db()
apkgs[1, 65] # character vector of length one with an MD5sum
# But these don't work:
apkgs[1, "MD5sum"] # NA
apkgs[1, names(apkgs)[65]] # NA
## But these work, even though they're very similar?
mtcars[1, "mpg"]
mtcars[1, names(mtcars)[1]]
任何想法我做错了什么?
答案 0 :(得分:2)
它不起作用,因为两列具有相同的名称(14和65)。
但你可以改用:
apkgs[1, which(names(apkgs) == "MD5sum")]