Hello,
I ran into a bit of an odd one and I didn't know where to address it so it seemed most appropriate here. Essentially, I wanted to write the below code as setdiff(door,cardoor) %>% sample(,1) but it provides two numbers instead of one as should be the case with size = 1. The only way I can guarantee this output is if I specify size = 1 argument explicitly yet it is fine with the last one even though it is not written explicitly.
Any idea why the piped version does not work in the same way as the last one? All three these should technically be equivalent?
library(tidyverse)
set.seed(42)
door <- c(1,2,3)
cardoor <- 1
setdiff(door,cardoor) %>% sample(,size = 1)
setdiff(door,cardoor) %>% sample(,1)
sample(setdiff(door,cardoor),1)