[R] dimnames

Joshua Wiley jwiley.psych at gmail.com
Wed Aug 18 18:20:51 CEST 2010


On Wed, Aug 18, 2010 at 8:58 AM, Jimmy Söderly <jimmy.soderly at gmail.com> 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)
> attr(try,"dimnames")<-list(NULL,"true value")
>
> Is it OK ?

Sure.  You can also do:

dimnames(try) <- list(NULL,"true value")

or if you are creating the matrix, directly with:

try <- matrix(1:4, nrow = 4, ncol = 1, dimnames = list(NULL, "true value")

>
> 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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list