I would like to use delayed assign to assign a new value to a slot of an S4 object. This assignment is basically a database query, and I only want the database query to be executed when the value is actually used.
But for the sake of testing this will do as well:
testFunction <- function(id = 1){
print("running query")
return(id)
}
delayedAssign("test", testFunction(id = 2))
This works. "running query" is only printed when test is called, not on assignment. In contrast to:
test2 <- testFunction(id = 2)
Now I would like to be able to do the same thing, but then on a slot.
delayedAssign("someObject@slotName", testFunction(id = 2))
This unfortunately creates an object names 'someObject@slotName' in the current environment. Any ideas on how to solve this?