run from Shell R function with parameter, that con

2019-08-11 06:13发布

问题:

Suppose, I have function:

 my_function<-function(string) return(string)

When I run it from R:

>my_function('string"with"quotes')
[1] "string\"with\"quotes"

It works well. But when I try to run this function from Shell:

  R -e "source('./my_function.R'); my_function('string"with"quotes')"

It fails with error, because shell can't deal with quotes.

Is there any solution for this problem?

P.S. I need to run this function directly from Shell.

标签: r shell quotes