[R] Generating Correlation matrix

David Winsemius dwinsemius at comcast.net
Wed Feb 11 16:00:43 CET 2009


We still have nothing at all specific about what these files even look  
like. Perhaps the problem is that you have not even read basic  
introductory material an don't yet know how to import files? If so,  
then look at:

?read.table    #which also  has material on read.csv

Perhaps:
read.csv(file ="c:/dir1/dir2/equity.csv", header = TRUE) # or FALSE

-- 
David Winsemius
On Feb 11, 2009, at 7:42 AM, Maithili Shiva wrote:

> Dear Ms Sarah,
>
> Thanks for your reply. Actually I am new to this R language and  
> besides coping with the demending office commitments, whenever  
> possible, I am trying to learn the R language on my own.
>
> Had it been Excel, I could have done in fraction of seconds however  
> I need to use R language for this. Its the simple correlation I am  
> looking for.
>
> I have a dataset of (say 500) observations EACH for these three  
> variables viz. Equity, Forex and Bond. I have three different files  
> (equity.csv, Forex.csv and Bond.csv) and need to generate the  
> regular correlation among these variabls. I had attached these files  
> in my earlier mail least knowing we can't do so. I did try to search  
> help, but wasn't that confident about it so I am requesting for the  
> guidance.
>
> With regards
>
> Maithili
>
>
>
>
> --- On Wed, 2/11/09, Sarah Goslee <sarah.goslee at gmail.com> wrote:
>
>> From: Sarah Goslee <sarah.goslee at gmail.com>
>> Subject: Re: [R] Generating Correlation matrix
>> To: "Maithili Shiva" <maithili_shiva at yahoo.com>
>> Cc: r-help at r-project.org
>> Date: Wednesday, February 11, 2009, 11:37 AM
>> Assuming you want "ordinary" correlations -
>> Pearson or Spearman - and not
>> some financial thing I've never heard of, searching the
>> help for correlation
>> would have gotten you to cor(), and probably also to other
>> more elaborate
>> constructions.
>>
>> If your problem is more complex than that, we need a better
>> description
>> of the difficulty, along with example code for as far as
>> you can get yourself.
>>
>> Sarah
>>
>> On Wed, Feb 11, 2009 at 5:44 AM, Maithili Shiva
>> <maithili_shiva at yahoo.com> wrote:
>>> Dear R helpers,
>>>
>>> I have generated a portfolio of Equity, Dollar Rate
>> and say zero coupon bond. I have calculated the daily
>> returns based on the prices available for last two years.
>>>
>>> Now, I have three seperate csv files (Equity.csv,
>> Dollar.csv and Bond.csv) containing the respective returns.
>> I need to calculate the correlation matrix between the
>> retuns of these assets. Please guide me how this can be done
>> in R.
>>>
>>> I have attached the three csv files.
>>>
>>> Thanking in advance
>>>
>>> With regards
>>>
>>> Maithili
>>>
>>>
>>>
>>>
>>
>>
>>
>> -- 
>> Sarah Goslee
>> http://www.functionaldiversity.org
>
> ______________________________________________
> R-help at 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.




More information about the R-help mailing list