I have a series of dates within a data.frame of the form x <- data.frame(01/01/2009). I would like to change the series to be of the form 01012009. I have tried the gsub("//","" x) but it does not appear to work.
I would just like to remove the back forward slashes. Any help would be greatly appreciated.
You don't need to escape a forward slash (which is not what you are doing anyway), so this will work, e.g:
dat <- data.frame(dates=c("01/01/2009","02/01/2009"))
dat
# dates
#1 01/01/2009
#2 02/01/2009
dat$dates <- gsub("/","",dat$dates)
dat
# dates
#1 01012009
#2 02012009
Thank you! I was wanting to apply this to an entire vector stored as a data.frame rather an individual input. Is there a way to modify this to do that?
@user2832896 -
gsub
will work just the same on a single value as it will on a vector in a data.frame. See my edits.