[R] Correlation Matrix

Vito Ricci vito_ricci at yahoo.com
Fri Oct 8 14:09:13 CEST 2004


Hi Sundar,
many thanks for your suggestion: it's just I wished!
Best
Vito



 --- Sundar Dorai-Raj <sundar.dorai-raj at PDF.COM> ha
scritto: 
> 
> 
> Vito Ricci wrote:
> 
> > Hi,
> > 
> > I'm dealing with a datamining analysis: I've a lot
> of
> > categories of product sold per week (n. week =26,
> n.
> > categories about 50.
> > my dataframe is like this:
> > 
> >   Settimana ALIMENTI..ALTRI. ALIMENTI.APROTEICI
> > 1          1                3                 19
> > 2          2                2                  0
> > 3          3                1                 22
> > 4          4                2                  6
> > 
> > I computed correlation coefficents among
> categories
> > having a correlation matrix (53X53). Now I will
> > extract from this matrix only significative
> > correlations, or, in alternative correlations >0.5
> and
> > <-0.5, excluding  the other, and put this
> coefficients
> > in a dataframe.
> > 
> > I'm looking for significative correlations among
> > categories.
> > 
> > Is someone could help me? Many thanks in advance.
> > Is also someone using R for dataminig analysis
> like
> > me?
> > 
> > Vito
> > 
> 
> Assuming `x' is your data above, how about the
> following:
> 
> r <- cor(x)
> y <- which(lower.tri(r), TRUE)
> z <- data.frame(row = rownames(r)[y[, 1]],
>                  col = colnames(r)[y[, 2]],
>                  cor = r[y])
> subset(z, abs(cor) > 0.5)
> 
> #                row       col        cor
> # 1 ALIMENTI..ALTRI. Settimana -0.6324555
> 
> --sundar
> 
> 
>  

=====
Diventare costruttori di soluzioni

"The business of the statistician is to catalyze 
the scientific learning process."  
George E. P. Box


Visitate il portale http://www.modugno.it/
e in particolare la sezione su Palese http://www.modugno.it/archivio/cat_palese.shtml




More information about the R-help mailing list