I am datamining the data from a mobile application, I have a simple problem that is reccurring that is giving me trouble,
Database UserId Platform Date 1 Android 01-01-2016 2 iOS 02/01/2016 3 Android 03-01-2016 4 Android 04-01-2016
As you can see the format of the date is different depending whether the user is on using iOS or Android,
My question, is there a way to transform the Android format date to d/m/y instead of d-m-y ? Directly in the Date column or by creating a new one,
Thanks a lot
If you want to convert both types of strings directly to a date you could use the dmy() function in the lubridate package.
library(lubridate)
date.vector <- c("01-01-2016", "02/01/2016", "03-01-2016", "04-01-2016")
dmy(date.vector)
# > dmy(date.vector)
# [1] "2016-01-01" "2016-01-02" "2016-01-03" "2016-01-04"
you can use gsub to replace dashes by slashes:
gsub("-", "/", mydata$Date)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With