gglogger

gglogger is an R package that logs the calls used to create ggplot2 objects.

https://github.com/pwwang/gglogger

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.0%) to scientific vocabulary

Keywords

ggplot ggplot2 ggplot2-enhancements
Last synced: 5 months ago · JSON representation

Repository

gglogger is an R package that logs the calls used to create ggplot2 objects.

Basic Info
Statistics
  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 4
Topics
ggplot ggplot2 ggplot2-enhancements
Created over 1 year ago · Last pushed 8 months ago
Metadata Files
Readme License

README.md

gglogger gglogger website

gglogger is an R package that logs the calls used to create ggplot2 objects.

This can be useful for debugging, reproducibility, and understanding the sequence of operations used to build a plot.

Have you ever created a plot in ggplot2 and then forgotten how you made it? Or wanted to reproduce a plot but couldn't remember the exact sequence of operations you used? gglogger can help!

Installation

You can install the gglogger package from source using devtools:

```r devtools::install_github("pwwang/gglogger")

or

remotes::install_github("pwwang/gglogger") ```

Usage

To use the gglogger package, simply load it along with ggplot2 and create your plots as usual. The package will automatically log the calls used to create the plots.

Previous Now
```r library(ggplot2) p <- ggplot(mpg, aes(x = displ, y = hwy)) + geom_point() ``` ```r library(ggplot2) # Just add gglogger after ggplot2 library(gglogger) p <- ggplot(mpg, aes(x = displ, y = hwy)) + geom_point() # Print the logs print(p$logs) ## ggplot2::ggplot(mpg, aes(x = displ, y = hwy)) + ## geom_point() ```

Evaluate the code in logs to reproduce the plot:

r p$logs$evaluate()

You can also attach the variables in an environment for evaluation:

r env <- new.env() env$mpg <- mpg env$mpg$hwy <- mpg$hwy / 2 p$logs$evaluate(env)

Registering a function from a ggplot2 extension

```r library(dplyr) library(gglogger)

mtcarsradar <- mtcars %>% astibble(rownames = "group") %>% mutate_at(vars(-group), scales::rescale) %>% tail(4) %>% select(1:10)

ggradar <- register(ggradar::ggradar)

p <- ggradar(mtcars_radar, legend.position = "right") print(p$logs)

ggradar::ggradar(mtcars_radar, legend.position = "right")

```

Generating code to reproduce a plot

```r

p is a ggradar plot created in the previous example

code <- p$logs$gen_code(setup = ' library(dplyr) library(ggradar)

mtcarsradar <- mtcars %>% astibble(rownames = "group") %>% mutate_at(vars(-group), scales::rescale) %>% tail(4) %>% select(1:10) ')

cat(code)

library(dplyr)

library(ggradar)

mtcars_radar <- mtcars %>%

as_tibble(rownames = "group") %>%

mutate_at(vars(-group), scales::rescale) %>%

tail(4) %>%

select(1:10)

ggradar::ggradar(mtcars_radar, legend.position = "right")

eval(parse(text = code)) # to reproduce the plot

```

Limitations

gglogger cannot log the global settings used to create a plot, such as theme_set(). It can only log the calls used directly to create the plot itself. You may need to manually set these global settings when reproducing a plot, or prepare them using the setup argument in gen_code().

If your data is piped to ggplot function, you need to use |> instead of %>%, otherwise the data will be logged as ..

Owner

  • Login: pwwang
  • Kind: user

GitHub Events

Total
  • Create event: 1
  • Issues event: 1
  • Release event: 1
  • Watch event: 1
  • Issue comment event: 1
  • Push event: 7
Last Year
  • Create event: 1
  • Issues event: 1
  • Release event: 1
  • Watch event: 1
  • Issue comment event: 1
  • Push event: 7

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 31
  • Total Committers: 1
  • Avg Commits per committer: 31.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 31
  • Committers: 1
  • Avg Commits per committer: 31.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
pwwang p****g@p****m 31
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 1
  • Total pull requests: 0
  • Average time to close issues: 1 day
  • Average time to close pull requests: N/A
  • Total issue authors: 1
  • Total pull request authors: 0
  • Average comments per issue: 2.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: 1 day
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 2.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • teunbrand (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 235 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 2
  • Total maintainers: 1
cran.r-project.org: gglogger

Track 'ggplot2' Calls

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 235 Last month
Rankings
Dependent packages count: 27.9%
Dependent repos count: 34.4%
Average: 49.8%
Downloads: 86.9%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/main.yml actions
  • JamesIves/github-pages-deploy-action v4 composite
  • actions/checkout v4 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION cran
  • ggplot2 * imports