From ehlers at ucalgary.ca  Sat Oct 24 23:54:32 2009
From: ehlers at ucalgary.ca (Peter Ehlers)
Date: Sat, 24 Oct 2009 15:54:32 -0600
Subject: [Rd] names drop for columns from data.frame (PR#14002)
In-Reply-To: <20091012183016.2AB77282EF3D@mail.pubhealth.ku.dk>
References: <20091012183016.2AB77282EF3D@mail.pubhealth.ku.dk>
Message-ID: <4AE37798.8010308@ucalgary.ca>

Have you tried names(a[,1,drop=FALSE])?
Then have a look at help("[").

-Peter

veraf at clemson.edu wrote:
> Full_Name: Francisco Vera
> Version: 2.9.2
> OS: Windows
> Submission from: (NULL) (74.248.242.164)
> 
> 
> Run the following commands:
> 
> a<-data.frame(x=1:2,y=3:4,row.names=c("i","j"))
> names(a$x)
> names(a[,1])
> 
> For names(a$x) I get NULL instead of c("i","j"). Same thing happens with
> names(a[,1]). It works fine for rows, i.e., names(a[1,]) gives what is supposed
> to.
> 
> It also works fine for matrices. If you issue the commands
> b<-matrix(1:4,ncol=2,dimnames=list(c("x","y"),c("i","j")))
> names(b[,1])
> names(b[1,])
> 
> Thanks
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 

-- 
Peter Ehlers
University of Calgary



[Rd] names drop for columns from data.frame (PR#14002)
Peter Ehlers