{
  "name": "R sprintf() conversion specifiers: accepted input types and output",
  "description": "Compiled from the base R documentation page for sprintf (R-devel manual): each conversion character, the input types it accepts, how other types are coerced, and what it produces.",
  "page": "https://casrai.org/guides/sprintf-in-r",
  "publisher": "CASRAI",
  "license": "https://creativecommons.org/licenses/by/4.0/",
  "dateModified": "2026-11-14T22:28:26Z",
  "temporalCoverage": null,
  "spatialCoverage": null,
  "columns": [
    {
      "name": "Conversion",
      "unit": "",
      "description": ""
    },
    {
      "name": "Value type",
      "unit": "",
      "description": ""
    },
    {
      "name": "Accepted input and coercion",
      "unit": "",
      "description": ""
    },
    {
      "name": "Output",
      "unit": "",
      "description": ""
    }
  ],
  "rows": [
    {
      "Conversion": "%d, %i",
      "Value type": "Integer",
      "Accepted input and coercion": "Integer; integer-valued numerics are coerced; logical gives 0, 1 or NA",
      "Output": "Decimal integer"
    },
    {
      "Conversion": "%o",
      "Value type": "Integer",
      "Accepted input and coercion": "Same input rules as %d",
      "Output": "Octal"
    },
    {
      "Conversion": "%x, %X",
      "Value type": "Integer",
      "Accepted input and coercion": "Same input rules as %d",
      "Output": "Hexadecimal (lower or upper case)"
    },
    {
      "Conversion": "%f",
      "Value type": "Real",
      "Accepted input and coercion": "Non-double input is coerced with as.double",
      "Output": "Fixed point; default 6 decimals; precision 0 suppresses the point"
    },
    {
      "Conversion": "%e, %E",
      "Value type": "Real",
      "Accepted input and coercion": "Non-double input is coerced with as.double",
      "Output": "Exponential notation"
    },
    {
      "Conversion": "%g, %G",
      "Value type": "Real",
      "Accepted input and coercion": "Non-double input is coerced with as.double",
      "Output": "%e/%E if exponent < -4 or >= precision, else %f; precision = significant digits (default 6)"
    },
    {
      "Conversion": "%a, %A",
      "Value type": "Real",
      "Accepted input and coercion": "Non-double input is coerced with as.double",
      "Output": "Hexadecimal binary representation"
    },
    {
      "Conversion": "%s",
      "Value type": "Character",
      "Accepted input and coercion": "Non-character input is coerced with as.character; NA gives \"NA\"",
      "Output": "String; width and precision count bytes"
    },
    {
      "Conversion": "%%",
      "Value type": "None",
      "Accepted input and coercion": "No argument consumed",
      "Output": "A literal percent sign"
    }
  ],
  "sources": [
    {
      "title": "R documentation: sprintf (base package, R-devel)",
      "url": "https://stat.ethz.ch/R-manual/R-devel/library/base/html/sprintf.html",
      "accessed": "2026-11-14"
    }
  ]
}