Message-ID: <4A127859.6060403@idi.ntnu.no>
Date: 2009-05-19T09:14:01Z
From: Wacek Kusnierczyk
Subject: Generic 'diff'
In-Reply-To: <4A1271D0.9060607@idi.ntnu.no>
Wacek Kusnierczyk wrote:
>
> btw., the error message here is confusing:
>
> lag = 1:2
> diff(1:10, lag=lag)
> # Error in diff.default(1:10, lag = lag) :
> # 'lag' and 'differences' must be integers >= 1
>
> is.integer(lag)
> # TRUE
> all(lag >= 1)
> # TRUE
>
> what is meant is that lag and differences must be atomic 1-element
> vectors of positive integers. or rather integer-representing numerics:
>
> lag = 1
> diff(1:5, lag=1)
> # fine
> is.integer(lag)
> # FALSE
>
>
... and even non-integer-representing non-integers are fine:
diff(1:5, lag=pi)
# 3 3
vQ