The reason to get back 1 for certain years is that if there are only 52 weeks in a year, then "dec-28" may counted to the first week of the next year. It is easy to get rid of that problem:
weeks <- function(year) {
y<- lubridate::isoweek(paste0(year, "-12-31"))
y[y==1] <- 52
return(y
}