Hi, I used the write.table function to save data in txt file, and this is the output: V1 V2 V3 V4 1 YAL005C 21 14 11 2 YAL007C 2 1 4 3 YAL012W 8 16 3 4 YAL016W 24 23 23 5 YAL019W 3 3 2 6 YAL020C 2 4 2 7 YAL021C 7 5 5 8 YAL022C 3 1 2 but I need to remove the dimnames (first column) I tried to use dimnames function to remove it and then save it, but still, the output is the same These are the command lines, XX #matrix dimnames(XX)<-NULL write.table(XX,"XX.txt",quote=FALSE,sep="\t") Thanks in advance Roberto [[alternative HTML version deleted]]
Try this: write.table(XX,"XX.txt",quote=FALSE,sep="\t", row.names = FALSE) On 13/02/2008, Roberto Olivares Hernandez <roh at bio.dtu.dk> wrote:> Hi, > > I used the write.table function to save data in txt file, and this is the output: > > > V1 V2 V3 V4 > 1 YAL005C 21 14 11 > 2 YAL007C 2 1 4 > 3 YAL012W 8 16 3 > 4 YAL016W 24 23 23 > 5 YAL019W 3 3 2 > 6 YAL020C 2 4 2 > 7 YAL021C 7 5 5 > 8 YAL022C 3 1 2 > > > but I need to remove the dimnames (first column) > > I tried to use dimnames function to remove it and then save it, but still, the output is the same > > These are the command lines, > > XX #matrix > dimnames(XX)<-NULL > write.table(XX,"XX.txt",quote=FALSE,sep="\t", row.names = FALSE) > > > > Thanks in advance > Roberto > > > > [[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. >-- Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O
On Wed, 2008-02-13 at 14:06 +0100, Roberto Olivares Hernandez wrote:> Hi, > > I used the write.table function to save data in txt file, and this is the output: > > > V1 V2 V3 V4 > 1 YAL005C 21 14 11 > 2 YAL007C 2 1 4 > 3 YAL012W 8 16 3 > 4 YAL016W 24 23 23 > 5 YAL019W 3 3 2 > 6 YAL020C 2 4 2 > 7 YAL021C 7 5 5 > 8 YAL022C 3 1 2 > > > but I need to remove the dimnames (first column)You actually only want to remove one aspect of dimnames(XX), not all of them. The answer is in the documentation for write.table(). See argument 'row.names' in ?write.table. Setting row.names = FALSE will do what you want. HTH G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
What if you just removed the first column from your matrix: XX<-XX[,2:length(XX[1,])) so you have a new matrix without the first column and save this second one to a file? Regards, Eleni On Feb 13, 2008 3:06 PM, Roberto Olivares Hernandez <roh@bio.dtu.dk> wrote:> Hi, > > I used the write.table function to save data in txt file, and this is the > output: > > > V1 V2 V3 V4 > 1 YAL005C 21 14 11 > 2 YAL007C 2 1 4 > 3 YAL012W 8 16 3 > 4 YAL016W 24 23 23 > 5 YAL019W 3 3 2 > 6 YAL020C 2 4 2 > 7 YAL021C 7 5 5 > 8 YAL022C 3 1 2 > > > but I need to remove the dimnames (first column) > > I tried to use dimnames function to remove it and then save it, but still, > the output is the same > > These are the command lines, > > XX #matrix > dimnames(XX)<-NULL > write.table(XX,"XX.txt",quote=FALSE,sep="\t") > > > > Thanks in advance > Roberto > > > > [[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 > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
?write.table and look at the row.names arguement which is what they are called in this instance. write.table(XX, file="XX.txt",quote=FALSE,sep="\t", row.names=FALSE) --- Roberto Olivares Hernandez <roh at bio.dtu.dk> wrote:> Hi, > > I used the write.table function to save data in txt > file, and this is the output: > > > V1 V2 V3 V4 > 1 YAL005C 21 14 11 > 2 YAL007C 2 1 4 > 3 YAL012W 8 16 3 > 4 YAL016W 24 23 23 > 5 YAL019W 3 3 2 > 6 YAL020C 2 4 2 > 7 YAL021C 7 5 5 > 8 YAL022C 3 1 2 > > > but I need to remove the dimnames (first column) > > I tried to use dimnames function to remove it and > then save it, but still, the output is the same > > These are the command lines, > > XX #matrix > dimnames(XX)<-NULL > write.table(XX,"XX.txt",quote=FALSE,sep="\t") > > > > Thanks in advance > Roberto > > > > [[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. >[[elided Yahoo spam]]