{
  "name": "R pattern-search tasks and output shapes",
  "description": "Original task-to-output crosswalk compiled from R Core and stringr reference documentation. It distinguishes selecting element positions, selecting whole strings, preserving logical flags and testing literal boundaries. Calls use generic x and pattern inputs rather than study observations.",
  "page": "https://casrai.org/guides/grep-r",
  "publisher": "CASRAI",
  "license": "https://creativecommons.org/licenses/by/4.0/",
  "dateModified": "2026-11-14T08:32:20Z",
  "temporalCoverage": null,
  "spatialCoverage": null,
  "columns": [
    {
      "name": "Task",
      "unit": "",
      "description": ""
    },
    {
      "name": "Documented call",
      "unit": "",
      "description": ""
    },
    {
      "name": "Output",
      "unit": "",
      "description": ""
    },
    {
      "name": "Reference",
      "unit": "",
      "description": ""
    }
  ],
  "rows": [
    {
      "Task": "Select matching positions",
      "Documented call": "base::grep(pattern, x)",
      "Output": "Positions of matching elements",
      "Reference": "R Core: Pattern Matching and Replacement"
    },
    {
      "Task": "Select matching strings",
      "Documented call": "base::grep(pattern, x, value = TRUE)",
      "Output": "Whole matching elements as a character vector",
      "Reference": "R Core: Pattern Matching and Replacement"
    },
    {
      "Task": "Retain one flag per input element",
      "Documented call": "base::grepl(pattern, x)",
      "Output": "Logical match flags",
      "Reference": "R Core: Pattern Matching and Replacement"
    },
    {
      "Task": "Test a literal prefix",
      "Documented call": "base::startsWith(x, prefix)",
      "Output": "Logical prefix flags; shorter inputs are recycled",
      "Reference": "R Core: startsWith/endsWith"
    },
    {
      "Task": "Test a literal suffix",
      "Documented call": "base::endsWith(x, suffix)",
      "Output": "Logical suffix flags; shorter inputs are recycled",
      "Reference": "R Core: startsWith/endsWith"
    },
    {
      "Task": "Detect with string-first arguments",
      "Documented call": "stringr::str_detect(x, pattern)",
      "Output": "Logical vector",
      "Reference": "stringr: str_detect"
    },
    {
      "Task": "Subset with string-first arguments",
      "Documented call": "stringr::str_subset(x, pattern)",
      "Output": "Character vector of matching whole elements",
      "Reference": "stringr: str_subset"
    }
  ],
  "sources": [
    {
      "title": "R Core: Pattern Matching and Replacement",
      "url": "https://search.r-project.org/R/refmans/base/html/grep.html",
      "accessed": "2026-11-14"
    },
    {
      "title": "R Core: startsWith/endsWith",
      "url": "https://stat.ethz.ch/R-manual/R-devel/library/base/html/startsWith.html",
      "accessed": "2026-11-14"
    },
    {
      "title": "stringr: str_detect",
      "url": "https://stringr.tidyverse.org/reference/str_detect.html",
      "accessed": "2026-11-14"
    },
    {
      "title": "stringr: str_subset",
      "url": "https://stringr.tidyverse.org/reference/str_subset.html",
      "accessed": "2026-11-14"
    }
  ]
}