Check if package is loaded, if not load it
check_inst_pkg.RdCheck if pkg is installed. If not, package is installed with
install.packages(dependencies = TRUE) and loaded with
library(pkg, character.only = TRUE)
Examples
check_inst_pkg("plotly")
#> Loading required package: plotly
#> Warning: there is no package called ‘plotly’
#> also installing the dependencies ‘httr’, ‘htmlwidgets’, ‘lazyeval’, ‘crosstalk’, ‘data.table’
#> Loading required package: ggplot2
#>
#> Attaching package: ‘plotly’
#> The following object is masked from ‘package:ggplot2’:
#>
#> last_plot
#> The following object is masked from ‘package:stats’:
#>
#> filter
#> The following object is masked from ‘package:graphics’:
#>
#> layout