[R] Odp: Apply vector of labels to columns of data frame
Petr PIKAL
petr.pikal at precheza.cz
Fri Oct 5 11:45:05 CEST 2007
Hi
r-help-bounces at r-project.org napsal dne 05.10.2007 11:19:16:
> Dear list members
> I would like to apply a vector of labels
> v=c("lab1","lab2","lab3")
> to a dataframe
> df=data.frame(1:3,1:3,1:3)
> using some kind of loop or apply function.
> Any ideas?
Few
1. Read R-intro manual how to manipulate objects in R
2
> df
X1.3 X1.3.1 X1.3.2
1 1 1 1
2 2 2 2
3 3 3 3
> names(df) <- v
> df
lab1 lab2 lab3
1 1 1 1
2 2 2 2
3 3 3 3
> row.names(df) <- v
> df
lab1 lab2 lab3
lab1 1 1 1
lab2 2 2 2
lab3 3 3 3
Regards
Petr
> Thanks
>
>
> Steve Powell
>
>
>
> Checked by AVG Free Edition.
>
> 17:03
>
>
> [[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.
More information about the R-help
mailing list