[R] macro function
Rui Barradas
rui1174 at sapo.pt
Tue Feb 28 19:26:31 CET 2012
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.
More information about the R-help
mailing list