从data.frame中的日期中删除斜杠

use*_*896 1 string r date dataframe

我在x < - data.frame(01/01/2009)格式的data.frame中有一系列日期.我想将系列更改为01012009格式.我已经尝试了gsub("//",""x)但它似乎不起作用.

我只想删除后退斜线.任何帮助将不胜感激.

mne*_*nel 5

另一种方法是在R中使用as.Date/ strftime和其他日期时间操作函数

# create a Date column (can do things with dates as dates now)
dat$Date <- as.Date(as.character(dat$dates),format = '%d/%m/%Y')
# create character column with format of your desire
dat$newDate <- strftime(dat$Date, '%d%m%Y')
Run Code Online (Sandbox Code Playgroud)