run from Shell R function with json string parameter -
i have function, works json string. when try in r:
my_function('{"menu":{"id":"file","value":"file","popup":{"menuitem":[{"value":"new","onclick":"createnewdoc()"},{"value":"open","onclick":"opendoc()"},{"value":"close","onclick":"closedoc()"}]}}}')
it works well.
but when try in shell command:
r -e "source('./my_function.r'); my_function('{"menu":{"id":"file","value":"file","popup":{"menuitem":[{"value":"new","onclick":"createnewdoc()"},{"value":"open","onclick":"opendoc()"},{"value":"close","onclick":"closedoc()"}]}}}')"
it fails error:
unexpected character 'm'
.
seems, problem quotes in json string. how can solve it?
p.s. need call my_function directly shell.
thank you!
write main script main.r,
source('./my_function.r') my_function('{"menu":{"id":"file","value":"file","popup":{"menuitem":[{"value":"new","onclick":"createnewdoc()"},{"value":"open","onclick":"opendoc()"},{"value":"close","onclick":"closedoc()"}]}}}')"
execute command terminal like,
rscript main.r
please make sure have r path configured.
Comments
Post a Comment