Hello,
Is it just a columns names issue?
Try (DF is your data, 'A' or other data.frame)
# colNames <- colnames(DF)
colNames <- c("name", "publish day", "2011-01-01", "2011-01-02",
"2011-01-03", "2011-01-04", "2011-01-05")
x <- as.Date(colNames[-(1:2)])
x
[1] "2011-01-01" "2011-01-02" "2011-01-03" "2011-01-04" "2011-01-05"
y <- difftime(x[-1], x[1], units="days")
y <- as.integer(y)
y
[1] 1 2 3 4
colNames[3] <- "D-Day"
colNames[-(1:3)] <- paste("D", y, sep="+")
colNames
[1] "name" "publish day" "D-Day" "D+1" "D+2"
[6] "D+3" "D+4"
# colnames(DF) <- colNames
Hope this helps,
Rui Barradas
--
View this message in context:
http://r.789695.n4.nabble.com/macro-function-tp4427385p4429055.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
[email protected] 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.