Re: [R] reading of a matrix

From: Vladimir Eremeev <wl2776_at_gmail.com>
Date: Thu 05 Apr 2007 - 11:25:19 GMT

Schmitt, Corinna wrote:
>
> I still have problems with the reading of a matrix.
>
> Input: matrixData6.txt
>
> A-Paar B-Paar C-Paar D-Paar E-Paar
> A 1 3 5 7 9
> B 2 4 6 8 10
>
>
> R-commands:
> y=read.table(file="Z:/Software/R-Programme/matrixData6.txt")
> y
>
> Result:
> A.Paar B.Paar C.Paar D.Paar E.Paar
> A 1 3 5 7 9
> B 2 4 6 8 10
>
> If you look into the txt-file you can recognize that the column names
> are not the same. Why?
>

Using "_" in variable names was illegal earlier (now this rule seems to be relaxed).
read.table has converted names.
You could try to change them back (UNTESTED) names(y) <- gsub(".", "_", names(y)),

Schmitt, Corinna wrote:
>
> If I add in the txt-file the line "MyData:" infront of all followed by a
> newline. The R-command as above response an error. How can I read the
> modified input and get the following result:
>
> MyData:
>
> A.Paar B.Paar C.Paar D.Paar E.Paar
> A 1 3 5 7 9
> B 2 4 6 8 10
>

You could name your variable MyData:

> MyData<-read.table( )
> MyData

Schmitt, Corinna wrote:
>
> Another stupid question might be hows can I change the column and row
> names after I made "read.table"? I want to have the following result,
> for example:
>
> MyData:
>
> G H I J K
> M 1 3 5 7 9
> N 2 4 6 8 10
>
> I studied all manuals I could find and the help but could not understand
> the examples or interpret it right for my case.
>
> Thanks for help,
> Corinna

>

names(MyData)<-c("G","H","I","J","K")
row.names(MyData)<-c("M","N")

-- 
View this message in context: http://www.nabble.com/reading-of-a-matrix-tf3530874.html#a9854003
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@stat.math.ethz.ch 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 Thu Apr 05 21:32:46 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 05 Apr 2007 - 12:30:47 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.