Examining contents of .rdata file by attaching into a new environment - possible?

后端 未结 4 613
再見小時候
再見小時候 2021-01-31 22:48

I am interested in listing objects in an RDATA file and loading only selected objects, rather than the whole set (in case some may be big or may already exist in the environment

4条回答
  •  醉梦人生
    2021-01-31 23:25

    You can suppress the warning by setting warn.conflicts=FALSE on the call to attach. If an object is masked by one in the global environment, you can use get to retreive it from your attached data.

    x <- 1:10
    save(x, file="x.rData")
    #attach("x.rData", pos=2, warn.conflicts=FALSE)
    attach("x.rData", pos=2)
    (x <- 1)
    # [1] 1
    (x <- get("x", pos=2))
    # [1]  1  2  3  4  5  6  7  8  9 10
    

提交回复
热议问题