如果您有,list但您希望列表中的每个元素都是它在全局环境中的独立元素,例如
alist <- list( c(1,2), c(3,4) )
# into
a <- c(1,2)
b <- c(3,4)
Run Code Online (Sandbox Code Playgroud)
有一个简单的方法吗?也许下面的形式:
mapply(function(x,y){ y <- x }, alist, list("a","b"), SIMPLIFY = FALSE )
Run Code Online (Sandbox Code Playgroud)
Jil*_*ina 10
使用 list2env
alist <- list( a=c(1,2), b=c(3,4) ) # naming list elements
list2env(alist, envir = .GlobalEnv)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
179 次 |
| 最近记录: |