[R] add names to data frame

Henrique Dallazuanna wwwhsd at gmail.com
Thu Apr 14 14:11:22 CEST 2011


The matrix is generated by print.dist function ( getS3method("print", "dist") ).

You could try this:

d <- as.matrix(dist(matrix(rnorm(27), 9), diag = TRUE, upper = TRUE))
colnames(d) <- letters[1:9]



On Wed, Apr 13, 2011 at 1:29 PM, Radhouane Aniba <aradwen at gmail.com> wrote:
> Hi,
>
> I have a vector V of values I used to create a distance matrix using dist()
> function with diag=TRUE and upper=TRUE parameters.
>
> I would like to assign names in another vector on top of each column instead
> of 1 2 3 4 ...
>
> How can we do that ? is the distance matrix generated a data frame or a
> matrix ?
>
> Regards
> --
> *Radhouane *
>
>        [[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



More information about the R-help mailing list