Skip to contents

Adds breaks to the text of a deparsed data structure script

Usage

.format_script(obj_expr, snip_width = 70)

Arguments

obj_expr

text for a data structure

snip_width

limit for the number of characters desired before data folding at comma-space breaks

Value

a string with embedded '/n' line breaks

Examples

letters[1:5] |> deparse1(backtick = TRUE) |> xlr:::.format_script()
#> [1] "c(\"a\", \"b\", \"c\", \"d\", \"e\")"
list(tail(iris,2)) |> deparse1(backtick = TRUE) |> xlr:::.format_script()
#> [1] "list(\nstructure(\nlist(\nSepal.Length = c(\n6.2, 5.9\n), \nSepal.Width = c(\n3.4, 3\n), \nPetal.Length = c(\n5.4, 5.1\n), \nPetal.Width = c(\n2.3, 1.8\n), \nSpecies = structure(\nc(\n3L, 3L\n), \nlevels = c(\n\"setosa\", \"versicolor\", \"virginica\"\n), \nclass = \"factor\"\n)\n), \nrow.names = 149:150, \nclass = \"data.frame\"\n)\n)\n"