If you would post a subset of your data so that we can see what you
are talking about, we could probably help you come up with a solution.

On Sat, Mar 3, 2012 at 7:50 PM, Mikhail Titov <m...@gmx.us> wrote:
> Hello!
>
> I’m having stacked data in a data.frame with 2 factors, ordered POSIXct, and 
> actual value as numeric (as if for lattice::xyplot).
>
> I would like to calculate first difference using “diff” function within 
> corresponding subsets/partitions. Since data.frame is organized by factors 
> and has sorted dates, it seems like "by" is a good candidate for the job. 
> However it returns just a dumb list of vectors.
>
> It seems that I can use either expand.grid to remap results of "by" and hope 
> that I won't mess up order, or I can use "unique(subset(x,select=c(foo,bar)))"
>
> In overall it looks like quite many steps for such task not counting 
> assignment of those differences back to original data.frame starting from 2nd 
> position in each partition (as diff returns shorter vector).
>
> Am I on the right track or is there an easier way to do that?
>
> Mikhail
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to