Posts

Showing posts with the label Rlang

Converting A Quosure To A String In R

Answer : We can use quo_name print(paste("looking at", quo_name(thing))) quo_name does not work if the quosure is too long: > q <- quo(a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s + t + u + v + w + x + y + z) > quo_name(q) [1] "+..." rlang::quo_text (not exported by dplyr ) works better, but introduces line breaks (which can be controlled with parameter width ): > rlang::quo_text(q) [1] "a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + \n q + r + s + t + u + v + w + x + y + z" Otherwise, as.character can also be used, but returns a vector of length two. The second part is what you want: > as.character(q) [1] "~" [2] "a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s + t + u + v + w + x + y + z" > as.character(q)[2] [1] "a + b + c + d + e + ...