You're looking for delayedAssign
.
delayedAssign('x', read.table(text = "a b \n 1 2", header=TRUE))
You can see that the expression executes when x
is first requested:
delayedAssign('x', {
message('assigning')
read.table(text = "a b \n 1 2", header=TRUE)
})
x
# assigning
# a b
# 1 1 2