Remove objects from different environments
- by Fred
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.