Lauri Nikkinen wrote:
> Hi R-users,
>
> What is the best way to achieve a table which contains all days and months
> between years 2007-2020? I would like to calculate number of days in each
> month within those years (to data frame).
>
> Regards,
>
> Lauri
How about this?
X <- seq(ISOdate(2
Just one refinement if you want it nicely formatted:
> ts(diff(seq(as.Date("2007-01-01"), as.Date("2021-01-01"), by = "month")),
> start = c(2007, 01), freq = 12)
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2007 31 28 31 30 31 30 31 31 30 31 30 31
2008 31 29 31 30 31 30
> diff(seq(as.Date("2007-01-01"), as.Date("2021-01-01"), by = "month"))
Time differences in days
[1] 31 28 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31 31
[26] 28 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31 31 28
[51] 31 30 31 30 31 31 30 31 30 31 31 2
On Tue, Aug 07, 2007 at 03:53:28PM +0300, Lauri Nikkinen wrote:
> What is the best way to achieve a table which contains all days and months
> between years 2007-2020? I would like to calculate number of days in each
> month within those years (to data frame).
Here you go -- just replace length.ou
Hi R-users,
What is the best way to achieve a table which contains all days and months
between years 2007-2020? I would like to calculate number of days in each
month within those years (to data frame).
Regards,
Lauri
[[alternative HTML version deleted]]
___
+61 7 3286 7700
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of threshold
Sent: Monday, 14 May 2007 7:16 PM
To: r-help@stat.math.ethz.ch
Subject: [R] number of days
Hi, some of you knows h
Hi, some of you knows how to calculate in R the number of days between given
dates?
issue relevant in option pricing
thanks, robert
--
View this message in context:
http://www.nabble.com/number-of-days-tf3751163.html#a10600371
Sent from the R help mailing list archive at Nabble.com.
__
<[EMAIL PROTECTED]> writes:
> In some cases, incorrect results are produced by the code below intended to
> calculate the number of days between 2 dates. The year in question was a
> leap year.
> Note the results for 2004-04-04 and 2004-04-05 are the same! They should be
> 37 and 38 respectivel
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://www.med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
- Original Message -
From: <[EMAIL PROTECTED]>
To:
Sent: Tuesday, February 21, 2006 4:48 PM
Subject: [R] Number of Days Between Dates: Inc
The results are actually correct if you consider daylight savings time.
For example, try this and note that the difference is 23 hours, not 24 hours:
as.POSIXct("2004-04-05") - as.POSIXct("2004-04-04")
You can address this by either using Date or chron classes or adding
the tz = "GMT" argumen
In some cases, incorrect results are produced by the code below intended to
calculate the number of days between 2 dates. The year in question was a
leap year.
Note the results for 2004-04-04 and 2004-04-05 are the same! They should be
37 and 38 respectively.
> as.integer(as.POSIXct("2004-04-02"
ndays <- strptime(ex,format="%d%b%Y") - strptime(x,format="%d%b%Y")
If you need it in a calculation then as.numeric(ndays) might be
useful.
---
Date: Wed, 5 Nov 2003 23:33:33 -0600
From: umeno <[EMAIL PROTECTED]>
To: R-Help
Subject: [R] Number of Days
?strptime
?as.POSIXct
?difftime
On Wed, 5 Nov 2003, umeno wrote:
> Hi everyone,
>
> I have been trying to compute numbers of days between two dates as follows:
>
> > x <- c("1jan1960", "2jan1960", "31mar1960", "30jul1960")
> > z <- format(x, "%d%b%Y")
> > ex <- c("1jan1961", "15jan1960", "21mar
Hi everyone,
I have been trying to compute numbers of days between two dates as follows:
> x <- c("1jan1960", "2jan1960", "31mar1960", "30jul1960")
> z <- format(x, "%d%b%Y")
> ex <- c("1jan1961", "15jan1960", "21mar1975", "10jul1981")
> ez <- format(ex, "%d%b%Y")
> ez-z
Error in ez - z : non-num
14 matches
Mail list logo