yanci
yanci

Reputation: 173

R Date Format in Spotfire

I have a column in a dataframe: 16542.00. I am trying to convert it to 04/17/2015.

I have tried:

df<-mutate(.data = df, DateColumn= as.Date(DateColumn, "%m/%d/%Y"))  

I get this error:

Changing datatype of an existing property is not allowed. Old datatype: Date, new datatype: Real

Upvotes: 0

Views: 247

Answers (1)

jyjek
jyjek

Reputation: 2707

Try this one:

df<-data.frame(DateColumn=as.numeric(16542:16545))
 df%>%
   mutate(DateColumn=format(as.Date(DateColumn, origin = "1970-01-01"), format="%m/%d/%Y"))
  DateColumn
1 04/17/2015
2 04/18/2015
3 04/19/2015
4 04/20/2015

Upvotes: 1

Related Questions