Nice feature!
datapasta
has something very useful and similar
You could do in a script
d <- head(ggplot2::diamonds)
datapasta::tribble_paste(d)
and the command will output a tribble call using the clipboard right at your cursor position ! Very useful for reproductibility when preparing a reprex.
datapasta::tribble_paste(d)
tibble::tribble(
~carat, ~cut, ~color, ~clarity, ~depth, ~table, ~price, ~x, ~y, ~z,
0.23, "Ideal", "E", "SI2", 61.5, 55, 326L, 3.95, 3.98, 2.43,
0.21, "Premium", "E", "SI1", 59.8, 61, 326L, 3.89, 3.84, 2.31,
0.23, "Good", "E", "VS1", 56.9, 65, 327L, 4.05, 4.07, 2.31,
0.29, "Premium", "I", "VS2", 62.4, 58, 334L, 4.2, 4.23, 2.63,
0.31, "Good", "J", "SI2", 63.3, 58, 335L, 4.34, 4.35, 2.75,
0.24, "Very Good", "J", "VVS2", 62.8, 57, 336L, 3.94, 3.96, 2.48
)
If run in a script, the output will be paste in the script, if in the console it will be paste in the console.
One advantage is not need to have another package than tibble to recreate the data.frame/tibble. datapasta is only needed to generate the data.frame object as a tribble call. Nice features!
datapasta::tribble_construct outputs a string that can be print with cat.
There is also df_paste and df_construct for data.frame call creation. And also other feature that one can discover in datapasta