Finding correlation for penalized regression in R

#1
I need to use the penalized models (lasso, ridge) for linear regression. In R, I use the "penalized" package. The output is a penfit object. If I want to find the in-sample and predictive correlation, how can I do that in R?

Converting the penfit oject to glm maybe a good idea,but I don't know how to do it.

(I am working on a dataset with hundreds of variables and observations. So, one-by-one method is impossible.)