Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing named arguments through magrittr

Tags:

r

piping

magrittr

I am trying to implement magrittr's piping syntax and getting stuck very early. I have read everything I can find on it online but I just don't see how to pass named arguments though the %>% function.

I would like:

Nsamp+2 %>% seq(0, 1, length.out = .)

To do the same as:

seq(0,1,length.out=Nsamp+2)
like image 847
Francis Smart Avatar asked Dec 30 '25 17:12

Francis Smart


1 Answers

As @Victorp pointed out

Nsamp <- 3
(Nsamp + 2) %>% seq(0, 1, length.out = . )
# [1] 0.00 0.25 0.50 0.75 1.00

should work just fine.

like image 87
MrFlick Avatar answered Jan 02 '26 05:01

MrFlick