[R] Odp: Letters(V1,V2..) as row col indices instead of numbers
Petr PIKAL
petr.pikal at precheza.cz
Fri Jan 28 14:47:31 CET 2011
Hi
r-help-bounces at r-project.org napsal dne 28.01.2011 09:52:05:
>
> What makes matrix to print V1, V2 as the row and col indices instead of
> numbers??
>
> cdata = read.table("ramesh.txt") #cdata is read from a file.
> c1 = cor(cdata)
>
> I am printing c1 below. I need only numbers. I dont need V1, V2...what
> should I do in this case??
> http://r.789695.n4.nabble.com/file/n3243980/ramesh.txt ramesh.txt
>
> V1 V2 V3 V4 V5 V6 V7
> V1 1.0000000 0.9471591 0.9191233 0.9403129 0.9689690 0.9621362
0.9529811
> V2 0.9471591 1.0000000 0.8888108 0.9108174 0.9703906 0.9425248
0.9294308
> V3 0.9191233 0.8888108 1.0000000 0.8788107 0.9077245 0.9078971
0.8965331
> V4 0.9403129 0.9108174 0.8788107 1.0000000 0.9477058 0.9017977
0.8646251
> V5 0.9689690 0.9703906 0.9077245 0.9477058 1.0000000 0.9531459
0.9162016
> V6 0.9621362 0.9425248 0.9078971 0.9017977 0.9531459 1.0000000
0.9447130
> V7 0.9529811 0.9294308 0.8965331 0.8646251 0.9162016 0.9447130
1.0000000
> V8 0.9167526 0.9395067 0.8491496 0.8942693 0.9460702 0.9304229
0.8505287
> V9 0.9512951 0.9598302 0.8666839 0.9465725 0.9645178 0.9486105
0.8979753
> V10 0.9551633 0.9040160 0.9180022 0.9429816 0.9448644 0.9220875
0.9075537
Vn are names of columns which R gave to your matrix when you read it as a
data frame. And cor just makes a matrix of pairwise corelation
coefficients from this data frame conveniently named from this data frame.
If you do not want those names just unname it.
c1 = unname(cor(cdata))
But I wonder why you dislike those names which are, well, just names.
Regards
Petr
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/Letters-V1-V2-as-
> row-col-indices-instead-of-numbers-tp3243980p3243980.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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