This function creates the code in text needed for reproducing a plot from explore.
The filename (preferably the full path) for the data used.
The data.frame with the original full data displayed in explore.
An integer vector of the rows of the fulldata
without empty rows (see dropEmpty_row) to be used in the plot.
A variable name in fulldata
.
A variable name in fulldata
. If missing, the code for a
one way plot is shown.
A color to use in the plots that have one single color.
A color palette to use with brewer.pal for the mosaic plots when `x` and `y` are factors.
A character vector with the code to reproduce a figure.
cat(plot_code("mtcars.csv", mtcars, x = "mpg", selection = 1:5))
#>
#> ## Install shinycsv if needed
#> install.packages('devtools')
#> devtools::install_github('LieberInstitute/shinycsv')
#>
#> ## Load necessary code
#> library('shinycsv')
#>
#> ## Load your data
#> df <- read_table('mtcars.csv')
#>
#> ## If your file is not in the R current working directory (see it with getwd())
#> ## then you can run:
#> # df <- read_table(file.choose())
#> ## Note that using file.choose() is not completely reproducible, which is why
#> ## we prefer the first option.
#>
#> ## Drop empty rows
#> df <- dropEmpty_row(df)
#>
#> ## Subset data
#> df <- df[, c(1, 2, 3, 4, 5)]
#>
#> ## One variable plot
#> plot_oneway(info = df$mpg, title = 'mpg', color = 'lightblue')
#>
#> ## Reproducibility information
#> options(width = 120)
#> devtools::session_info()
#> Sys.time()
#>
cat(plot_code("mtcars.csv", mtcars, x = "mpg", y = "vs"))
#>
#> ## Install shinycsv if needed
#> install.packages('devtools')
#> devtools::install_github('LieberInstitute/shinycsv')
#>
#> ## Load necessary code
#> library('shinycsv')
#>
#> ## Load your data
#> df <- read_table('mtcars.csv')
#>
#> ## If your file is not in the R current working directory (see it with getwd())
#> ## then you can run:
#> # df <- read_table(file.choose())
#> ## Note that using file.choose() is not completely reproducible, which is why
#> ## we prefer the first option.
#>
#> ## Drop empty rows
#> df <- dropEmpty_row(df)
#>
#> ## Two variable plot
#> plot_twoway(x = df$mpg, y = df$vs, xvar = 'mpg', yvar = 'vs', color = 'lightblue', pal = 'Set1')
#>
#> ## Reproducibility information
#> options(width = 120)
#> devtools::session_info()
#> Sys.time()
#>