On Nov 29, 2009, at 7:52 AM, Linlin Yan wrote:
There is no year() function. Maybe you can try format() instead.
On Sun, Nov 29, 2009 at 8:44 PM, DispersionMap <frenc...@btinternet.com
> wrote:
i have a column of dates in this format:
data[,"Raised.Date"] <- as.Date(data[,"Raised.Date"], "%d/%m/%Y");
data[1:10,"Raised.Date"]
[1] "2006-07-07" "2006-07-07" "2006-04-03" "2006-04-03" "2006-04-03"
"2006-04-03" "2006-04-03" "2006-04-03" "2006-04-03" "2006-04-03"
I can turn them into months like this...
Month<-months(data[,"Raised.Date"])
Month[1:10]
[1] "July" "July" "April" "April" "April" "April" "April" "April"
"April"
"April"
But i also want to turn them into years (and also weeks later on),
so tried
this...
library(chron)
?cut.dates
The argument breaks has several options including one of c("days",
"weeks", "months", "year")
> dts <- Sys.Date() - 1:20
> cut(dts, breaks="weeks")
[1] 2009-11-23 2009-11-23 2009-11-23 2009-11-23 2009-11-23
2009-11-23 2009-11-16 2009-11-16 2009-11-16 2009-11-16
[11] 2009-11-16 2009-11-16 2009-11-16 2009-11-09 2009-11-09 2009-11-09
2009-11-09 2009-11-09 2009-11-09 2009-11-09
Levels: 2009-11-09 2009-11-16 2009-11-23
I was a bit puzzled when I tried cut.dates as the function which
throws a function not found error.
Year<-year(data[,"Raised.Date"])
Error: could not find function "year"
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
______________________________________________
R-help@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.