考慮這個組成的函式:
Made_up <- function(x) {
one <- x
two <- x 1
three <- x 2
}
如何讓函式只列印物件三的結果并存盤我寫時要呼叫的其他變數
answer <- Made_up(1)
answer$....
uj5u.com熱心網友回復:
與 Vasily A 的回答類似,您可以使用return函式的結果并將其存盤在answer.
Made_up <- function(x) {
one <- x
two <- x 1
three <- x 2
print(three)
return(list(one=one, two=two, three=three))
}
answer <- Made_up(1)
answer$one
[1] 1
uj5u.com熱心網友回復:
這個怎么樣:
Made_up <- function(x) {
one <- x
two <- x 1
three <- x 2
print(three)
invisible(list(one=one, two=two, three=three))
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/319048.html
