Format a data.frame as a data.frame(...) call with column vectors, for pasting into Carob scripts. Unlike dput, the output omits structure(), row.names, and class and uses readable column-wise c(...) vectors.

dfput(x, name=NULL, digits = NULL, indent = 4, drop=NULL)

Arguments

x

data.frame

name

optional object name; if set, prints name <- data.frame(...)

digits

optional number of digits for rounding numeric columns

indent

number of spaces before each column line inside data.frame

drop

character vector of column names to omit

Value

The formatted code string (invisibly); also printed for interactive use.

Examples

xy <- data.frame(
  adm1 = c("Dodoma", "Manyara"),
  adm2 = c("Kongwa", "Kiteto"),
  longitude = c(36.6104, 36.8266),
  latitude = c(-5.9767, -5.1963),
  geo_undertainty = c(56168, 84918)
)

dfput(xy, name = "geo")
#> geo <- data.frame(
#>     adm1 = c("Dodoma", "Manyara"),
#>     adm2 = c("Kongwa", "Kiteto"),
#>     longitude = c(36.6104, 36.8266),
#>     latitude = c(-5.9767, -5.1963),
#>     geo_undertainty = c(56168, 84918)
#> )