ate's as follows
> res <- mondate(Date) + Vec
> as.Date(mondate.ymd(year(res), month(res), 1))
[1] "2013-03-01" "2014-04-01" "2014-01-01" "2013-07-01"
Hope that helps,
Dan
==
Message: 16
Date: Sat, 9 Mar 2013 08:37:23 -
On Mar 9, 2013, at 4:24 AM, Rui Barradas wrote:
> Hello,
>
> I don't believe there's such a function, but you can write one.
I beg to disagree. The seq.Date function lets one create sequences by month.
The only added twist in this case is to subract to the beginning of the current
month:
> s
c:
Sent: Saturday, March 9, 2013 6:41 AM
Subject: [R] Calculation with date
Hello again,
Let say I have an non-negative integer vector (which may be random):
Vec <- c(0, 13, 10, 4)
And I have a date:
> Date <- as.Date(Sys.time())
> Date
[1] "2013-03-09"
Using these 2
Hello,
I don't believe there's such a function, but you can write one.
Date <- as.Date(Sys.time())
New_Vec <- c("2013-03-01", "2014-04-01", "2014-01-01", "2013-07-01")
New_Vec <- as.Date(New_Vec)
Vec <- c(0, 13, 10, 4)
plusmonths <- function(x, y){
s <- as.integer(format(x, "%m")) + y
On Sat, Mar 9, 2013 at 11:41 AM, Christofer Bogaso <
bogaso.christo...@gmail.com> wrote:
> Hello again,
>
> Let say I have an non-negative integer vector (which may be random):
>
> Vec <- c(0, 13, 10, 4)
>
> And I have a date:
>
> > Date <- as.Date(Sys.time())
> > Date
> [1] "2013-03-09"
>
>
>
> U
5 matches
Mail list logo