Consider the following line:
to_run = "alpha = data.frame(a=1:3, b=2:4)"
or
to_run = "for (i in 1:10){print(i);print('Hello World!')}"
How to run code written as a string character in an object to_run?
One solution is to output the object to an external file and its source:
write.table(to_run, 'I.am.a.Path/folder/file.name', quote=F, row.names=F, col.names=F)
source('I.am.a.Path/folder/file.name')
Is there any other, more direct solution?
source
share