1

I have this data.frame in sparkR

df <- data.frame(user_id=c(1,1,2,2),
             time=c("2015-7-10","2015-8-04","2015-8-8","2015-7-10"))

I make this to a DataFrame

dft <- createDataFrame(sqlContext, df)

I want to convert the date (which is now a string) to a 'date'-type. I use the 'cast'-function

dft$time <- cast(dft$time, 'date')

But now when I use head(dft) I can see that 'time' only contain NA.

Maybe there should be added something to the 'cast'-function or maybe there should be loaded a package before using it? Alternative one could use 'as.Date' on the data.frame but it takes time for large data.

I have the exact same problem with 'integer'. If I type

cast(dft$time, 'int')

time will then produce NA.

Ole Petersen
  • 670
  • 9
  • 21

0 Answers0