On Feb 7, 2010, at 1:57 PM, James Rome wrote:
On 2/7/2010 1:35 PM, David Winsemius wrote:But to answer your
question:
apply(d, 1, function(z) aggregate(z, by=list(s), FUN=sum) )
David,
That works, but I do not understand why I could not use aggregate
directly. And the answer comes out as
This works. But I wish I could write it without a lot of trial and
error. :-(
ha = matrix(nrow=7, ncol=24)
colnames(ha) = as.character(c(0:23))
rownames(ha) = rownames(maxrdf)
m = as.matrix(maxrdf)
for(j in 1:7) {
x = aggregate(m[j,], by=list(s), FUN=sum)
ha[j,] = x[
On 2/7/2010 1:35 PM, David Winsemius wrote:But to answer your question:
> apply(d, 1, function(z) aggregate(z, by=list(s), FUN=sum) )
David,
That works, but I do not understand why I could not use aggregate
directly. And the answer comes out as a list, which thus far baffles me.
How do I get the
On 2/7/2010 1:32 PM, David Winsemius wrote:You have a dataframe with 96
columns and a single row named "Sunday". My guess is that was not your
intent. How did "d" come to exist?
I was trying to make a simpler example. The actual code uses a data
frame maxrdf:
> dput(maxrdf)
structure(list(`0` = c(
On Feb 7, 2010, at 1:32 PM, David Winsemius wrote:
You have a dataframe with 96 columns and a single row named
"Sunday". My guess is that was not your intent. How did "d" come to
exist?
But to answer your question:
> apply(d, 1, function(z) aggregate(z, by=list(s), FUN=sum) )
$Sunday
G
You have a dataframe with 96 columns and a single row named "Sunday".
My guess is that was not your intent. How did "d" come to exist?
--
David.
On Feb 7, 2010, at 1:29 PM, James Rome wrote:
dput(d)
structure(list(`0` = 0, `1` = 1, `2` = 0, `3` = 0, `4` = 0, `5` = 0,
`6` = 0, `7` = 0, `8
> dput(d)
structure(list(`0` = 0, `1` = 1, `2` = 0, `3` = 0, `4` = 0, `5` = 0,
`6` = 0, `7` = 0, `8` = 0, `9` = 0, `10` = 0, `11` = 0, `12` = 0,
`13` = 0, `14` = 0, `15` = 0, `16` = 0, `17` = 2, `18` = 0,
`19` = 0, `20` = 0, `21` = 0, `22` = 0, `23` = 0, `24` = 0,
`25` = 0, `26` = 0
On Feb 7, 2010, at 1:08 PM, James Rome wrote:
I am trying to get hourly totals, given 15-minute bins.
s = seq(0, 95, 1)
s = floor(s/4) # 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3
4 . . .
s
[1] 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5
5 5 6
[26] 6 6 6
I am trying to get hourly totals, given 15-minute bins.
s = seq(0, 95, 1)
s = floor(s/4) # 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 4 . . .
> s
[1] 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5
5 5 6
[26] 6 6 6 7 7 7 7 8 8 8 8 9 9 9 9 10 10 10 10 11
9 matches
Mail list logo