[R] dimnames

David Winsemius dwinsemius at comcast.net
Wed Aug 18 18:38:02 CEST 2010


On Aug 18, 2010, at 11:58 AM, Jimmy Söderly wrote:

> Hi everybody,
>
> I wanted to name a column vector (a variable).
>
> This is what I did :
>
> try<-matrix(1:4,nrow=4,ncol=1)

("try" is a bad name for an object because it is a useful function  
name.)

> attr(try,"dimnames")<-list(NULL,"true value")
>
> Is it OK ?

Single column matrices get automatically converted to vectors unless  
you use drop=FALSE. Furthermore naming vectors with strings that  
contain spaces is possible but unwise , because you will forever be  
needing to stick quotes around what would otherwise not need the quotes


>
> Thanks for your help,
> Jimmy
>
> 	[[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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list