# ds2dd • stRoke
stRoke

Skip to contents

# ds2dd

#### 2023-04-12

Source: `vignettes/ds2dd.Rmd`
`ds2dd.Rmd`

    library(stRoke)

## Easy data set to data base workflow

This function can be used as a simple tool for creating at data base metadata file for REDCap (called a DataDictionary) based on a given data set file.

### Step 1 - Load your data set

Here we’ll use the sample TALOS dataset included with the package.

    data("talos")
    # As the data set lacks an ID column, one is added
    talos$id <- seq_len(nrow(talos))

### Step 2 - Create the DataDictionary

    datadictionary <- ds2dd(talos,record.id = "id")

Now additional specifications to the DataDictionary can be made manually, or it can be uploaded and modified manually in the graphical user interface on the web page.

### Step 3 - Upload

Now the DataDictionary can be exported as a spreadsheet and uploaded or it can be uploaded using the `REDCapR` package (only projects with “Development” status).

Use one of the two approaches below:

#### Manual upload

    write.csv(datadictionary,"datadictionary.csv")

#### Upload with `REDCapR`

    REDCapR::redcap_metadata_write(
      datadictionary,
      redcap_uri = keyring::key_get("DB_URI"),
      token = keyring::key_get("DB_TOKEN")
    )

In the “REDCap R Handbook” more is written on interfacing with REDCap in R using the `library(keyring)`to store credentials in chapter 1.1.