to_tribble: Convert a tibble/dataframe to tribble code

View source: R/misc.R

to_tribbleR Documentation

Convert a tibble/dataframe to tribble code

Description

Tribbles are an easy way to legibly input data, and therefore helpful for teaching and interactive work. This function takes a tibble and returns code that can recreate it. Note that this function converts "NA" to NA and converts factors to characters to retain the levels.

Usage

to_tribble(x, show = FALSE, digits = 5, to_clip = interactive())

Arguments

x

The tibble/dataframe to be converted into tribble code

show

Logical. Print code (otherwise, returned - print with cat() to get linebreaks etc)

digits

Number of digits to round numeric columns to.

to_clip

Should code for vector be copied into clipboard? Defaults to TRUE in interactive use, but only works when clipr package is installed

Examples

to_tribble(mtcars[1:5, 1:3], show = TRUE)

LukasWallrich/timesaveR documentation built on Nov. 29, 2024, 4:47 a.m.