knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%", warning = FALSE, message = FALSE )
scatteR generates scatterplots based on scagnostic measurements. The current implementation uses Simulated Annealing based on the GenSA package for optimization and rJava is required for the scagnostics measurement calculation.
Simply put scagnostics are like diagnostics for scatterplots. Each scatterplot will have a certain set of characteristics that scagnostics will show to you. You can learn more about it through this paper.
library(palmerpenguins) library(scagnostics) library(ggplot2) qplot(x = bill_length_mm,y = bill_depth_mm,data=penguins)+ theme_minimal()+ labs(x = "Bill length",y = "Bill depth", title = "Scatterplot of bill length and bill depth", subtitle = "Data provided by palmerpenguins dataset")
The above scatterplot has the following characteristics according to scagnostics.
scagnostics(penguins$bill_length_mm,penguins$bill_depth_mm)
You can install the released version of scatteR from Github with:
install.packages("devtools") devtools::install_github("janithwanni/scatteR")
library(scatteR) ## basic example code df <- scatteR(measurements = c("Monotonic" = 0.9),n_points = 100)
scagnostics(df)
plot(df$x,df$y)
library(tidyverse) scatteR(c("Convex" = 0.9),n_points = 250,verbose=FALSE) %>% # data generation mutate(label = ifelse(y > x,"Upper","Lower")) %>% # data preprocessing ggplot(aes(x = x,y = y,color=label))+ geom_point()+ theme_minimal()+ theme(legend.position = "bottom")
generated <- scatteR(scagnostics(penguins$bill_length_mm, penguins$bill_depth_mm), n_points = length(penguins$bill_length_mm),verbose=FALSE) penguins %>% select(bill_length_mm,bill_depth_mm) %>% drop_na() %>% rename(x = bill_length_mm,y = bill_depth_mm) %>% mutate(x = (x - min(x)) / (max(x) - min(x)), y = (y - min(y)) / (max(y) - min(y)), source = "penguins") %>% bind_rows(generated %>% mutate(source = "generated")) %>% ggplot(aes(x = x,y = y,color=source))+ geom_point()+ theme_minimal()+ theme(legend.position = "bottom")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.