Re: [R] Force argument to have quotes

2017-06-06 Thread Nordlund, Dan (DSHS/RDA)
- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bert > Gunter > Sent: Tuesday, June 06, 2017 12:14 PM > To: Doran, Harold > Cc: r-help@r-project.org > Subject: Re: [R] Force argument to have quotes > > Harold: > > As a general rule, if you are usi

Re: [R] Force argument to have quotes

2017-06-06 Thread Bert Gunter
Harold: As a general rule, if you are using eval(parse(...)) you are doing it poorly in R; cf library("fortunes") fortune(106) Why is something like this not suitable: fun1 <- function(a1,a2,a3 = c("hi","by")) { cat(a3,a1+a2,"\n") } > fun1 (1,2) hi by 3 > fun1(1,2, a3 = "whoopee") whoopee

Re: [R] Force argument to have quotes

2017-06-06 Thread Boris Steipe
If I understand you correctly what you are really asking is how to embed quotes in a string so that it can be parse()'d as an expression. The answer would be: escape the quotes. R > myOptions <- "Hello" R > eval(parse(text = paste( "print(", myOptions, ")" ))) Error in print(Hello) : object

[R] Force argument to have quotes

2017-06-06 Thread Doran, Harold
I am writing a program where non-technical R users will read in a config file and the config file will then parse the arguments found within the config and pass them to respective functions. I'm having trouble (efficiently) writing a piece of code to retain quotation marks around the argument