gglogger
gglogger is an R package that logs the calls used to create ggplot2 objects.
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
Repository
gglogger is an R package that logs the calls used to create ggplot2 objects.
Basic Info
- Host: GitHub
- Owner: pwwang
- License: other
- Language: R
- Default Branch: master
- Homepage: https://pwwang.github.io/gglogger/
- Size: 4.65 MB
Statistics
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 4
Topics
Metadata Files
README.md
gglogger 
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
ggplot2and then forgotten how you made it? Or wanted to reproduce a plot but couldn't remember the exact sequence of operations you used?ggloggercan 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
- Repositories: 108
- Profile: https://github.com/pwwang
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
Top Committers
| Name | 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
- Homepage: https://github.com/pwwang/gglogger/
- Documentation: http://cran.r-project.org/web/packages/gglogger/gglogger.pdf
- License: MIT + file LICENSE
-
Latest release: 0.1.6
published 8 months ago
Rankings
Maintainers (1)
Dependencies
- 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
- ggplot2 * imports