Package 'psychds'

Title: Creating and Validating 'Psych-DS' Datasets
Description: Provides a 'Shiny' application and helper functions for adopting 'Psych-DS' (<https://psych-ds.github.io/>), a community data standard for organizing and documenting datasets in the psychological and behavioral sciences inspired by the Brain Imaging Data Structure ('BIDS'). A guided interface walks researchers through the dataset creation process, organizing tabular data files into proper 'Psych-DS' directory structures, generating new, compliant, keyword-based filenames, and generating machine-readable 'JSON' metadata. Additional tools support building and editing data dictionaries with variable-level descriptions, validating datasets against the full 'Psych-DS' specification via a bundled 'JavaScript' validator, and exploring dataset contents interactively.
Authors: Massachusetts Institute of Technology [cph], Brian Leonard [aut, cre] (ORCID: <https://orcid.org/0009-0005-7244-6882>), Melissa Kline Struhl [aut] (ORCID: <https://orcid.org/0000-0003-2217-9331>)
Maintainer: Brian Leonard <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-10-15 20:45:54 UTC
Source: https://github.com/cran/psychds

Help Index


Check and Load Package Dependencies

Description

This function provides robust package management following CRAN policies. It checks versions, handles conflicts, and provides clear user feedback.

Usage

check_dependencies(
  min_versions = NULL,
  recommended_versions = NULL,
  startup_mode = getOption("psychds.startup_mode", "recommended")
)

Arguments

min_versions

Named list of minimum required package versions

recommended_versions

Named list of recommended package versions

startup_mode

Character: "strict", "recommended", or "minimal"

Value

Logical indicating success


Check psychds Dependencies

Description

Verifies that all required and optional package dependencies are installed and meet minimum version requirements.

Usage

check_psychds_deps(
  install_missing = interactive(),
  detailed = FALSE,
  check_pdf = TRUE
)

Arguments

install_missing

Logical. If TRUE (and session is interactive), prompts the user to install any missing packages. Defaults to interactive().

detailed

Logical. If TRUE, displays additional information about the R environment. Default is FALSE.

check_pdf

Logical. Ignored. Retained for backwards compatibility. Default is TRUE.

Details

This function checks for:

  • Required packages: shiny, shinydashboard, shinyjs, DT, jsonlite

  • Optional packages: sortable, zip, pointblank

  • Minimum version requirements for each package

If dependencies are missing, the function provides installation instructions.

Value

Invisibly returns a list with missing_required and missing_recommended character vectors.

Examples

# Quick check
check_psychds_deps()

# Detailed check with environment info
check_psychds_deps(detailed = TRUE)

Initialize Shiny App with Robust Package Management

Description

Main entry point that ensures all dependencies are met

Usage

run_app_safe(app_dir = system.file("shiny", package = "psychds"), ...)

Arguments

app_dir

Directory containing the Shiny app

...

Additional arguments passed to shiny::runApp

Value

No return value. Called for its side effect of launching the 'Shiny' application; blocks until the app is closed.


Run the Psych-DS Shiny Application

Description

Launches the interactive Shiny application for creating, editing, and validating Psych-DS compliant datasets.

Usage

run_psych_ds_app(
  launch.browser = getOption("shiny.launch.browser", interactive()),
  port = getOption("shiny.port"),
  host = getOption("shiny.host", "127.0.0.1"),
  startup_mode = getOption("psychds.startup_mode", "recommended"),
  force_browser = getOption("psychds.force_browser", FALSE),
  ...
)

Arguments

launch.browser

Logical or function. Should the app be opened in a browser? Defaults to TRUE in interactive sessions.

port

Integer. Port number for the application. If NULL, a random available port is used.

host

Character. Host IP address. Defaults to "127.0.0.1" (localhost).

startup_mode

Character. One of "strict", "recommended", or "minimal". Controls dependency checking strictness:

  • "strict": Requires all packages at minimum versions

  • "recommended": Warns about outdated packages but continues

  • "minimal": Only checks for critical dependencies

force_browser

Logical. Force opening in external browser. Recommended for RStudio users experiencing viewer issues.

...

Additional arguments passed to shiny::runApp().

Details

The application provides a guided interface for:

  • Selecting project directories and data files

  • Adding dataset metadata

  • Standardizing filenames with Psych-DS keywords

  • Generating data dictionaries

  • Validating datasets against the Psych-DS specification

Value

This function does not return a value. It launches the Shiny application and blocks until the app is closed.

See Also

check_psychds_deps() for verifying dependencies before running.

Examples

if (interactive()) {
  # Standard launch
  run_psych_ds_app()

  # Force external browser (if RStudio viewer has issues)
  run_psych_ds_app(force_browser = TRUE)

  # Minimal checking for faster startup
  run_psych_ds_app(startup_mode = "minimal")

  # Specific port
  run_psych_ds_app(port = 3838)
}

Validate a Psych-DS Dataset

Description

Validates a dataset directory against the full 'Psych-DS' specification using the same validator used by the 'psychds-validator' command-line tool.

Usage

validate_dataset(dir_path, json = FALSE, verbose = FALSE, use_events = FALSE)

Arguments

dir_path

Path to the 'Psych-DS' dataset directory to validate.

json

Logical. If TRUE, output results as JSON instead of formatted text. Default is FALSE.

verbose

Logical. If TRUE, show verbose output including warnings. Default is FALSE.

use_events

Logical. If TRUE, show live checklist progress output. Default is FALSE.

Details

Requires 'Node.js' to be installed and available on the system PATH. Install 'Node.js' from https://nodejs.org.

Value

Invisibly returns the exit status. Called for its side effect of printing validation results to the console.

Examples

## Not run: 
# Standard text output
validate_dataset("path/to/my-study")

# JSON output for programmatic use
validate_dataset("path/to/my-study", json = TRUE)

# Verbose with warnings
validate_dataset("path/to/my-study", verbose = TRUE)

# Live checklist
validate_dataset("path/to/my-study", use_events = TRUE)

## End(Not run)