Sorry if this has been echoed elsewhere, I can't seem to find any info on this.
I found a strange bug when creating an interactive markdown document with RMarkdown, shiny, and plotly. Basically when I have a selectInput
tab in the document which is then used to filter a data frame, the axis labels are incorrect but only for the selected=
or the default first argument. Here's a MCVE
---
title: "MCVE"
author: "author"
date: "6/8/2020"
output: html_document
runtime: shiny
---
```{r iris, echo=FALSE, message=FALSE, warning=FALSE}
require(shiny)
require(plotly)
require(tidyverse)
inputPanel(
selectInput("Species", label = "Species",
choices = unique(as.character(iris$Species)), selected = "setosa"))
renderPlotly({
iris %>%
filter(Species == input$Species) %>%
ggplot(aes(x=Sepal.Length, y=Sepal.Width)) +
geom_point() -> g1
ggplotly(g1)
})
```
Here is a screenshot where you can see the error:
Note the tooltip displays the correct values for Sepal Length and Sepal Width, but the labels on the x- and y-axes are incorrect.
This problem does not exist for the other options in the selectInput
, seen here for "versicolor". For both versicolor and virginica the tooltip values match the axes labels.
Note that this problem persists even if you don't specify a selected
value. Am I using something incorrectly or is this a bug?
```
> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] plotly_4.9.2 viridis_0.5.1 viridisLite_0.3.0 ROCR_1.0-11 ncdf4_1.16.1 aws.s3_0.3.12
[7] googlesheets4_0.2.0 rnoaa_0.8.4 rvest_0.3.5 xml2_1.2.5 forcats_0.4.0 stringr_1.4.0
[13] dplyr_0.8.3 purrr_0.3.3 readr_1.3.1 tidyr_1.0.2 tibble_2.1.3 ggplot2_3.3.0
[19] tidyverse_1.3.0
```