knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

swecris

Lifecycle: experimental R-CMD-check

The goal of the swecris R package is to provide access to data from SweCRIS, a national database that allows you to see how participating research funding bodies has distributed their money to Swedish recipients.

SweCRIS is managed by the Swedish Research Council on behalf of the Government. This R package uses the API at SweCRIS to make data available for use from R.

Installation

You can install the development version of swecris from GitHub with:

library(devtools)
install_github("swecris", dependencies = TRUE)

Examples

Projects for an organization

Goal: Using bundled data for KTH. This is a basic example which shows you how to get bundled data about projects at KTH Royal Institute of Technology:

library(swecris)
suppressPackageStartupMessages(library(dplyr))

# either fetch data live from the API
#kth_projects <- swecris_funding()

# or use the bundled data
kthf <- swecris_kth

# top three largest fundings containing abstracts with the word "data"
library(dplyr)

fundings <- 
  kthf |>
  mutate(total_funding = as.numeric(FundingsSek)) |>
  arrange(desc(total_funding)) |>
  filter(grepl("data", ProjectAbstractEn)) |>
  slice(3)

# display an example record
fundings |>
  glimpse()

Goal: Given an organisation, get its id and then get information about three associated projects whose funding start date soon will be here:

orgid <- 
  swecris_organisations() |>
  filter(grepl("^KTH, ", organisationNameSv)) |>
  dplyr::pull(organisationId) |>
  purrr::pluck(1)

kthp <- swecris_projects(orgid)

# three upcoming projects
projects <- 
  kthp |> 
  mutate(fsd = lubridate::ymd(fundingStartDate)) |>
  filter(fsd > lubridate::now()) |>
  arrange(desc(fsd)) |> 
  select(-starts_with("projectAbstract")) |>
  select(
    projectId, 
    projectTitleEn, 
    projectStartDate, 
    projectEndDate, 
    fundingOrganisationNameEn, 
    fundingsSek, 
    fundingYear
  ) |>
  head(3)

knitr::kable(projects)

Project details

Goal: Given a projects id, get more information about the project and associated people and SCB classification codes:

# some details for a specific project
"2021-00157_VR" |> swecris_project() |> select(-c("projectAbstractEn")) |> t()

# some people involved in this project
"2021-00157_VR" |> swecris_project_people()

# SCB classification codes for this project
"2021-00157_VR" |> swecris_project_scbs()

Swedish, Danish, Finnish and Norwegian lists

Goal: Not part of the SweCRIS API, but mentioned on SweCRIS website. Get data for some Nordic "lists".

Swedish list (the first few records):

sl <- 
  swecris_list_swedish()

glimpse(sl |> head(3) |> collect())

knitr::kable(sl |> head(3) |> collect())

Some other Nordic list referenced at SweCRIS are also provided:

f <- swecris_list_finnish()
n <- swecris_list_norwegian

glimpze <- function(df) {
  df |> slice(1:3) |> knitr::kable()
}

glimpze(f)
glimpze(n)


KTH-Library/swecris documentation built on Nov. 27, 2024, 6:48 p.m.