Thanks again David,
Heres what happened:
> Weeks<-summary(cut(data$Raised.Date, breaks="weeks"))
> Weeks
2007-12-17 2009-01-05 2008-06-09 2008-12-08 2009-02-09 2008-12-01
370 342 333 317 308 298
2008-05-12 2009-02-16 2007-01-22 2008-06-02 2007-01-29 2008-05-19
289 269 265 257 254 253
2007-06-11 2008-06-16 2008-05-26 2008-06-23 2008-11-03 2009-01-12
252 249 243 243 239 239
2008-07-21 2007-02-05 2008-02-18 2008-07-14 2008-01-14 2008-10-27
236 234 233 232 230 230
2007-12-10 2008-03-17 2008-08-04 2008-11-24 2006-12-18 2007-11-26
229 229 229 228 227 226
2007-11-12 2006-11-06 2007-06-25 2006-04-03 2008-01-07 2006-04-10
225 222 218 217 216 215
2008-07-28 2006-05-08 2006-06-05 2009-02-23 2007-10-22 2007-02-19
215 214 214 214 212 211
2008-06-30 2009-02-02 2007-06-04 2007-12-03 2006-11-13 2007-09-03
209 209 208 207 205 205
2006-08-28 2008-07-07 2007-05-14 2006-08-14 2007-04-16 2006-07-31
204 204 203 202 202 201
2008-12-15 2006-09-11 2006-06-12 2008-01-21 2008-04-07 2009-01-26
200 199 197 197 197 197
2008-02-11 2007-04-02 2007-04-09 2008-04-21 2006-08-07 2007-11-19
195 194 194 194 193 193
2008-04-14 2008-05-05 2006-07-24 2007-05-21 2006-06-19 2006-10-09
193 193 192 191 190 190
2007-02-12 2007-03-26 2007-07-09 2007-11-05 2008-02-25 2008-09-08
190 189 189 189 189 189
2009-08-10 2008-09-15 2009-06-08 2006-05-15 2007-07-02 2009-06-01
189 188 188 187 187 186
2008-11-17 2006-06-26 2009-06-29 2007-08-06 2007-08-13 2009-01-19
183 182 182 181 180 180
2009-07-13 2006-04-17 2007-03-05 2007-12-24 2006-10-16 2008-08-11
180 179 179 179 178 178
2006-05-29 2006-11-27 2007-10-29 (Other)
177 177 177 13091
As you can see its come out a little disorderly though.
I have to plot the number of events under each date in a time series.
How do i order the dates and their counts?
David Winsemius wrote:>
>
> 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 <frenchcr at
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 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.
>
>
--
View this message in context:
http://n4.nabble.com/column-of-dates-into-time-series-tp930699p930744.html
Sent from the R help mailing list archive at Nabble.com.