Re: [R] Howto Compute Pairwise Similarity/Correlation Matrix from aData Frame

From: Gundala Viswanath <gundalav_at_gmail.com>
Date: Wed, 18 Jun 2008 17:53:09 +0900

Dear Dimitris,

Thanks so much for the reply.

However I got this memory error,when
I run it on my data (12.7Mb).

Is there a way I can make the
code more memory susceptible.

My dataset can be found here:
http://dpaste.com/57274/plain/

__BEGIN__
> data <- read.table("mydata.txt")
> nofsamp <- ncol(data)
> nofrow <- nrow(data)
>
> mat.data <- data.matrix(data)
> corr <- cor(t(mat.data))
R(1294) malloc: *** mmap(size=3948052480) failed (error code=12) *** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug R(1294) malloc: *** mmap(size=3948052480) failed (error code=12) *** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug Error: cannot allocate vector of size 3.7 Gb Execution halted
__END__

On Wed, Jun 18, 2008 at 4:39 PM, Dimitris Rizopoulos <dimitris.rizopoulos_at_med.kuleuven.be> wrote:
> try this:
>
> mat.data <- data.matrix(data)
> cor(t(mat.data))
>
>
> I hope it helps.
>
> Best,
> Dimitris
>
> ----
> Dimitris Rizopoulos
> Biostatistical Centre
> School of Public Health
> Catholic University of Leuven
>
> Address: Kapucijnenvoer 35, Leuven, Belgium
> Tel: +32/(0)16/336899
> Fax: +32/(0)16/337015
> Web: http://med.kuleuven.be/biostat/
> http://www.student.kuleuven.be/~m0390867/dimitris.htm
>
>
> ----- Original Message ----- From: "Gundala Viswanath" <gundalav_at_gmail.com>
> To: <r-help_at_stat.math.ethz.ch>
> Sent: Wednesday, June 18, 2008 8:55 AM
> Subject: [R] Howto Compute Pairwise Similarity/Correlation Matrix from aData
> Frame
>
>
>> Hi,
>>
>> I have the following 5 vectors. I wish to compute
>> the pairwise Pearson Correlation matrix with this data.frame.
>> Is there a compact way to do it?
>>
>> At the end I hope to create a heatmap out of this correlation matrix.
>>
>> __BEGIN__
>>>
>>> data <- read.table("mydata.txt")
>>> print(data)
>>
>> V1 V2 V3 V4 V5 V6 V7 V8 V9
>> 1 42.3 53.2 76.4 78.8 83.6 91.3 92.2 105.8 109.6
>> 2 6.8 9.7 12.7 13.1 14.6 16.3 17.2 17.9 18.1
>> 3 10.6 21.5 34.4 38.2 38.8 50.0 60.7 64.0 64.3
>> 4 215.3 227.4 227.7 245.0 257.2 260.0 269.8 287.3 340.2
>> 5 4.1 4.2 4.6 6.4 6.8 6.9 16.9 17.6 23.3
>>
>> __END__
>>
>> Currently I am stuck in constructing the very matrix itself from
>> double loop.
>>
>> __BEGIN__
>> data <- read.table("GDS596_part1.txt")
>> nofrow <- nrow(data)
>>
>> for (rwx in 1:nofrow) {
>> print(data[rwx,])
>> for (rwy in 1:nofrow) {
>> print(data[rwy,])
>>
>> thecor <- cor(data[rwx,],data[rwy.], method="pearson")
>> # not sure how to proceed from here.
>> }
>>
>> }
>> __END__
>>
>> Please advice.
>>
>> - Gundala Viswanath
>> Jakarta - Indonesia
>>
>> ______________________________________________
>> 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.
>>
>
>
> Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
>
>



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. Received on Wed 18 Jun 2008 - 10:16:08 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 18 Jun 2008 - 10:31:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive