Cleaning up the global environment after sourcing: How to remove objects of a certain type in R

前端 未结 3 470
暗喜
暗喜 2021-02-06 13:24

I read in a public-use dataset that created dozens of temporary vectors in the process of building a final dataframe. Since this dataframe will be analyzed as part of a larger p

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-06 13:54

    I have scripts like this save the result as an RDS file and then open the result in a new session (or alternatively, after clearing everything). That is,

    a <- 1
    saveRDS(a, file="a.RDS")
    rm(list=ls())
    a <- readRDS("a.RDS")
    a
    ## [1] 1
    

提交回复
热议问题