如果您有,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) r ×1