[R] Dynamic data.frame headers

Hans Gardfjell Hans.Gardfjell at srh.slu.se
Wed Jan 13 10:28:08 CET 2010


Hi Mattias,

Try this,

percentiles <- c(0.05, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 0.95, 1.00)
test <-  data.frame(matrix(NA,0,12))
names(test) <- paste("p",percentiles*100,sep="")
 
test
 [1] p5   p10  p20  p30  p40  p50  p60  p70  p80  p90  p95  p100

Cheers, Hans

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Mattias Nyström
Sent: Wednesday, January 13, 2010 10:11
To: r-help at r-project.org
Subject: [R] Dynamic data.frame headers

I would like to create a data.frame with dynamic created headers. I will later fill it with percentiles. My percentiles vector is:
percentiles = c(0.05, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 0.95, 1.00)

>From this vector I would like to have headers like:
p5, p10, p20, ..., p95, p100

Is it possible to create headers in such way, something like "p"+100*c?

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