我想从几个数据表中导出地块。
我尝试使用1)for循环,并将ls()传递给2)函数,但无论如何,我使用的函数(正则图)只到达字符向量:数据中的错误,1:不正确的维数。
cbind.data.frame(x = 0:6, y = c(1, 2, 3, 6.1, 5.9, 6, 6.1)) -> data1
cbind.data.frame(x = 0:6, y = c(2, 4, 6, 12.2, 11.8, 12, 12.2)) -> data2require(easyreg)
for (i in base::ls()) { i |> easyreg::regplot(model = 3) }尝试使用函数的
test_fun <- function(x) { x |> regplot(model=3) }
test_fun(ls())for (i in base::ls()) {
svglite::svglite(filename = paste0(i,".svg"))
i |> easyreg::regplot(model = 3)
dev.off()
}发布于 2022-07-23 14:14:38
您可以跳过步骤2和步骤3。
# require(svglite)
for (i in ls(pattern = "data")) { # Assuming that all the dataframes'names contain the word "data"
svglite::svglite(filename = paste0(i,".svg"))
get(i) |> easyreg::regplot(model = 3)
dev.off()
}受this comment启发
https://stackoverflow.com/questions/73091313
复制相似问题