I am trying to build a function in which I have to use a comma separator between two strings to pass as formula (brmsformula need this format to specify sigma), but I get an error cause formula
does not want ,
inside it:
library(brms)
term1 <- "mpg ~ 0 + Intercept + cyl"
term2 <- "sigma ~ 0 + cyl"
formula0 <- brms::brmsformula(paste( AAA, BBB, sep = ', ' ))
Error in str2lang(x) : <text>:1:26: unexpected ',' 1: mpg ~ 0 +
Intercept + cyl,
^
I know I can simply pass it from terminal as:
> brms::brmsformula( mpg ~ 0 + Intercept + cyl, sigma ~ 0 + cyl )
mpg ~ 0 + Intercept + cyl
sigma ~ 0 + cyl
but I need to create it inside a function that can have (or not) sigma specifications, thus pasting these two terms (if sigma is specified).
I have googled around and looked similar post (like this or this) but these does not apply to my case. Does anybody know how to achieve this?