[R] indexing in data frames
R. Michael Weylandt
michael.weylandt at gmail.com
Fri Aug 10 01:22:17 CEST 2012
On Thu, Aug 9, 2012 at 5:30 PM, arun <smartpink111 at yahoo.com> wrote:
>
> lapply(1:length(a$c),function(x) a$b[x]-a$c[[x]])
Arun,
I've seen you use this idiom a few times lately and I'd just like to note that
seq_along()
is an (underutilized) primitive and a safer and faster alternative
(avoiding the pathological length(x) = 0 case).
Cheers,
Michael
More information about the R-help
mailing list