Hi,
Sorry, a correction:
fun1 <- function(months, Given_date){
g1 <- format(Given_date, "%b")
indx1 <- match(months,month.abb)
indx2 <- match(g1, month.abb)
yr <- as.numeric(format(Given_date,"%Y"))
if(any(indx1 < indx2)){
ifelse(indx1 < indx2, paste(months, yr+1,sep="-"), paste(months, yr,s
Hi,
May be this helps:
fun1 <- function(months, Given_date){
g1 <- format(Given_date, "%b")
indx1 <- match(months,month.abb)
indx2 <- match(g1, month.abb)
yr <- as.numeric(format(Given_date,"%Y"))
if(any(indx1 < indx2)){
ifelse(indx1 < indx2, paste(months, yr,sep="-"), paste(months, yr+1,sep=
On 01/01/2014 08:53 AM, Christofer Bogaso wrote:
Hi again,
Happy new year 2014 to every R gurus and users.
I am struggling with some calculation with dates... Let say I have
following vector of months:
Months<- c("Jan", "Dec", "Mar")
Now I need to assign year with them. This assignment will b
Use, format() to extract a character string representation of the
year, then paste() it together with Months. Like this:
paste(Months, format(Given_Date, format = "%Y"), sep = "-")
See ?strftime for details.
Best,
Ista
On Tue, Dec 31, 2013 at 4:53 PM, Christofer Bogaso
wrote:
> Hi again,
>
> H
Hi again,
Happy new year 2014 to every R gurus and users.
I am struggling with some calculation with dates... Let say I have
following vector of months:
Months <- c("Jan", "Dec", "Mar")
Now I need to assign year with them. This assignment will be based on some
given date. Let say my given date
\\2",format(asd,"%d/%m/%Y"))
#[1] "3/1/2012"
A.K.
- Original Message -
From: Ron Michael mailto:ron_michae...@yahoo.com>>
To: jim holtman mailto:jholt...@gmail.com>>
Cc: "r-help@r-project.org<mailto:r-help@r-project.org>"
mailto:r-help@
))
#[1] "3/1/2012" "25/12/2012" "12/1/2012" "1/10/2012"
A.K.
- Original Message -
From: Jim Holtman
To: arun
Cc: Ron Michael ; R help
Sent: Wednesday, December 26, 2012 9:38 PM
Subject: Re: [R] Working with date
what happens with 25/12/2012?
> From: Ron Michael
> To: jim holtman
> Cc: "r-help@r-project.org"
> Sent: Wednesday, December 26, 2012 2:25 PM
> Subject: Re: [R] Working with date
>
> Thanks Jim for your reply.
>
> However I want "3/1/2012" not "03/01/2012"
>
&g
Hi,
gsub("^\\d(.*/)\\d(.*/.*)","\\1\\2",format(asd,"%d/%m/%Y"))
#[1] "3/1/2012"
A.K.
- Original Message -
From: Ron Michael
To: jim holtman
Cc: "r-help@r-project.org"
Sent: Wednesday, December 26, 2012 2:25 PM
Subject: Re: [R] Workin
HI,
format(asd,"%d/%m/%Y")
#[1] "03/01/2012"
A.K.
- Original Message -
From: Ron Michael
To: "r-help@r-project.org"
Cc:
Sent: Wednesday, December 26, 2012 1:31 PM
Subject: [R] Working with date
Hi,
Let say I have a date variable:
> asd <- as.D
Thanks Jim for your reply.
However I want "3/1/2012" not "03/01/2012"
Any idea ?
Thanks
- Original Message -
From: jim holtman
To: Ron Michael
Cc: "r-help@r-project.org"
Sent: Thursday, 27 December 2012 1:01 AM
Subject: Re: [R] Working with date
r I want "3/1/2012" not "03/01/2012"
>
> Any idea ?
>
> Thanks
>
>
> - Original Message -
> From: jim holtman
> To: Ron Michael
> Cc: "r-help@r-project.org"
> Sent: Thursday, 27 December 2012 1:01 AM
> Subject: Re: [R] Working wit
If you don't have to be finicky about leading zeros, the easy way is:
as.character(asd,format="%d/%m/%Y")
?strptime
If you are going to be finicky, then
asdlt <- as.POSIXlt(asd)
with(asdlt,sprintf("%d/%d/%d",mday,mon+1,year+1900))
?as.POSIXlt
?sprintf
--
forgot you were asking for mdy format
> # interchange day and month
> format(asd, format = '%d/%m/%Y')
[1] "03/01/2012"
>
On Wed, Dec 26, 2012 at 2:14 PM, jim holtman wrote:
> try this:
>
>> asd <- as.Date("2012-01-03")
>> asd
> [1] "2012-01-03"
>> format(asd, format = '%m/%d/%Y')
> [1] "01/03/
try this:
> asd <- as.Date("2012-01-03")
> asd
[1] "2012-01-03"
> format(asd, format = '%m/%d/%Y')
[1] "01/03/2012"
>
On Wed, Dec 26, 2012 at 1:31 PM, Ron Michael wrote:
> asd <- as.Date("2012-01-03")
--
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?
Tell m
Hi,
Let say I have a date variable:
> asd <- as.Date("2012-01-03")
> asd
[1] "2012-01-03"
Now, I want to express this date like 3/1/2012.
can somebody help me how to achieve that?
Thanks,
__
R-help@r-project.org mailing list
https://stat.ethz.ch/
16 matches
Mail list logo