I\'m having a problem with using double quotes while formatting text strings being sent to functions in R.
Consider an example function code:
foo <
Two ways I know. First is to just use single quotes to start and end the character string:
> cat( 'Learning "R" is fun!' )
Learning "R" is fun!
Second is to escape the double quotes:
> cat( "Learning \"R\" is fun!" )
Learning "R" is fun!
Note that this works because I use cat
, which is intended to output strings to the console. It seems you use print()
which shows the object rather than output it
You can try these approaches:
foo <- function(numarg = 5, textarg = "** Default text **" ){
cat(c(textarg, "\n"))
val <- (numarg^2) + numarg
return(val)
}
foo <- function(numarg = 5, textarg = "** Default text **" ){
print(noquote(textarg))
val <- (numarg^2) + numarg
return(val)
}
foo( 4, "Learning R is fun!" )
foo( 4, 'Learning "R" is fun!' )