Adding an element to a call object in R

Viewed 75

I was wondering how I can add & weeks == 1 to the end of s below?

s <- substitute(type == 1 & ESL == 1 & prof == T) # A `call` object

# Tried the following to add "& weeks == 1" to end of `s` without success:

 c(s, "& weeks == 1")

Desired output a call object like below:

type == 1 & ESL == 1 & prof == T & weeks == 1

1 Answers

This can be done without conversion to text solely at the language level using bquote:

bquote(.(s) & weeks == 1)
## type == 1 & ESL == 1 & prof == T & weeks == 1
Related