Not sure I follow. I would like the date formatting information preserved as is implemented when using as.character: MaxUpdated_row<-NULL MaxUpdated_val<- "2013-06-28"
c(MaxUpdated_row, as.character(MaxUpdated_val)) [1] "2013-06-28" However, when I try to used as.Date(...) I loose the date formatting information: c(MaxUpdated_row, as.Date(MaxUpdated_val, "%Y-%m-%d")) [1] 15884 I thought as.Date was an instruction describing how the data element should be represented? Maybe as.character is the only way to preserve the "date" formatting information in character string format in a vector and then just convert it back later on... Thanks again. On Wednesday, March 19, 2014 5:42 PM, Jim Lemon <j...@bitwrit.com.au> wrote: On 03/20/2014 08:46 AM, Jason Rupert wrote: > MaxUpdated_row<-NULL > MaxUpdated_val<- "2013-06-28" > > > rbind(MaxUpdated_row, as.Date(MaxUpdated_val, "%Y-%m-%d")) > [,1] > [1,] 15884 > > c(MaxUpdated_row, as.Date(MaxUpdated_val, "%Y-%m-%d"")) >> [1] 15884 > c(MaxUpdated_row, MaxUpdated_val) >> [1] 15884 > > Evidently, I'm again missing something simple, as I would prefer to be able > to see the actual date to be shown. > > I found a work around, but I don't like it, as I have to convert back to date > later: > c(MaxUpdated_row, as.character(MaxUpdated_val)) > Hi Jason, You aren't converting the date to something else, just displaying it as a character vector by using the format function. Whenever you form a vector, R tries to convert everything in it to the same data type. If you _assign_ that vector to something else: mymax<-c(MaxUpdated_row, as.Date(MaxUpdated_val, "%Y-%m-%d"")) you will have the date type in the MaxUpdated_val and the character type in mymax. Jim [[alternative HTML version deleted]]
______________________________________________ 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.