Skip to content

inbo/inbodb

Project Status: Active – The project has reached a stable, usable state and is being actively developed. Lifecycle:stable GitHub Release R build status r-universe name r-universe package GitHub code size in bytes GitHub repo size DOI

inbodb A hexagon with the word inbodb

Connect to and retrieve data from databases on the INBO server

Installation

To install inbodb from the INBO universe, start a new R session and run this code (before loading any packages):

# Enable the INBO universe (not needed for INBO employees, as this is the default setting)
options(
  repos = c(
    inbo = "https://inbo.r-universe.dev", CRAN = "https://cloud.r-project.org"
  )
)
# Install the packages
install.packages("inbodb")

To install inbodb from GitHub, start a new R session and run this code (before loading any packages):

#install.packages("remotes")
remotes::install_github("inbo/inbodb")

Use inbodb

The main function, connect_inbo_dbase(), makes a connection to an INBO database by simply providing the database's name as an argument (when connected to the INBO network). After making this connection, a Connections pane in RStudio shows an overview of the INBO databases, in which database contents can be explored by clicking on the icons.

The connection allows to download or query data from the database using functions of packages DBI and dbplyr. Some of the DBI functions have extra functionality in inbodb, for instance dbDisconnect() will also close the Connections pane in RStudio in addition to closing the connection. Other functions may give more informative errors or (temporarily) fix small technical issues in addition to the DBI functionality, to ensure smooth access to the INBO databases.

Some code examples:

# load packages
library(inbodb)
library(DBI)

# open database connection
con <- connect_inbo_dbase("D0152_00_Flora")

# read a whole table
dbReadTable(con, "Bron")

# query a database using a SQL query
dbGetQuery(con, "SELECT ID, Code, Beschrijving FROM Bron")

# compose a query using R-code and dbplyr
library(dplyr)
tbl(con, "Bron") |>
  select("ID", "Code", "Beschrijving") |>
  collect()

# close the connection
dbDisconnect(con)

# convert column names of an imported dataset to snake_case
janitor::clean_names(dataset)

As databases can be rather complex, we also wrote manuals and functions to easily retain data from some databases:

Some other databases have functions in a dedicated R package to retain or analyse data, e.g.

About

Connect to and retrieve data from databases on the INBO server

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors