[R] "2013-06-28" coverts to 15884?
Jim Lemon
jim at bitwrit.com.au
Wed Mar 19 23:37:47 CET 2014
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
More information about the R-help
mailing list