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.
可能重复: 识别给定类的所有对象以进行进一步处理
我想为我工作区中的每个数据框建立一个索引。我该如何写一些听起来像:
dindex <- ls(class=data.frame)
根据评论中提供的链接@Chase,您可以只包含该类的对象Filter名称。lsinheritdata.frame
Filter
ls
inherit
data.frame
#R --vanilla -q a <- data.frame(1:3) b <- data.frame(1:2, 4:3) L <- list(a, b) Filter(function(x) inherits(get(x), "data.frame"), ls()) #[1] "a" "b"