What's your favorite one-liner in R
?
Include a short companion example, and limit to one tip per post, please.
Note, ;
is cheating.
Example: calculate x[i] / x[i-1]
for a vector x
,
x <- 1:10
Reduce("/", as.data.frame(embed(x, 2)))
(collected from R-help, I forget who/when)
Edit: after some initial controversy, it looks like the question is now reopen for entries.