1
我想用附加()後,以確定在一塊土地上的數據連接,但我有離開我的功能之前,拆下問題:使用識別和功能
f = function(x, y, data) {
attach(data)
plot(x, y)
ids = identify(x, y)
detach(data)
return ids
}
返回值:
<environment: 0xf785ed8>
attr(,"name")
[1] "data"
> class(i1)
[1] "environment"
> str(i1)
<environment: 0xf785ed8>
- attr(*, "name")= chr "data"
如何在函數中使用attach和identify並返回附加對象的id?
不知道這是你的問題的根源,但' return ids'應該是'return(ids)'。 – nrussell
或者只是'ids' .. –
如果你只是完全避免了'attach' /'detach'會怎麼樣? –