Skip to content
Prev 198783 / 398506 Next

How to execute a funcition which name is stored in a string?

Hi, everybody

Is there any way to execute a function, which name is stored in a string.
such as:
a <- "ls()"
foo(a) ## same as ls() itself.

Or, to execute a R command, which is stored in a string
such as:
a <- "m1 <- matrix(1:9,3,3)"
foo(a) ## same as the assignment itself