[R] date format

arun smartpink111 at yahoo.com
Thu Nov 28 16:24:09 CET 2013


#Or
 paste(dat[,3],dat[,2],dat[,1],sep=".")
#[1] "4.1.2011" "5.2.2012" "6.3.2013"
#
 as.character(interaction(dat[,3:1]))


 paste(sprintf("%02d",dat[,3]),sprintf("%02d",dat[,2]),dat[,1],sep=".")
#[1] "04.01.2011" "05.02.2012" "06.03.2013"


A.K.




On Thursday, November 28, 2013 10:18 AM, Rui Barradas <ruipbarradas at sapo.pt> wrote:
Hello,

Maybe something like the following.

dat <- data.frame(yyyy = 2011:2013, mm = 1:3, dd = 4:6)

apply(dat, 1, function(x) paste(rev(x), collapse = "."))


Hope this helps,

Rui Barradas

Em 28-11-2013 13:54, eliza botto escreveu:
> Dear Users of R,
> I have a data frame with three column, the first column contains years, the second one months and third one, the days (cbind(yyyy mm dd)). I want to combine them so that i have one column with the date format as (dd.mm.yyyy).
> Is there a way of doing that.
> Thanks in advance,
> Eliza                         
>     [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

>

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list