Hello, > > I would like to know for each variable what is date format? > Is it “ %y-%d-%m “ or “ %m-%d-%y “ > It's 4 digits, with uppercase 'Y'
Try Data <- data.frame(var1=c("12-15-2011", "12-15-2011", "12-17-2001"), var2=c("2001-15-12", "2001-15-01", "2001-15-01"), stringsAsFactors=FALSE ) str(Data) yr <- sapply(sapply(Data, strsplit, "-"), function(x) which(nchar(x) == 4)) yr [1] 3 3 3 1 1 1 To have the result with the same dimensions as your original data.frame (but with a different class, I don't believe it matters) matrix(yr, ncol=ncol(Data)) Hope this helps, Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/Date-formate-y-d-m-or-m-d-y-tp4548736p4549342.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@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.