surreal
Create Datasets with Hidden Images or Messages in Residual Plots
Science Score: 39.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
Found 1 DOI reference(s) in README -
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (18.7%) to scientific vocabulary
Keywords
diagnostic-plots
r-package
residual-analysis
residuals
rstats
Last synced: 10 months ago
·
JSON representation
Repository
Create Datasets with Hidden Images or Messages in Residual Plots
Basic Info
- Host: GitHub
- Owner: coatless-rpkg
- License: gpl-3.0
- Language: R
- Default Branch: main
- Homepage: https://r-pkg.thecoatlessprofessor.com/surreal/
- Size: 7.25 MB
Statistics
- Stars: 16
- Watchers: 1
- Forks: 0
- Open Issues: 2
- Releases: 1
Topics
diagnostic-plots
r-package
residual-analysis
residuals
rstats
Created about 2 years ago
· Last pushed almost 2 years ago
Metadata Files
Readme
Changelog
License
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# surreal
[](https://github.com/coatless-rpkg/surreal/actions/workflows/R-CMD-check.yaml)
Ever wanted to hide secret messages or images in your data? That's what the
`surreal` package does! It lets you create datasets with hidden images or text
that appear when you plot the residuals of a linear model by providing an
implementation of the "Residual (Sur)Realism" algorithm described by
Stefanski (2007).
## Installation
You can install `surreal` from CRAN:
```r
install.packages("surreal")
```
Or get the latest version from GitHub:
``` r
# install.packages("remotes")
remotes::install_github("coatless-rpkg/surreal")
```
## Usage
First, load the package:
```{r}
#| label: load-library
library(surreal)
```
Once loaded, we can take any series of `(x, y)` coordinate positions for an image
or a text message and apply the surreal method to it.
### Importing Data
As an example, let's use the built-in R logo dataset:
```{r}
#| label: load-logo
data("r_logo_image_data", package = "surreal")
plot(r_logo_image_data, pch = 16, main = "Original R Logo Data")
```
The data for the R logo is stored in a data frame with two columns, `x` and `y`:
```{r}
#| label: logo-data-summary
str(r_logo_image_data)
summary(r_logo_image_data)
```
### Applying the Surreal Method
Now, let's apply the surreal method to the R logo data to hide it in a dataset.
We'll want to set a seed for reproducibility purposes since the algorithm
relies on an optimization routine:
```{r}
#| label: apply-surreal-method
set.seed(114)
transformed_data <- surreal(r_logo_image_data)
```
We can note that the transformed data has additional covariates that obfuscate
the original image. If we observe the transformed data by using a scatterplot
matrix graph, we can see that the new covariates do not reveal the original image:
```{r}
#| label: surreal-method-data-pair-plot
pairs(y ~ ., data = transformed_data, main = "Data After Transformation")
```
### Revealing the Hidden Image
We need to fit a linear model to the transformed data and plot the residuals:
```{r}
#| label: surreal-method-residual-plot
model <- lm(y ~ ., data = transformed_data)
plot(model$fitted, model$resid, pch = 16,
main = "Residual Plot: Hidden R Logo Revealed")
```
The residual plot reveals the original R logo with a slight border. This
border is automatically added inside the surreal method to enhance the
recovery of the hidden image in the residual plot.
## Hide Your Own Message
Want to hide your own message? You can also create datasets with custom text:
```{r}
#| label: custom-text-example
# Generate a dataset with a hidden message across multiple lines
message_data <- surreal_text("R\nis\nawesome!")
# Reveal the hidden message
model <- lm(y ~ ., data = message_data)
plot(model$fitted, model$resid, pch = 16,
main = "Custom Message in Residuals")
```
## References
Stefanski, L. A. (2007). "Residual (Sur)realism". *The American Statistician*, 61(2), 163-177. doi:10.1198/000313007X190079
## Acknowledgements
This package is based on Stefanski (2007) and builds upon earlier R implementations by [John Staudenmayer](https://www4.stat.ncsu.edu/~stefansk/NSF_Supported/Hidden_Images/000_R_Programs/John_Staudenmayer/),
[Peter Wolf](https://www4.stat.ncsu.edu/~stefansk/NSF_Supported/Hidden_Images/000_R_Programs/Peter_Wolf/), and
[Ulrike Gromping](https://www4.stat.ncsu.edu/~stefansk/NSF_Supported/Hidden_Images/000_R_Programs/Ulrike_Gromping/).
Owner
- Name: coatless-rpkg
- Login: coatless-rpkg
- Kind: organization
- Repositories: 14
- Profile: https://github.com/coatless-rpkg
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 4
- Total pull requests: 0
- Average time to close issues: 3 days
- Average time to close pull requests: N/A
- Total issue authors: 1
- Total pull request authors: 0
- Average comments per issue: 0.5
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 4
- Pull requests: 0
- Average time to close issues: 3 days
- Average time to close pull requests: N/A
- Issue authors: 1
- Pull request authors: 0
- Average comments per issue: 0.5
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- coatless (4)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 208 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 1
- Total maintainers: 1
cran.r-project.org: surreal
Create Datasets with Hidden Images in Residual Plots
- Homepage: https://github.com/coatless-rpkg/surreal
- Documentation: http://cran.r-project.org/web/packages/surreal/surreal.pdf
- License: GPL (≥ 3)
-
Latest release: 0.0.1
published almost 2 years ago
Rankings
Dependent packages count: 28.2%
Dependent repos count: 34.8%
Average: 49.9%
Downloads: 86.6%
Maintainers (1)
Last synced:
11 months ago
Dependencies
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v4 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml
actions
- JamesIves/github-pages-deploy-action v4.5.0 composite
- actions/checkout v4 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION
cran
- R >= 4.3.0 depends