Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 删除列 R 数据框
我有一个我想从 IRIS 表中删除的变量列表,如下所示:
dropList <- c("Sepal.Length", "Sepal.Width")
如何使用此列表从 IRIS 数据框中删除?(我不想明确提及职位)
谢谢。
还有其他一些方法可以做到这一点,比如使用select参数 of subset,但如果dropList它作为来自其他地方的字符向量出现在你面前,那么它的效果很好。
select
subset
dropList
data(iris) dropList <- c("Sepal.Length", "Sepal.Width") iris2 <- iris[, !colnames(iris) %in% dropList]