Skip to content

Instantly share code, notes, and snippets.

@cpsievert
Created October 5, 2016 16:16
Show Gist options
  • Save cpsievert/50dfba96c424c7bce5cbf11e6ec30861 to your computer and use it in GitHub Desktop.
Save cpsievert/50dfba96c424c7bce5cbf11e6ec30861 to your computer and use it in GitHub Desktop.
library(trelliscopecore)
library(dplyr)
library(plotly)
# cognostics data frame
iris_cog_df <- iris %>%
group_by(Species) %>%
summarise(
mean_sl = cog(mean(Sepal.Length), desc = "mean sepal length"),
mean_sw = cog(mean(Sepal.Width), desc = "mean sepal length"),
mean_pl = cog(mean(Petal.Length), desc = "mean sepal length"),
mean_pw = cog(mean(Petal.Width), desc = "mean sepal length")
)
iris_cog_df <- as_cognostics(iris_cog_df, cond_cols = "Species", key_col = "Species")
# list of panels
panels <- iris %>%
split(iris$Species) %>%
lapply(function(x) {
# set collaborate to FALSE, and it works since it doesn't require htmlwidgets::JS()
plot_ly(x, x = ~Sepal.Length, y = ~Sepal.Width) %>% config(collaborate = TRUE)
})
base_path <- tempdir()
write_panels(panels, base_path = base_path, name = "iris")
write_display_obj(
iris_cog_df,
panel_example = panels[[1]],
base_path = base_path,
name = "iris"
)
prepare_display(base_path)
view_display(base_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment