Last updated: 2021-02-12

Checks: 7 0

Knit directory: rpkgs/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20201012) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 90be63f. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    code/chartfonts/chartfonts/.Rhistory
    Ignored:    code/chartfonts/chartfonts/.Rproj.user/
    Ignored:    code/workflowrsubdirs/.Rhistory
    Ignored:    code/workflowrsubdirs/workflowrsubdirs/.Rhistory
    Ignored:    code/workflowrsubdirs/workflowrsubdirs/.Rproj.user/

Untracked files:
    Untracked:  code-rmd/examples--iris--data-overview.Rmd
    Untracked:  code-rmd/examples--iris--interactive-visuals--plotly.Rmd
    Untracked:  code-rmd/examples--iris--interactive-visuals--trelliscopejs.Rmd
    Untracked:  code-rmd/examples--iris--static-visuals--histograms.Rmd
    Untracked:  code-rmd/examples--iris--static-visuals--plots.Rmd
    Untracked:  trelliscopejs/

Unstaged changes:
    Modified:   code/examples/iris/interactive-visuals/trelliscopejs.R

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/examples–iris–interactive-visuals–plotly.Rmd) and HTML (docs/examples–iris–interactive-visuals–plotly.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 90be63f LearnUseZone 2021-02-12 feat: Commit temporary analysis .(r|R)md files
Rmd a0ae3fb LearnUseZone 2021-02-09 feat(workflowrsubdirs): Recreate current HTML web pages
html a0ae3fb LearnUseZone 2021-02-09 feat(workflowrsubdirs): Recreate current HTML web pages
Rmd 9adb980 LearnUseZone 2021-02-09 feat: Commit temporary analysis .(r|R)md files
Rmd cb9dcd9 LearnUseZone 2021-01-05 fix(workflowrsubdirs): Use correct Source file paths in HTML
html cb9dcd9 LearnUseZone 2021-01-05 fix(workflowrsubdirs): Use correct Source file paths in HTML
Rmd 824a3e9 LearnUseZone 2021-01-05 feat: Commit temporary analysis .(r|R)md files
Rmd 3063bb6 LearnUseZone 2020-12-31 feat(workflowrsubdirs): Add files associated to plotly.Rmd
html 3063bb6 LearnUseZone 2020-12-31 feat(workflowrsubdirs): Add files associated to plotly.Rmd
Rmd 717cb7c LearnUseZone 2020-12-31 feat: Commit temporary analysis .(r|R)md files
Rmd 272ca70 LearnUseZone 2020-12-19 feat(workflowrsubdirs): Update .html examples using workflowrsubdirs (.Rmd files in “code-rmd”)
html 272ca70 LearnUseZone 2020-12-19 feat(workflowrsubdirs): Update .html examples using workflowrsubdirs (.Rmd files in “code-rmd”)
Rmd 7b517dd LearnUseZone 2020-12-19 separate commit of temporary .Rmd files
Rmd 527b83a LearnUseZone 2020-12-09 feat(workflowrsubdirs): Add examples to demonstrate functionality
html 527b83a LearnUseZone 2020-12-09 feat(workflowrsubdirs): Add examples to demonstrate functionality
Rmd 96087f9 LearnUseZone 2020-12-09 separate commit of temporary .Rmd files

Source file: code-rmd/examples/iris/interactive-visuals/plotly.Rmd

Scatter plot with qualitative color scales

Interactive scatter plot with 3 species of Iris (Iris setosa, Iris virginica and Iris versicolor) distinguished by color is shown below.

Load prepared data

knitr::read_chunk("code/examples/iris/interactive-visuals/plotly.R")

Scatter plot

# load packages
library(dplyr)

# shared data
iris_shared <- crosstalk::SharedData$new(iris)

# color by species
color_scatter <- iris_shared %>%
  plotly::plot_ly(
    x = ~ Sepal.Length,
    y = ~ Petal.Length,
    mode = "markers",
    type = "scatter",
    color = ~ Species,
    colors = c("blue", "red2", "green3"),  # alternative: "Set2"

    # hover text
    hoverinfo = "text", # suppress default text in tooltip
    text = ~ base::paste(
      paste("\n", "Iris species:  ", paste("<b>", Species, "</b>")),
      paste("\n", "Sepal length:", paste("<b>", `Sepal.Length`, "cm", "</b>")),
      paste("\n", "Petal length: ", paste("<b>", `Petal.Length`, "cm", "</b>"))
    ),
    hoverlabel = list(  # properties of hover label text
      font = list(
        size = 16,
        family = "Arial",
        color = "rgb(245, 245, 245)"
      ),
      align = "left"
    )
  ) %>%
  plotly::layout(
    title = "Iris species by lengths",
    xaxis = list(title = "Sepal length (cm)"),
    yaxis = list(title = "Petal length (cm)"),
    legend = list(
      orientation = "v",
      x = 0.82, y = 0.08,
      bgcolor = "white",  # alternative: rgb(245, 245, 245)
      title = list(text = "Iris species")
    )
  )

# add a filter to an interactive qualitative color scales scatter plot
crosstalk::bscols(
  widths = c(2, NA),
  list(
    crosstalk::filter_slider("Sepal.Length", "Sepal length (cm)", iris_shared, ~ Sepal.Length),
    crosstalk::filter_slider("Petal.Length", "Petal length (cm)", iris_shared, ~ Petal.Length)
  ),
  color_scatter
)

sessionInfo()
#> R version 4.0.3 (2020-10-10)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19041)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=Slovak_Slovakia.1250  LC_CTYPE=Slovak_Slovakia.1250   
#> [3] LC_MONETARY=Slovak_Slovakia.1250 LC_NUMERIC=C                    
#> [5] LC_TIME=Slovak_Slovakia.1250    
#> system code page: 1252
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] dplyr_1.0.2     workflowr_1.6.2
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.5             pillar_1.4.6           compiler_4.0.3        
#>  [4] later_1.1.0.1          git2r_0.27.1           tools_4.0.3           
#>  [7] digest_0.6.25          viridisLite_0.3.0      jsonlite_1.7.1        
#> [10] gtable_0.3.0           lubridate_1.7.9        evaluate_0.14         
#> [13] lifecycle_0.2.0        tibble_3.0.3           pkgconfig_2.0.3       
#> [16] rlang_0.4.10           shiny_1.5.0            rstudioapi_0.11.0-9000
#> [19] crosstalk_1.1.0.1      yaml_2.2.1             xfun_0.18             
#> [22] fastmap_1.0.1          httr_1.4.2             stringr_1.4.0         
#> [25] knitr_1.30             htmlwidgets_1.5.1      generics_0.0.2        
#> [28] fs_1.5.0               vctrs_0.3.2            grid_4.0.3            
#> [31] rprojroot_1.3-2        tidyselect_1.1.0       data.table_1.13.0     
#> [34] glue_1.4.2             R6_2.4.1               plotly_4.9.2.1        
#> [37] rmarkdown_2.4          farver_2.0.3           tidyr_1.1.1           
#> [40] ggplot2_3.3.2          purrr_0.3.4            magrittr_1.5          
#> [43] whisker_0.4            scales_1.1.1           backports_1.1.9       
#> [46] promises_1.1.1         ellipsis_0.3.1         htmltools_0.5.0       
#> [49] colorspace_1.4-1       xtable_1.8-4           mime_0.9              
#> [52] httpuv_1.5.4           stringi_1.5.3          lazyeval_0.2.2        
#> [55] munsell_0.5.0          crayon_1.3.4

Copyright © 2021 LearnUseZone