Change tempdir() in session (update R_TempDir)

前端 未结 5 833
既然无缘
既然无缘 2021-01-01 03:16

I am looking for a way to change the tempdir() location after an R session has started. I think it would be required to update the C level global variable

5条回答
  •  醉梦人生
    2021-01-01 03:36

    If you unlock tempdir() and re-assign a new function to the baseenv() it might work:

    tempdir <- function() "/NewTempDir"
    unlockBinding("tempdir", baseenv())
    assignInNamespace("tempdir", tempdir, ns="base", envir=baseenv())
    assign("tempdir", tempdir, baseenv())
    lockBinding("tempdir", baseenv())
    

提交回复
热议问题