Um comentario a parte, que pode ser ignorado:

x <- c("lattice","nlme","contrast","plyr","reshape","latticeExtra","multcomp","aod"
)
x <- rep(x, 1e6)
t0 <- system.time(r0 <- gsub("^.*(.{4})$","\\1", x))
t1 <- system.time({n <- nchar(x); r1 <- substr(x, n-3, n)})
identical(r0, r1)
t0[3]/t1[3]