基于colnames从CRAN_package_db()子集data.frame时出现问题
从基于colnames从CRAN_package_db()子集data.frame时出现问题,r,R,从tools::CRAN\u package\u db()按名称对data.frame进行子集设置时遇到问题: 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 w
tools::CRAN\u package\u db()
按名称对data.frame
进行子集设置时遇到问题:
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]]
apkgs它不起作用,因为两列的名称相同(14和65)
但您可以使用:
apkgs[1, which(names(apkgs) == "MD5sum")]
它不起作用,因为两列的名称相同(14和65)
但您可以使用:
apkgs[1, which(names(apkgs) == "MD5sum")]
啊,这是有道理的。不过,看起来R至少应该给出一个警告。谢谢啊,这是有道理的。不过,看起来R至少应该给出一个警告。谢谢