I am not sure exactly what you were trying to do. read.table will read your
data into an object with R and you can change the row names:
> dat <- read.table(textConnection("H1 H2 H3
+ 1 2 3
+ 4 54 6
+ 6 7 8
+ 3 2 1"), header=TRUE)> closeAllConnections()
> dat
H1 H2 H3
1 1 2 3
2 4 54 6
3 6 7 8
4 3 2 1> row.names(dat) <- paste('g', seq(nrow(dat)), sep="")
> dat
H1 H2 H3
g1 1 2 3
g2 4 54 6
g3 6 7 8
g4 3 2 1>
It does not change the file on the disk and therefore file.show will display
the original file. If you want to rewrite the file, then look at
write.table.
On Sun, Jun 8, 2008 at 1:48 AM, Paul Adams <pma3622@yahoo.com> wrote:
> Hello everyone,
> I have a data frame in which I am wanting to eliminate the row labels and
> then relabel the rows with
> g1-g2000.I have used the following code:
> dat<-read.table(file="C:\\Documents and Settings\\Owner\\My
> Documents\\colon cancer1.txt",header=T,row.names=1)
> file.show(file="C:\\Documents and Settings\\Owner\\My Documents\\colon
> cancer1.txt")
> I thought that this would eliminate the row labels (first column) because
> of the header=T and row.names=1 argument.
> Then I tried to add the following to relabel the rows (first column)
> g1-g2000
> dat<-read.table(file="C:\\Documents and Settings\\Owner\\My
> Documents\\colon cancer1.txt",header=T,row.names=1)
> row.names(dat)<-paste("g",c(1:nrow(dat)),sep="")
> file.show(file="C:\\Documents and Settings\\Owner\\My Documents\\colon
> cancer1.txt")
> However I still get the same row labels that I have to begin with.
> Any help or explantation would be much appreciated.
> Paul
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
[[alternative HTML version deleted]]