Inspired by discussion in "Need very fast application of 'diff' - ideas?"
(around https://stat.ethz.ch/pipermail/r-help/2012-January/301873.html), I have
another suggestion.
Suggestion 3: Make 'diff.default' run faster.
For vector case (if suggestion 2 is not applied or if unclassed input is
t
--- On Mon, 28/1/13, Suharto Anggono Suharto Anggono
wrote:
> From: Suharto Anggono Suharto Anggono
> Subject: Suggestions for 'diff.default'
> To: r-de...@lists.r-project.org
> Date: Monday, 28 January, 2013, 5:31 PM
> I have suggestions for function
> 'diff.default' in R.
>
>
> Suggestion
I have suggestions for function 'diff.default' in R.
Suggestion 1: If the input is matrix, always return matrix, even if empty.
What happens in R 2.15.2:
> rbind(1:2)# matrix
[,1] [,2]
[1,]12
> diff(rbind(1:2)) # not matrix
integer(0)
> sessionInfo()
R version 2.15.2 (2012-10