Welcome to R and the list.
Others may suggest books ( Nutshell was my first ) but first there are
some things that will help you
both in programming and getting help on the list.
You should post executable code in your question. So, build a toy example
of the data.frame you have
and show what you tried. Folks here should be able to run your toy example
and show you how to get the answer you want.
For your problem I'm guessing that aggregate() would be one path
?aggregate
you will need to specify "by" to aggregate by month
Steve
On Thu, Apr 12, 2012 at 7:10 AM, Robert Latest <boblatest@gmail.com>
wrote:
> Hi all,
>
> I'm just getting started in R. My problem is the following:
>
> I have a data frame (v1) with lots of production data measurements.
> Each row contains a single measurement ('ARI_MIT') with a
timestamp. I
> want to "lump" the data by months with their mean and standard
> deviation.
>
> I have already successfully managed to do the lumping by adding
> another column to my data frame:
>
> v1$MONTH = strftime(v1$TIMESTAMP, "%y%m")
>
> This makes a nice month-wise boxplot of my data, although I don't have
> an idea why:
> boxplot(v1$ARI_MIT ~ v1$MONTH)
>
> I don't need this plotted, though, but in the form of a new data frame
> with three columns: the month, the mean, and the standard deviation of
> all values from that month.
>
> I tried un-stacking v1 into a list of vectors and then looping over
> its elements, calculating the mean of each group:
>
> for (i in unstack(v1, v1$ARI_MIT ~ v1$MONTH)) { write(mean(i),
"") }
>
> This works, but how do I get the data into a data frame? With the
> month labels in a column? They are not avaliable inside the loop body.
>
> I know I need to get a book on R.
>
> Thanks,
> robert
>
> ______________________________________________
> 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.
>
[[alternative HTML version deleted]]