Instead of doing
a <- loadBigObject("a")
b <- loadBigObject("b")
I’d like to call a function like
loadBigObjects(list("a","b"))
And be able to access the a and b objects.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is not clear what
loadBigObjects()does or where it will look foraandb. How does it load the objects from file or sourcing code?There are lots of options in general:
sys.source()allows an R file to be sourced to a given environmentload()which will load an.Rdatafile to a given environmentassign()in combination with any object created byloadBigObjects()or a call toreadRDS()can also load an object to a given environment.From within your function, you’ll want to specify the environment in which to load objects as the Global Environment by using
globalenv(). If you don’t do that then the object will only exist in the evaluation frame of the runningloadBigObjects(). E.g.(as per your comment to @GSee’s Answer, and assuming the
list("a","b")is sufficient information forreadRDS()to locate and open the object.