You need to reference specific columns, and not just refer to a data frame. If a variable containing integer dates is in the df data frame and is called x , you can do this:
df <- transform(df, x = as.Date(as.character(x), "%Y%m%d"))
This converts integers to character strings, and then interprets the strings as dates.
If you have several columns containing dates in this format, you can convert them in one fell swoop, but you should do it a little differently:
df <- data.frame(lapply(df, function(x) as.Date(as.character(x), "%Y%m%d")))
Or even better, since docendo discimus is mentioned in the comment:
df[] <- lapply(df, function(x) as.Date(as.character(x), "%Y%m%d"))
source share