[R] shift and pop equivalent in R

Duncan Murdoch murdoch.duncan at gmail.com
Tue Apr 20 20:40:16 CEST 2010


On 20/04/2010 2:03 PM, Xie Chao wrote:
> Dear All,
>
> I am wondering is there any shift (or pop or push or unshift) equivalent in R?
> For example,
> shift(x)   # should return x[1], and x becomes x[-1]
>   

Not in base R.  Generally speaking, functions with side effects are 
frowned upon.  It is possible to write it yourself, but you need to 
watch out for weird cases like

shift(x + y)

where it's not at all clear what the side effect should be.

Duncan Murdoch
> Thanks a lot.
>
> Best Regards,
> Xie Chao
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list