Skip to contents

This function tells RAP to extract the variables you want from the .dataset database file and to create a CSV file within the main RAP project folder. When you want to use the CSV file in your own data analysis project, use download_project_data(). You probably don't need to run this function often, probably only once at the start of your project. NOTE: This function takes 5 minutes to run on the UKB RAP, so be careful with just randomly running it.

Usage

create_csv_from_database(
  variables_to_extract,
  field = c("name", "title"),
  file_prefix = "data",
  project_id = get_rap_project_id(),
  dataset_record_id = dare_project_record_id,
  username = rap_get_user()
)

Arguments

variables_to_extract

A character vector of variables you want to extract from the UKB database (from the .dataset file). Use save_database_variables_to_project() to create the data-raw/rap-variables.csv file, open that file, and delete all variables you don't want to keep. This is the file that contains the variable_name column you would use for this argument.

file_prefix

The prefix to add to the start of the file name. Defaults to "data".

project_id

The project's abbreviation. Defaults to using get_rap_project_id(), which is the name of the project folder.

dataset_record_id

The "record ID" of the database, found when clicking the .dataset file in the RAP project folder. Defaults to the ID for the Steno project dare_project_record_id.

username

The username to set where the dataset is saved to. Defaults to using rap_get_user(), which is the name of the current user of the session.

Value

Outputs whether the extraction and creation of the data was successful or not. Used for the side effect of creating the CSV on the RAP server. The newly created CSV will have your username in the filename.

Examples

if (FALSE) { # \dontrun{
library(tidyverse)
rap_variables %>%
  pull(id) %>%
  create_csv_from_database(project_id = "mesh", username = "lwjohnst")
} # }