0

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: enter image description here

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. enter image description here

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    
```
John Harley
  • 156
  • 1
  • 6
  • 2
    I couldn't reproduce this issue in `R 4.0` iin `mac` and `packageVersion('shiny') [1] ‘1.4.0.2’ > packageVersion('plotly') [1] ‘4.9.2.1’ > packageVersion('dplyr') [1] ‘0.8.99.9003’` – akrun Jun 09 '20 at 03:19
  • 1
    The same is true for me. Maybe you have to update `plotly` to 4.9.2.1. – stefan Jun 09 '20 at 13:09
  • Solved! After reading these comments I updated to 4.9.2.1 and the problem is fixed. I saw this in the most recent package update: [Fixes a ggplotly() bug in axis tick translation (#1725, #1721)](https://cran.r-project.org/web/packages/plotly/news/news.html). – John Harley Jun 09 '20 at 17:31

0 Answers0