In rlang what is the difference between 1:10 and !!(1:10)?

Hi, and welcome to community.rstudio.com!

identical(!!(1:10), rep(10, TRUE) )
[1] FALSE
So, what makes them not identical?

I don't know if you swapped the syntax intentionally in your second-to-last chunk, but if you run identical(!!(1:10), rep(TRUE, 10)), you get

> identical(!!(1:10), rep(TRUE, 10))
[1] TRUE

Notice the arguments inside rep() are TRUE, 10, not 10, TRUE as you have in your post. So in my code, TRUE is being repeated 10 times, which makes it identical to the vector created by !!(1:10).

As for correct usage - I think this gets into quosures, which I'm not seasoned with, so hopefully someone more familiar can chime in here!

By the way, it seems there's some overlap between this post and the other post you've made here:

Are both of these posts seeking the same information?

3 Likes