## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval = FALSE ) ## ----install------------------------------------------------------------------ # install.packages("rMosaic") ## ----voronoi_yaml------------------------------------------------------------- # library(rMosaic) # # # Generate synthetic penguins dataset # set.seed(42) # penguins_df <- data.frame( # bill_length = rnorm(150, mean = 40, sd = 5), # bill_depth = rnorm(150, mean = 18, sd = 3), # species = sample(c("Adelie", "Gentoo", "Chinstrap"), 150, replace = TRUE) # ) # # # Define YAML spec as R list # voronoi_yaml <- list( # params = list( # mesh = 0, # hull = 0 # ), # vconcat = list( # # Main plot # list( # plot = list( # list( # mark = "voronoi", # data = list(from = "penguins"), # x = "bill_length", # y = "bill_depth", # stroke = "white", # strokeWidth = 1, # strokeOpacity = 0.5, # fill = "species", # fillOpacity = 0.2 # ), # list( # mark = "hull", # data = list(from = "penguins"), # x = "bill_length", # y = "bill_depth", # stroke = "species", # strokeOpacity = "$hull", # strokeWidth = 1.5 # ), # list( # mark = "delaunayMesh", # data = list(from = "penguins"), # x = "bill_length", # y = "bill_depth", # z = "species", # stroke = "species", # strokeOpacity = "$mesh", # strokeWidth = 1 # ), # list( # mark = "dot", # data = list(from = "penguins"), # x = "bill_length", # y = "bill_depth", # fill = "species", # r = 2 # ), # list(mark = "frame") # ), # width = 680, # height = 480 # ), # # Interactive controls # list( # hconcat = list( # list( # input = "menu", # label = "Delaunay Mesh", # options = list( # list(value = 0, label = "Hide"), # list(value = 0.5, label = "Show") # ), # as = "$mesh" # ), # list(hspace = 5), # list( # input = "menu", # label = "Convex Hull", # options = list( # list(value = 0, label = "Hide"), # list(value = 1, label = "Show") # ), # as = "$hull" # ) # ) # ) # ) # ) # # # Run the application # runMosaicApp( # spec = voronoi_yaml, # specType = "yaml", # data = list(penguins = penguins_df), # title = "Voronoi Diagram (YAML)" # )