假设您正在使用大型工作环境,并且您不善于跟上环境变量,或者您有一些自动生成批量对象的过程.有没有办法扫描你ls()以识别具有给定类的所有对象?考虑以下简单示例:
#Random objects in my environment
x <- rnorm(100)
y <- rnorm(100)
z <- rnorm(100)
#I estimate some linear models for fun.
lm1 <- lm(y ~ x)
lm2 <- lm(y ~ z)
lm3 <- lm(y ~ x + z)
#Is there a programmatic way to identify all objects in my environment
#that are of the "lm" class? Or really, any arbitrary class?
outList <- list(lm1, lm2, lm3)
#I want to look at a bunch of plots for all …Run Code Online (Sandbox Code Playgroud) r ×1