dates by week multiple years
Hi Keith, Perhaps you do not want to go with calendar weeks: 365/7 = 52.14 as there are not an even number of weeks in a year, you may want to plot by week from your initial observation. As you are using as.Date, you could simply calculate weeks as: data$Week<-1+as.numeric(data$Date - data$Date[1])%/%7 Jim
On Wed, Feb 6, 2019 at 4:52 PM Marlin Keith Cox <marlinkcox at gmail.com> wrote:
Hello all, I did not attach data as this is probably simple answer that I
cannot find.
I am collecting daily data and would like to plot the data by week but now
that we are into the new year, my plots started over with 01 after the last
week of the year. How can I continuously keep adding weeks such as 53, 54,
55, 56, etc. instead of starting over?
Below has worked for me until we moved into 2019.
data$Date <- as.Date(data$TIMESTAMP,format="%m/%d/%y %H:%M")
data$Week1 <- strftime(data$Date,format = "%V")
data$Week<-as.factor(data$Week1)
Keith
M. Keith Cox, Ph.D.
Principal
MKConsulting
17415 Christine Ave.
Juneau, AK 99801
U.S. 907.957.4606
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.