Skip to contents

Install package ctrdata on a R system

The R Project website ( provides installers for the R system. It can be used with software products and graphical user interfaces such as R Studio, or Microsoft R Open, or from Visual Studio Code.

General information on the ctrdata package is available here:

In R, execute:


For using the development version of package ctrdata, install from GitHub:

# install preparatory package
install.packages(c("devtools", "httr"))

Either of the above should install package ctrdata into the user’s library.

Internet access via proxy

Functions in package ctrdata that start with ctr... require access to trial registers over the internet via the https protocol. Package ctrdata checks and automatically uses the proxy that is set under MS Windows in system settings. However, proxy settings need to be set by the user for other operating systems and for more complicated environments such as using authenticating proxies, as follows:

Sys.setenv(https_proxy = "your_proxy.server.domain:8080")
Sys.setenv(https_proxy_user = "userid:password") # if needed

Additional installation aspects

The ommand line tools perl, sed, cat and php (5.2 or higher) are required for ctrLoadQueryIntoDb(), the main function of package ctrdata. No other function in this package has this requirement.

MS Windows

Package ctrdata requires on MS Windows that the Cygwin environment be installed, into the local directory c:\cygwin (or any folder corresponding to c:\cygw*). The installation of a minimal Cygwin environment on MS Windows can be done with the help of package ctrdata in R as follows:

If internet access has to be via a proxy and this was not correctly detected automatically, it can be specified for the installation of Cygwin as follows:

ctrdata::installCygwinWindowsDoInstall(proxy = "proxy.server.domain:8080") 

Users who want or need to install Cygwin manually can download the setup executable from here. In a MS Windows command window or Powershell window, use the following command line. The parameters are explained here.

setup-x86_64.exe --no-admin --quiet-mode --verbose --upgrade-also --root c:/cygwin 
--packages perl,php-jsonc,php-simplexml

macOS, Linux and other operating systems

The command line tools perl, sed, cat and php (5.2 or higher) are typically installed and available by default in Linux and macOS systems. In case of issues,

  • In macOS, homebrew can be used to install these binaries

  • In Linux, tools for installation vary by distribution (e.g., sudo apt install php php-xml php-json)

Databases to use

At this time, a PostgreSQL, an SQLite or a remote or a local MongoDB database can be used with the package ctrdata. SQLite is provided in the R package RSQLite. Suggested installation instructions for a local MongoDB server are here; a remote MongoDB database server is accessible here.

Purpose Function call Reference
Create SQLite database connection dbc <- nodbi::src_sqlite(dbname = "name_of_my_database", collection = "name_of_my_collection") nodbi::src_sqlite()
Create PostgreSQL database connection dbc <- nodbi::src_postgres(dbname = "name_of_my_database"); dbc[["collection"]] <- "name_of_my_collection" nodbi::src_postgres()
Create MongoDB database connection dbc <- nodbi::src_mongo(db = "name_of_my_database", collection = "name_of_my_collection") nodbi::src_mongo()
Subsequently, use connection dbc with ctrdata functions ctrdata::{ctr,db}*(con = dbc, ...)

Attach package ctrdata

After completing the installation, attach the package from the user’s library. This will also check the availability of the additional installation requirements as mentioned above:

Remember to respect the registers’ terms and conditions (see ctrOpenSearchPagesInBrowser(copyright = TRUE)). Please cite this package in any publication as follows: Ralf Herold (2021). ctrdata: Retrieve and Analyze Clinical Trials in Public Registers. R package version 1.8.0.