install.packages()returns a warning if the package cannot be installed (for example, if it is not available); eg:
install.packages()
install.packages("notapackage")
( EDIT : I would like to make a mistake, regardless of the reason the package could not be installed, and not just in this example with the missing package).
I run the command install.packagesin a script and I would like it to throw the correct error and complete the execution. I do not see an obvious option inside install.packagesto handle this behavior. Any suggestions?
install.packages
R WithCallingHandlers() . , , R , - ( ).
WithCallingHandlers()
withCallingHandlers(install.packages("notapackage"), warning = function(w) stop(w))
, , , ; . , require , , .
require
:
R> AP <- available.packages() R> "notapackage" %in% AP[,1] # expected to yield FALSE [1] FALSE R> "digest" %in% AP[,1] # whereas this should be TRUE [1] TRUE R>
Source: https://habr.com/ru/post/1694531/More articles:How to disable busy dates in daterangepicker JS and Laravel - laravel-5R: how to add volumes from a date - rHow to add Webview to Flutter? - androidHow to return a view to its original size after scaling ViewPropertyAnimator? - androidGraceful gRPC closure downstream - goSQLServer Failed to get ALLOW_SNAPSHOT_ISOLATION to work in C # code (it works in Management Studio) - c #productFlavor in Android Studio / Gradle - androidIterating through an html table using Cheerio - jsonsingle quote output in sql - sqlGroupBy Hour, тогда в среднем между двумя точками - c#All Articles