The easiest way is to use lubridate:
library(lubridate)
prods.all$Date2 <- mdy(prods.all$Date2)
This function automatically returns objects of class POSIXct
and will work with either factors or characters.
More Related Contents:
- Transform year/week to date object
- How to convert Excel date format to proper date in R
- Find the day of a week
- What are the “standard unambiguous date” formats for string-to-date conversion in R?
- Converting year and month (“yyyy-mm” format) to a date?
- How to flatten / merge overlapping time periods
- Changing date format in R
- as.Date with dates in format m/d/y in R
- Generate a sequence of the last day of the month over two years
- Convert integer to class Date
- How to subtract/add days from/to a date?
- as.Date returning NA while converting from ‘ddmmmyyyy’
- Is there a more elegant way to convert two-digit years to four-digit years with lubridate?
- R: How to handle times without dates?
- Add (subtract) months without exceeding the last day of the new month
- How to subtract years?
- Convert two-digit years to four-digit years with correct century
- Create a Vector of All Days Between Two Dates
- Grouping functions (tapply, by, aggregate) and the *apply family
- Reshaping multiple sets of measurement columns (wide format) into single columns (long format)
- Select the row with the maximum value in each group
- Rename multiple columns by names
- Number of months between two dates
- Error in : target of assignment expands to non-language object
- How to search for “R” materials? [closed]
- How to sort a data frame by date
- Should I use a data.frame or a matrix?
- Variable name restrictions in R
- Convert decimal day to HH:MM
- Round a POSIX date (POSIXct) with base R functionality