I want to remove the column names from a data frame. I do it the long way, can any body show me a better way ? df= data.frame(chrN= c(“chr1”, “chr2”, “chr3”), start= c(1, 2, 3), end= c(4, 5, 6), score= c(7, 8, 9)) df #I write a txt file without row or column names write.table(df,"df1.txt",sep='\t',quote=FALSE,row.names=F,col.names=F) #then I read it with the header = F to obtain the format I want df1=read.table("df1.txt", header = F) df1 ____________________________________________________________________________________ Looking for last minute shopping deals? /category.php?category=shopping [[alternative HTML version deleted]]
apparently you want to check the "Introduction to R" document.... I found it very useful when I started working with R: http://cran.r-project.org/doc/manuals/R-intro.pdf try: names(df) <- NULL b ps: "df" is the name of the function to get the density for an F distribution... On Feb 18, 2008, at 2:42 PM, joseph wrote:> > > I want to remove the column names from a data frame. I do > it the long way, can any body show me a better way ? > > > df= data.frame(chrN= c(?chr1?, ?chr2?, ?chr3?), start= c(1, > 2, 3), end= c(4, 5, 6), score= c(7, 8, 9)) > > > df > > > #I write a txt file without row or column names > > > write.table(df,"df1.txt",sep='\t',quote=FALSE,row.names=F,col.names=F) > > > #then I read it with the header = F to obtain the format > I want > > > df1=read.table("df1.txt", header = F) > > > df1 > > > > ____________________________________________________________________________________ > Looking for last minute shopping deals? > > /category.php?category=shopping > [[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.
Try this: names(df) <- NA or names(df) <- make.names(seq(ncol(df))) On 18/02/2008, joseph <jdsandjd at yahoo.com> wrote:> > > I want to remove the column names from a data frame. I do > it the long way, can any body show me a better way ? > > > df= data.frame(chrN= c("chr1", "chr2", "chr3"), start= c(1, > 2, 3), end= c(4, 5, 6), score= c(7, 8, 9)) > > > df > > > #I write a txt file without row or column names > > > write.table(df,"df1.txt",sep='\t',quote=FALSE,row.names=F,col.names=F) > > > #then I read it with the header = F to obtain the format > I want > > > df1=read.table("df1.txt", header = F) > > > df1 > > > ____________________________________________________________________________________ > Looking for last minute shopping deals? > > /category.php?category=shopping > [[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
Hi Benilton I actually tried "names(df) <- NULL" before I asked for help. Please see below how it looks like> names(df) <- NULL > dfstructure(c("chr1", "chr2", "chr3"), class = "AsIs") structure(c("1", "2", "3"), class = "AsIs") 1 chr1 1 2 chr2 2 3 chr3 3 structure(c("4", "5", "6"), class = "AsIs") structure(c("7", "8", "9"), class = "AsIs") 1 4 7 2 5 8 3 6 9>----- Original Message ---- From: Benilton Carvalho <bcarvalh@jhsph.edu> To: joseph <jdsandjd@yahoo.com> Cc: r-help@r-project.org Sent: Monday, February 18, 2008 11:47:50 AM Subject: Re: [R] remove column names from a data frame apparently you want to check the "Introduction to R" document.... I found it very useful when I started working with R: http://cran.r-project.org/doc/manuals/R-intro.pdf try: names(df) <- NULL b ps: "df" is the name of the function to get the density for an F distribution... On Feb 18, 2008, at 2:42 PM, joseph wrote:> > >I want to remove the column names from a data frame. I do>it the long way, can any body show me a better way ?> > >df= data.frame(chrN= c(“chr1”, “chr2”, “chr3”), start= c(1,>2, 3), end= c(4, 5, 6), score= c(7, 8, 9))> > >df> > >#I write a txt file without row or column names> > >write.table(df,"df1.txt",sep='\t',quote=FALSE,row.names=F,col.names=F)> > >#then I read it with the header = F to obtain the format>I want> > >df1=read.table("df1.txt", header = F)> > >df1> > >>____________________________________________________________________________________>Looking for last minute shopping deals?> >/category.php?category=shopping>[[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. ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. [[alternative HTML version deleted]]