ローカル変数の一覧を取得
Posted feedbacks - R
> foo()
x y
"1" "hello"
1 2 3 4 5 6 | foo <- function(){
x = 1
y = "hello"
result <- sapply(ls(), function(s) eval(as.symbol(s)))
return(result)
}
|

にしお
#3391()
Rating0/0=0.00
Pythonで表現すると、下のコードの???部分を埋めることになります。
>>> def foo(): x = 1 y = "hello" ??? return result >>> foo() {'y': 'hello', 'x': 1}[ reply ]