Remove objects from different environments
Posted
by
Fred
on Stack Overflow
See other posts from Stack Overflow
or by Fred
Published on 2011-06-30T14:58:06Z
Indexed on
2011/06/30
16:22 UTC
Read the original article
Hit count: 208
I have an R
script file that executes a second R
script via:
source("../scripts/second_file.R")
That second file has the following lines:
myfiles <- list.files(".",pattern = "*.csv")
...
rm(myfiles)
When I run the master R
file I get:
> source("../scripts/second_file.R")
Error in file.remove(myfiles) : object 'myfiles' not found
and the program aborts.
I think this has something to do with the environment. I looked at ?rm()
pages but less than illuminating. I figure I have to give it a position argument, but not sure which.
© Stack Overflow or respective owner