I am running R 4.0.2 on a mac os 11.2
If I call the following libraries in R studio, this all go silently as expected
requiredPackages = c('dplyr','data.table',
'stringr','tools',
'lubridate','docopt',
'geosphere','scales',
'rgdal','tidyverse',
'stringi')
for(p in requiredPackages){
if(!require(p,character.only = TRUE)) install.packages(p)
suppressWarnings(suppressMessages(require(p,character.only = TRUE)))
}
But when I copy these lines in a command line R script
script.R:
#!/usr/bin/env Rscript
requiredPackages = c('dplyr','data.table',
'stringr','tools',
'lubridate','docopt',
'geosphere','scales',
'rgdal','tidyverse',
'stringi')
for(p in requiredPackages){
if(!require(p,character.only = TRUE)) install.packages(p)
suppressWarnings(suppressMessages(require(p,character.only = TRUE)))
}
and run
./script.R
I get back all the verbose
Loading required package: dplyr
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
Loading required package: data.table
Attaching package: ‘data.table’
The following objects are masked from ‘package:dplyr’:
between, first, last
Loading required package: stringr
Loading required package: tools
Loading required package: lubridate
Attaching package: ‘lubridate’
The following objects are masked from ‘package:data.table’:
hour, isoweek, mday, minute, month, quarter, second, wday, week, yday, year
The following objects are masked from ‘package:base’:
date, intersect, setdiff, union
Loading required package: docopt
Loading required package: geosphere
Loading required package: scales
Loading required package: rgdal
Loading required package: sp
rgdal: version: 1.5-23, (SVN revision 1121)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 3.1.4, released 2020/10/20
Path to GDAL shared files: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/gdal
GDAL binary built with GEOS: TRUE
Loaded PROJ runtime: Rel. 6.3.1, February 10th, 2020, [PJ_VERSION: 631]
Path to PROJ shared files: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/proj
Linking to sp version:1.4-5
To mute warnings of possible GDAL/OSR exportToProj4() degradation,
use options("rgdal_show_exportToProj4_warnings"="none") before loading rgdal.
Loading required package: tidyverse
── Attaching packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
✔ ggplot2 3.3.2 ✔ readr 1.3.1
✔ tibble 3.0.2 ✔ purrr 0.3.4
✔ tidyr 1.1.0 ✔ forcats 0.5.0
── Conflicts ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
✖ lubridate::as.difftime() masks base::as.difftime()
✖ data.table::between() masks dplyr::between()
✖ readr::col_factor() masks scales::col_factor()
✖ lubridate::date() masks base::date()
✖ purrr::discard() masks scales::discard()
✖ dplyr::filter() masks stats::filter()
✖ data.table::first() masks dplyr::first()
✖ lubridate::hour() masks data.table::hour()
✖ lubridate::intersect() masks base::intersect()
✖ lubridate::isoweek() masks data.table::isoweek()
✖ dplyr::lag() masks stats::lag()
✖ data.table::last() masks dplyr::last()
✖ lubridate::mday() masks data.table::mday()
✖ lubridate::minute() masks data.table::minute()
✖ lubridate::month() masks data.table::month()
✖ lubridate::quarter() masks data.table::quarter()
✖ lubridate::second() masks data.table::second()
✖ lubridate::setdiff() masks base::setdiff()
✖ purrr::transpose() masks data.table::transpose()
✖ lubridate::union() masks base::union()
✖ lubridate::wday() masks data.table::wday()
✖ lubridate::week() masks data.table::week()
✖ lubridate::yday() masks data.table::yday()
✖ lubridate::year() masks data.table::year()
Is there any way to silent a command line script? I want the script to say when it is missing some input arguments, so I need to get rid of all this fuzzy verbose.