You were close. format=
needs to be added to the as.Date
call:
mydate <- factor("1/15/2006 0:00:00")
as.Date(mydate, format = "%m/%d/%Y")
## [1] "2006-01-15"
More Related Contents:
- Collapse / concatenate / aggregate a column to a single comma separated string within each group
- Select / assign to data.table when variable names are stored in a character vector
- Replace all 0 values to NA
- How to convert a list consisting of vector of different lengths to a usable data frame in R?
- How to open CSV file in R when R says “no such file or directory”?
- Splitting a continuous variable into equal sized groups
- Programming with dplyr using string as input
- How to upgrade R in ubuntu? [closed]
- Convert data.frame column to a vector?
- Add new row to dataframe, at specific row-index, not appended?
- Building R package and error “ld: cannot find -lgfortran”
- What is the difference between assign() and
- How can I load an object into a variable name that I specify from an R data file?
- Merge by Range in R – Applying Loops
- ‘Embedded nul in string’ error when importing csv with fread
- Delete columns/rows with more than x% missing
- Reading two-line headers in R
- Show names of everything in a package
- Advantages of reactive vs. observe vs. observeEvent
- geom_text how to position the text on bar as I want?
- Convert NA into a factor level
- R fuzzy string match to return specific column based on matched string
- Scraping a dynamic ecommerce page with infinite scroll
- R strsplit with multiple unordered split arguments?
- Reorder rows using custom order
- Calculating percentile of dataset column
- modifying ggplot objects after creation
- Equivalent to rowMeans() for min()
- Adding a counter column for a set of similar rows in R [duplicate]
- R data table: update join