# Load the utils package
library(utils)
# Get information about all installed packages
pkg_info <- packageStatus()
# Filter the information to show only packages that need to be updated
outdated_packages <- pkg_info[,"needsUpdate"]
# Display the number of outdated packages
cat("Number of outdated packages:", length(outdated_packages))
pkg_info <- packageStatus()
pkg_info
Number of installed packages:
ok upgrade unavailable
/usr/local/lib/R/site-library 467 27 161 /usr/lib/R/site-library 0 0 0 /usr/lib/R/library 16 13 0
Number of available packages (each package counted only once):
installed not installed
/usr/local/lib/R/site-library /usr/lib/R/library/
sudo chown -R jhuang:jhuang /usr/lib/R/library/
sudo chown -R jhuang:jhuang /usr/share/R/doc/html
#update.packages(ask = FALSE)
update.packages(repos='http://cran.rstudio.com/', ask=FALSE, checkBuilt=TRUE)