Check for installed packages in R -


based on answer question: elegant way check missing packages , install them?

i'm using following code make sure packages installed when upgrade r, or set other users:

list.of.packages <- c("rodbc", "reshape2", "plyr") new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"package"])] if(length(new.packages)) install.packages(new.packages) 

i've placed in .first function in .rprofile, when start r gives following error , continues starting up:

error in match(x, table, nomatch = 0l) :    not find function "installed.packages" 

if run code after prompt works fine. ideas why?

thanks!

it appears reading ?startup that:

next, if function .first found on search path, executed .first(). finally, function .first.sys() in base package run. calls require attach default packages specified options("defaultpackages").

now, installed.packages in utils package, typically 1 of default packages. it's not available @ time .first called.

perhaps try replacing installed.packages utils::installed.packages?

as josh notes below eyes skimmed on piece addresses issue directly, namely:

note when site , user profile files sourced base package loaded, objects in other packages need referred e.g. utils::dump.frames or after explicitly loading package concerned.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -