Dear Gabor,
Many thanks!!
Best regards,
Antonio
Gabor Grothendieck escribió:
> aggregate can also be used:
>
> aggregate(d, list(d = d), length) # output is data frame
>
> or using zoo:
>
> library(zoo)
> aggregate(zoo(as.vector(d)), d, length) # output is a zoo object
>
> If what you
aggregate can also be used:
aggregate(d, list(d = d), length) # output is data frame
or using zoo:
library(zoo)
aggregate(zoo(as.vector(d)), d, length) # output is a zoo object
If what you actually have is a zoo object such as this one:
z <- zoo(1:10, d)
then the last statement co
Brandt, T. (Tobias) escribió:
>
> I think the following does what you want:
>
> > (d <- structure(c(6586, 6586, 6589, 6593, 6593, 6593, 6598, 6598,
> 6598, 6598), class = "Date"))
> [1] "1988-01-13" "1988-01-13" "1988-01-16" "1988-01-20" "1988-01-20"
> "1988-01-20" "1988-01-25"
> [8] "1988-01-2
-20 1988-01-25
2 1 3 4
>
HTH,
Tobias
>-Original Message-
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] On Behalf Of antonio
>rodriguez
>Sent: 02 November 2006 09:58 AM
>To: Gabor Grothendieck
>Cc: R-Help
>Subject:
Dear Gabor,
The solution below was very useful for me, but I have, I hope, one last
question about extracting some specific data. How to count , from below,
the number of times a date is repeated, that is:
starts
[1] "1988-01-13" "1988-01-13" "1988-01-16" "1988-01-20" "1988-01-20"
[6] "1988-01
Gabor Grothendieck escribió:
> On 10/29/06, antonio rodriguez <[EMAIL PROTECTED]> wrote:
>> Gabor Grothendieck escribió:
>
>> Thanks Gabor! Now it's OK (nice the output of dput. I was reluctant to
>> paste all data because is 6575 days long!)
>>
>
> You can write the following, say, to display just
On 10/29/06, antonio rodriguez <[EMAIL PROTECTED]> wrote:
> Gabor Grothendieck escribió:
> Thanks Gabor! Now it's OK (nice the output of dput. I was reluctant to
> paste all data because is 6575 days long!)
>
You can write the following, say, to display just a bit:
dput(z[1:10], control = "all")
Gabor Grothendieck escribió:
> Sorry, the line starting idx <- should have time(z) in place of z.
> That is,
>
> year <- as.Date(c(
> "1988-01-13", "1988-01-14", "1988-01-16", "1988-01-20", "1988-01-21",
> "1988-01-22", "1988-01-25", "1988-01-26", "1988-01-27", "1988-01-28"))
>
> x <- c(
> 7.973946
Sorry, the line starting idx <- should have time(z) in place of z.
That is,
year <- as.Date(c(
"1988-01-13", "1988-01-14", "1988-01-16", "1988-01-20", "1988-01-21",
"1988-01-22", "1988-01-25", "1988-01-26", "1988-01-27", "1988-01-28"))
x <- c(
7.973946, 9.933518, 7.978227, 7.512960, 6.641862
Gabor Grothendieck escribió:
> Try this:
>
> # test data
> x <- c(1:4, 6:8, 10:14)
> z <- zoo(x, as.Date(x))
>
> # idx is 1 for first run, 2 for second run, etc.
> idx <- cumsum(c(1, diff(z) != 1))
>
> # starts replaces each time with the start time of that run
> # ends is similar but for ends
> st
Try this:
# test data
x <- c(1:4, 6:8, 10:14)
z <- zoo(x, as.Date(x))
# idx is 1 for first run, 2 for second run, etc.
idx <- cumsum(c(1, diff(z) != 1))
# starts replaces each time with the start time of that run
# ends is similar but for ends
starts <- time(z)[match(idx, idx)]
ends <- time(z)[c
Gabor Grothendieck escribió:
> On 10/28/06, antonio rodriguez <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> Having an zoo object I can subset it to obtain the days where I have the
>> values within some range:
>>
>> is.zoo(z)
>> TRUE
>>
>> subset(z[,1], z[,1]>=5 & z[,1]<= 10) #Yields: Year(day)
>>
>> 198
On 10/28/06, antonio rodriguez <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Having an zoo object I can subset it to obtain the days where I have the
> values within some range:
>
> is.zoo(z)
> TRUE
>
> subset(z[,1], z[,1]>=5 & z[,1]<= 10) #Yields: Year(day)
>
> 1988(13) 1988(14) 1988(16) 1988(20) 1988(
13 matches
Mail list logo