rk.codebook: Data Documentation for RKWard

rk.codebook generates professional HTML data dictionaries directly within RKWard. It bridges the gap between RKWard's internal variable labels and standard R reporting tools (powered by sjPlot), allowing you to create instant "Codebooks" for your datasets.

Features

🌍 Internationalization

The interface is fully localized to match your RKWard language settings:

Requirements

  1. RKWard: 0.7.5 or higher.
  2. The R package sjPlot.
    install.packages("sjPlot")
    
  3. The R package devtools (for installation from source).

Installation

  1. Open R in RKWard.
  2. Run the following commands in the R console:
local({
## Preparar
require(devtools)
## Computar
  install_github(
    repo="AlfCano/rk.codebook"
  )
## Imprimir el resultado
rk.header ("Resultados de Instalar desde git")
})
  1. Restart RKWard to ensure the new menu items appear correctly.

Usage & Examples

To generate a useful codebook, your data needs metadata (Labels). You can add these via the RKWard Data Editor GUI, or programmatically using rk.set.label.

Step 1: Prepare Data with Labels

Run this code in the RKWard console to create a dataset and assign RKWard-native labels:

# 1. Create a raw dataset
my_survey <- data.frame(
  id = 1:10,
  age = c(25, 30, 22, NA, 45, 28, 33, 40, 29, 31),
  group = factor(c(1, 1, 2, 2, 1, 2, 1, 2, 1, 1), labels = c("Control", "Treatment")),
  satisfaction = c(4, 5, 3, 4, NA, 5, 4, 2, 3, 5)
)

# 2. Apply Variable Labels using RKWard's native function
# This is what the plugin "Sync" feature looks for.
rk.set.label(my_survey$id, "Participant Unique Identifier")
rk.set.label(my_survey$age, "Age of Respondent (Years)")
rk.set.label(my_survey$group, "Experimental Condition")
rk.set.label(my_survey$satisfaction, "Self-reported Satisfaction (1-5)")

# 3. (Optional) Check that labels are applied
# rk.get.label(my_survey$age) 

Step 2: Generate the Report

  1. Navigate to Analysis > Data Documentation (codebook) > Generate Data Codebook.
Hierarchy

Screenshot of the path in the main menu.

  1. Dataframe: Select my_survey.
  2. Metadata Integration: Ensure "Sync RKWard Variable Labels to Report" is checked.
  3. Table Content:
    • Check Show Frequencies (Useful for the group variable).
    • Check Show Missing Values (NA).
  4. Click Submit.
Codebook generation

Screenshot of the RKWard interface showing the main panel of rk.codebook and the selection of variables for dictionary generation.

Result

The Output Window will display a formatted HTML table where:

HTML preview

Screenshot of the HTML output device showing the resulting Codebook, with frequency tables and summary statistics.

Author

Alfonso Cano Robles

Assisted by Gemini, a large language model from Google.