Thanks to visit codestin.com
Credit goes to github.com

Skip to content

An R package to simplify API access to data on higher education in Norway, as provided by Norwegian Directorate for Higher Education and Skills

License

Notifications You must be signed in to change notification settings

ToolsCollectiveR/rdbhapi

 
 

Repository files navigation

R-CMD-check Codecov test coverage CRAN status Lifecycle: stable

Overview

rdbhapi provides an R interface for accessing the open data available through DBH-API. It allows users to query, filter, and retrieve data directly into R for further analysis.


Installation

Install remotes if you don’t have it

install.packages(“remotes”)

Install rdbhapi from GitHub

remotes::install_github(“mni-hkdir/rdbhapi”)

Authentication

To retrieve full (non-rounded) data from the DBH-API, you need to authenticate using your SSO ID and SSO Secret credentials.

There are two options:

  1. Using .Renviron file

    The .Renviron file is a hidden file used by R to store environment variables.
    You can create or edit this file in your home directory or in your R project folder.

    Open the .Renviron file in a text editor:

    file.edit("~/.Renviron")

    Add the following lines to .Renviron:

    dbhapi_sso_id = "your_sso_id"
    dbhapi_sso_secret = "your_sso_secret"
    

    After saving, restart your R session to load the updated .Renviron file.

    You can verify the environment variables are loaded using:

    Sys.getenv("dbhapi_sso_id")
    Sys.getenv("dbhapi_sso_secret")
  2. Setting credentials dynamically

    Alternatively, you can set the token during your R session using:

    Sys.setenv(dbhapi_sso_id = "your_sso_id")
    Sys.setenv(dbhapi_sso_secret = "your_sso_secret")

    Examples

# Load the package
library(rdbhapi)

Get contents of a table

dbh_data(1)

Get the whole table (ID 211)

institutions <- dbh_data(211)
head(institutions)

Download the entire table with ID 142

students_abroad <- dbh_data(142)
head(students_abroad)

Download filtered data for table ID 211

top5_institutions <- dbh_data(
  211,
  filters = list(
    "Institusjonskode" = c("top", "5")
  )
)
head(top5_institutions)

About

An R package to simplify API access to data on higher education in Norway, as provided by Norwegian Directorate for Higher Education and Skills

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • R 100.0%