Dear Jim, Eric, and Rui,
Great solutions! Thank you so much.
Best,
Milu
On Wed, Jul 15, 2020 at 9:20 AM Rui Barradas wrote:
> Hello,
>
> Yet another way, with package lubridate.
> When creating the "Date" objects, I set day = 1 to compare to TRUE below.
>
>
> library(lubridate)
>
> start <- a
Hello,
Yet another way, with package lubridate.
When creating the "Date" objects, I set day = 1 to compare to TRUE below.
library(lubridate)
start <- as.Date(ISOdate(1861, 1, 1))
end <- as.Date(ISOdate(2005, 12, 1))
start + months(4139 - 2400)
#[1] "2005-12-01"
end == start + months(4139 - 2
Hi Milu,
Jim gave a good solution. Another approach is to use standard packages
and objects.
In particular 'ts' (time series) objects from the stats package, and
'xts' (extensible time-series) objects from the xts package.
library(xts)
# construct dummy data
z <- rnorm(36)
# convert it into a mont
Hi Milu,
This is similar to the "birthday age" problem as it is much easier to
deal with the constant "12 months in a year" rather than the highly
variable number of days between two dates:
monthno2my<-function(x,startyear=1861,startmonth=2400) {
year<-startyear+(x-startmonth)%/%12
month<-1+(x-s
Dear all,
I have a panel dataset with a large number of groups (200K+) with a
sequence representing the month of the observations (2400 - 4139). The data
is from January 1861 to December 2005.
My goal is to extract the corresponding month and year for each observation.
I tried the following;
x$dt
5 matches
Mail list logo