[R] Comparing data

Florent D. flodel at gmail.com
Tue Nov 29 02:06:27 CET 2011


Unlike a data.frame, a matrix can only hold one type of data. Since
you have a column of characters ("labSt") in your original data,
turning it into a matrix will give you a matrix of characters. You can
check it is the case by asking class(DF.m[1,1]).

So you'll have to remove this labSt column before you use as.matrix,
maybe use it for your rownames if you want to keep labSt around.


On Mon, Nov 28, 2011 at 11:49 AM, Matevž Pavlič
<matevz.pavlic at gi-zrmk.si> wrote:
> Hi all,
>
>
>
> i have a data set cintaining 14 columns  and 11 rows. Rows represent single point and columns represent the parameter measured.
>
> I wiuld like to compare the data to see which are more alike. I used the cluster analysis, but now i ma wondering if there are some other methods, since the cluster analysis did not give me the result i like.
>
> I tried to use factanal() for factor analysis but i geta an error saying that it can only be used on numerical data (which is odd since all i have is numerical data).
>
> For factanal i used this code :
>
>
>
> DFm<-read.csv("kemijaM.csv", sep=";", dec=".")           # input data
>
> DF.m<-as.matrix(DFm)                                                               # transform it to matrix
>
> factanal(DF, factors=5)                                                                # factor analysis
>
>
>
> Here is what data looks like....
>
>
>
> 'data.frame':  11 obs. of  14 variables:
>
> $ labSt            : Factor w/ 11 levels "2011/9496","2011/9497",..: 1 2 3 4 5 6 7 8 9 10 ...
>
> $ Mangan           : num  0.1313 0.6364 0.0889 0.0028 0 ...
>
> $ Kalcij           : num  0.192 0.566 0.172 0 0.303 ...
>
> $ Magnezij         : num  0.321 0.568 0.29 0.352 0 ...
>
> $ Fluorid          : num  0.6739 0.2283 0.7826 0.0109 0.2609 ...
>
> $ Hidrogenkarbonati: num  0.362 1 0.31 0 0.16 ...
>
> $ Kalij            : num  0.335 0.456 0.335 0.426 0 ...
>
> $ Sulfat           : num  0.692 0 0.517 0.609 0.609 ...
>
> $ Nitrati          : num  0.3934 0.0195 0.5008 0.3835 0.2601 ...
>
> $ Silikati         : num  0.55 1 0.5214 0.0429 0.7143 ...
>
> $ Fe               : num  0.786 0 0.357 0.214 0 ...
>
> $ Natrij           : num  0.1321 0.093 0.093 0.0579 0 ...
>
> $ m.Alkaliteta     : num  0.362 1 0.31 0 0.161 ...
>
> $ Klorid           : num  0.0372 0.02471 0.03895 0.02721 0.00107 ...
>
>
>>
>
>
>
> Any ideas would be greatly appreciated.
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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