R - 对具有相似名称的多个变量使用rbind

bil*_*999 2 r rbind

我有很多变量,我使用这样的代码创建:

for (i in 1:10) {
    assign(paste0("variable", i), i )}
Run Code Online (Sandbox Code Playgroud)

我现在需要在变量上使用rbind来组合它们.我尝试过这样的事情无济于事:

rbind(assign(paste0("variable", 1:10)))
Run Code Online (Sandbox Code Playgroud)

有关该怎么办的任何建议?

42-*_*42- 11

这是处理相关项目的错误方法.最好使用列表或数据框,但您可能会在适当的时候找出原因.目前:

do.matrix <- do.call(rbind, lapply( ls(patt="variable"), get) )
Run Code Online (Sandbox Code Playgroud)

要么:

do.matrix <- do.call(rbind, lapply( paste0("variable", 1:10) , get) )
Run Code Online (Sandbox Code Playgroud)