On Wed, 2005-10-12 at 12:01 -0700, t c wrote:> I have a dataset with three variables: date, var1, var2
> How can I calculate the correlation, by date, between var1 and var2?
>
> e.g.
>
>
> date var1 var2
> 1/1/2001 5 4
> 1/1/2001 8 5
> 1/1/2001 9 7
>
>
>
> 2/1/2001 7 2
> 2/1/2001 2 1
> 2/1/2001 4 6
>
>
>
> 3/1/2001 3 5
> 3/1/2001 4 3
> 3/1/2001 6 9
> 3/1/2001 7 -1
>
>
>
> the results I want:
> 1/1/2001 0.891042111
> 2/1/2001 0.075093926
> 3/1/2001 -0.263117406
t c,
Given your series of posts here, I would highly recommend that before
you consider spending money on a tutor or other similar resource, you
take the time to read the freely available documentation that both R
Core and useRs have kindly provided to the Community. The R Core manuals
are all available with your downloaded installation of R and/or from the
main R web site under Documentation as are the Contributed documents.
You will find that your time will be well invested in that effort.
If you read the Posting Guide for the e-mail lists, a link to which is
provided at the bottom of every e-mail that comes through, you will find
an excellent guide to the resources that are available to assist you in
using R.
Trying to learn R (as with any technical endeavor) without reading at
least a basic set of the growing list of documents, books and
publications on R is going to be problematic.
A hint for you here:
See ?by, ?tapply, ?split and ?lapply for guidance on how to generate
summary statistics on subsets of data.
HTH,
Marc Schwartz