Subject: Re: [R] Oh apply functions, how you confuse me
Is this close to what you are asking for:
> require(data.table)
> Dt.. <- data.table(Df..)
> R <- Dt..[,
+ list(
+ sum = sum(Volume)
+ , weight = sum(Volume * Mph) / sum(Volume)
+ )
+ , by = list
Is this close to what you are asking for:
> require(data.table)
> Dt.. <- data.table(Df..)
> R <- Dt..[,
+ list(
+ sum = sum(Volume)
+ , weight = sum(Volume * Mph) / sum(Volume)
+ )
+ , by = list(Min5Break, Day, Hour, Dir)
+ ]
> R
Min5Break Day Hour Dir
I would suggest using a 'for' loop
rather than an apply function. The
advantage is that you will probably
understand the loop that you write,
and it will run in roughly the same
amount of time as a complicated call
to an apply function that you don't
understand.
On 01/09/2011 18:11, LCOG1 wrote:
Hi guys,
I have a crap load of data to parse and have enjoyed creating a script that
takes this data and creates a number of useful graphics for our area. I am
unable to figure out one summary though and its all cause I dont fully
understand the apply family of functions. Consider the following:
4 matches
Mail list logo