alldat$yearmonth <- substr(alldat$mydate, 1, 7)
From: Anna Dunietz
Cc: "r-help@r-project.org"
Sent: Wednesday, September 14, 2011 3:21 AM
Subject: Re: [R] Deleting Rows based on Factor and Time Period
Mikkel - thank you so much! That's a gr
Alright - for the first stock in the month, I pretty much copied Mikkel's
code and got what I wanted. Thanks! Anna
install.packages("surveillance")
library(surveillance)
alldat$year <- isoWeekYear(alldat$mydate)$ISOYear
alldat$months<-months(alldat$mydate)
alldat <- alldat[order(alldat$year, alld
Mikkel - thank you so much! That's a great start! I could change my demands
a bit and pick out the first stock each month. The first stock each week is
helpful, but I would need a bigger gap between dates - hence, the first
stock a month would be much better. It seems to me, however, that
isoWeek
The following will get you the first stock in each week. Is that useful?
install.packages("surveillance")
library(surveillance)
alldat$year <- isoWeekYear(alldat$mydate)$ISOYear
alldat$week <- isoWeekYear(alldat$mydate)$ISOWeek
alldat <- alldat[order(alldat$year, alldat$week), ]
alldat[!duplicated
4 matches
Mail list logo