Using lubridate
library(lubridate)
parse_date_time(as.character(20130107), "%Y%m%d")
If you wanted to just extract certain elements of the date, this is easy with strftime. For example, just the year:
strftime(parse_date_time(as.character(20130107), "%Y%m%d"), "%Y")