plot_code: Get the code for reproducing a plot

View source: R/plot_code.R

plot_codeR Documentation

Get the code for reproducing a plot

Description

This function creates the code in text needed for reproducing a plot from explore.

Usage

plot_code(
  filename,
  fulldata,
  selection = seq_len(nrow(fulldata)),
  x,
  y,
  color = "lightblue",
  pal = "Set1"
)

Arguments

filename

The filename (preferably the full path) for the data used.

fulldata

The data.frame with the original full data displayed in explore.

selection

An integer vector of the rows of the fulldata without empty rows (see dropEmpty_row) to be used in the plot.

x

A variable name in fulldata.

y

A variable name in fulldata. If missing, the code for a one way plot is shown.

color

A color to use in the plots that have one single color.

pal

A color palette to use with brewer.pal for the mosaic plots when 'x' and 'y' are factors.

Value

A character vector with the code to reproduce a figure.

Author(s)

Leonardo Collado-Torres

Examples

cat(plot_code("mtcars.csv", mtcars, x = "mpg", selection = 1:5))
cat(plot_code("mtcars.csv", mtcars, x = "mpg", y = "vs"))

LieberInstitute/shinycsv documentation built on May 8, 2023, 7:27 p.m.