Or even:
with(x, a / coredata(a[1]) )
On Sun, May 16, 2010 at 7:48 PM, Gabor Grothendieck
wrote:
> Normally that would be written like this using the coredata extraction
> function which extracts the data portion of a zoo object:
>
> x$a / coredata( x$a[1] )
>
> On Sun, May 16, 2010 at 7:32 PM,
Normally that would be written like this using the coredata extraction
function which extracts the data portion of a zoo object:
x$a / coredata( x$a[1] )
On Sun, May 16, 2010 at 7:32 PM, Sean Carmody wrote:
> Thanks David,
>
> You comment made me realise that whereas when x is a data frame, x$a
Thanks David,
You comment made me realise that whereas when x is a data frame, x$a is a
numeric vector,
when x is of class zoo, x$a is also of class zoo, so the following does what
I was expecting:
x$a/as.numeric(x$a[1])
Sean.
On Sun, May 16, 2010 at 9:25 PM, David Winsemius wrote:
>
> On May
When you combine zoo objects with arithmetic it merges them using all = FALSE:
> library(zoo)
> x <- data.frame(a=1:5*2, b=1:5*3)
> x <- zoo(x); x
a b
1 2 3
2 4 6
3 6 9
4 8 12
5 10 15
>
> # these two are the same
>
> x$a/x$a[1]
1
1
>
> m <- merge(x$a, x$a[1], all = FALSE)
> m
x$a x$a[
On May 16, 2010, at 2:00 AM, Sean Carmody wrote:
I am a bit confused about the different approaches taken to
recycling in
plain data frames and zoo objects. When carrying out simple
arithmetic,
dataframe seem to recycle single arguments, zoo objects do not. Here
is an
example
x <- data.
I am a bit confused about the different approaches taken to recycling in
plain data frames and zoo objects. When carrying out simple arithmetic,
dataframe seem to recycle single arguments, zoo objects do not. Here is an
example
> x <- data.frame(a=1:5*2, b=1:5*3)
> x
a b
1 2 3
2 4 6
3 6
6 matches
Mail list logo