An open API service indexing awesome lists of open source software.

https://github.com/bgreenwell/cprint

Print common R data structures in a format which can be used as input to the interpreter
https://github.com/bgreenwell/cprint

Last synced: about 2 months ago
JSON representation

Print common R data structures in a format which can be used as input to the interpreter

Awesome Lists containing this project

README

        

---
output: github_document
---

# cprint: Copy Print

[![Travis build status](https://travis-ci.org/bgreenwell/cprint.svg?branch=master)](https://travis-ci.org/bgreenwell/cprint)
[![Coverage status](https://codecov.io/gh/bgreenwell/cprint/branch/master/graph/badge.svg)](https://codecov.io/github/bgreenwell/cprint?branch=master)

This is a simple package to solve an issue I run into quite often: convert a simple data structure I am working with (i.e., a vector or data frame) into code that can be copy and pasted into an R script or the R interpreter that will reproduce the original object.

## Installation

Install from GitHub:

```{r installation, eval=FALSE}
if (!requireNamespace("devtools")) {
install.packages("devtools")
}
devtools::install_github("bgreenwell/cprint")
```

## Basic usage

Output can be copied and pasted directly into an R script or the R interpreter:

```{r example}
library(cprint)

cprint(iris[1:5, ])
cprint(iris$Petal.Width[1:5])
cprint(iris$Species[1:5])
```

## TODO

* Preserve numeric precision
* Support matrices