shinyplotlyflexdashboardreprex

Flexdashboard opens new tab with every user input


I would like to ask for help with a Flexdashboard using Plotly and Shiny. The only thing now is that the app is throwing away browser tabs like there's no tomorrow. For every reactive input from the user, the app opens a new tab, where it does produce the correct output.

I've noticed that Flexdashboard, Plotly, and Shiny all work well for me. The problem seems to arise somewhere in their combination.

I would greatly appreciate some advice. The reproducible .Rmd script may be found on Github. It was deployed in about two minutes by using the code below:

install.packages('arules')
install.packages('car')
install.packages('contrast')
install.packages('corpcor')
install.packages('doBy')
install.packages('dplyr')
install.packages('flexdashboard')
install.packages('gdata')
install.packages('ggplot2')
install.packages('ggrepel')
install.packages('GPArotation')
install.packages('gtools')
install.packages('Hmisc')
install.packages('irr')
install.packages('lattice')
install.packages('leaflet')
install.packages('ltm')
install.packages('MASS')
install.packages('pastecs')
install.packages('plotly')
install.packages('plyr')
install.packages('png')
install.packages('psych')
install.packages('qpcR')
install.packages('QuantPsyc')
install.packages('RColorBrewer')
install.packages('RCurl')
install.packages('reshape')
install.packages('Rmisc')
install.packages('rsconnect')
install.packages('scales')
install.packages('shiny')
install.packages('tibble')

library(arules)
library(car)
library(contrast)
library(corpcor)
library(doBy)
library(dplyr)
library(flexdashboard)
library(gdata)
library(ggplot2)
library(ggrepel)
library(GPArotation)
library(gtools)
library(Hmisc)
library(irr)
library(lattice)
library(leaflet)
library(ltm)
library(MASS)
library(pastecs)
library(plotly)
library(plyr)
library(png)
library(psych)
library(qpcR)
library(QuantPsyc)
library(RColorBrewer)
library(RCurl)
library(reshape)
library(Rmisc)
library(rsconnect)
library(scales)
library(shiny)
library(tibble)

rmarkdown::run('complete norms flex.rmd')

Below is the output I got (which didn't reveal a lot to me).

> rmarkdown::run('complete norms flex.rmd')
Loading required package: shiny

Listening on http://127.0.0.1:6295



processing file: complete_norms_flex.rmd

  |                                                                       
  |                                                                 |   0%
  |                                                                       
  |.....                                                            |   8%
  ordinary text without R code


  |                                                                       
  |..........                                                       |  15%
label: global (with options) 
List of 1
 $ include: logi FALSE

Loading required package: MASS
Loading required package: msm
Loading required package: polycor

Attaching package: 'psych'

The following object is masked from 'package:ltm':

    factor.scores

The following object is masked from 'package:polycor':

    polyserial

Loading required package: carData

Attaching package: 'car'

The following object is masked from 'package:psych':

    logit

Loading required package: rms
Loading required package: Hmisc
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2
RStudio Community is a great place to get help:
https://community.rstudio.com/c/tidyverse.

Attaching package: 'ggplot2'

The following objects are masked from 'package:psych':

    %+%, alpha


Attaching package: 'Hmisc'

The following object is masked from 'package:psych':

    describe

The following objects are masked from 'package:base':

    format.pval, units

Loading required package: SparseM

Attaching package: 'SparseM'

The following object is masked from 'package:base':

    backsolve


Attaching package: 'rms'

The following object is masked from 'package:Hmisc':

    plotp

The following objects are masked from 'package:car':

    Predict, vif

The following object is masked from 'package:shiny':

    validate


Attaching package: 'pastecs'

The following object is masked from 'package:rms':

    specs


Attaching package: 'scales'

The following objects are masked from 'package:psych':

    alpha, rescale

Loading required package: Matrix

Attaching package: 'Matrix'

The following object is masked from 'package:reshape':

    expand


Attaching package: 'arules'

The following object is masked from 'package:car':

    recode

The following objects are masked from 'package:base':

    abbreviate, write


Attaching package: 'plyr'

The following objects are masked from 'package:reshape':

    rename, round_any

The following objects are masked from 'package:Hmisc':

    is.discrete, summarize


Attaching package: 'magrittr'

The following object is masked from 'package:pastecs':

    extract


Attaching package: 'dplyr'

The following objects are masked from 'package:plyr':

    arrange, count, desc, failwith, id, mutate, rename, summarise,
    summarize

The following objects are masked from 'package:arules':

    intersect, recode, setdiff, setequal, union

The following object is masked from 'package:reshape':

    rename

The following objects are masked from 'package:pastecs':

    first, last

The following objects are masked from 'package:Hmisc':

    src, summarize

The following object is masked from 'package:car':

    recode

The following object is masked from 'package:MASS':

    select

The following objects are masked from 'package:stats':

    filter, lag

The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union


Attaching package: 'rlang'

The following object is masked from 'package:magrittr':

    set_names

gdata: Unable to locate valid perl interpreter
gdata: 
gdata: read.xls() will be unable to read Excel XLS and XLSX files
gdata: unless the 'perl=' argument is used to specify the location
gdata: of a valid perl intrpreter.
gdata: 
gdata: (To avoid display of this message in the future, please
gdata: ensure perl is installed and available on the executable
gdata: search path.)
gdata: Unable to load perl libaries needed by read.xls()
gdata: to support 'XLX' (Excel 97-2004) files.

gdata: Unable to load perl libaries needed by read.xls()
gdata: to support 'XLSX' (Excel 2007+) files.

gdata: Run the function 'installXLSXsupport()'
gdata: to automatically download and install the perl
gdata: libaries needed to support Excel XLS and XLSX formats.

Attaching package: 'gdata'

The following objects are masked from 'package:rlang':

    env, ll

The following objects are masked from 'package:dplyr':

    combine, first, last

The following objects are masked from 'package:pastecs':

    first, last

The following object is masked from 'package:stats':

    nobs

The following object is masked from 'package:utils':

    object.size

The following object is masked from 'package:base':

    startsWith

Loading required package: boot

Attaching package: 'boot'

The following object is masked from 'package:survival':

    aml

The following object is masked from 'package:car':

    logit

The following object is masked from 'package:psych':

    logit

The following object is masked from 'package:lattice':

    melanoma

The following object is masked from 'package:msm':

    cav


Attaching package: 'QuantPsyc'

The following object is masked from 'package:Matrix':

    norm

The following object is masked from 'package:SparseM':

    norm

The following object is masked from 'package:base':

    norm

Loading required package: minpack.lm
Loading required package: rgl
Loading required package: robustbase

Attaching package: 'robustbase'

The following object is masked from 'package:boot':

    salinity

The following object is masked from 'package:survival':

    heart

The following object is masked from 'package:psych':

    cushny


Attaching package: 'gtools'

The following objects are masked from 'package:boot':

    inv.logit, logit

The following object is masked from 'package:rlang':

    chr

The following object is masked from 'package:car':

    logit

The following object is masked from 'package:psych':

    logit

Loading required package: bitops

Attaching package: 'rsconnect'

The following object is masked from 'package:shiny':

    serverInfo


Attaching package: 'plotly'

The following objects are masked from 'package:plyr':

    arrange, mutate, rename, summarise

The following object is masked from 'package:reshape':

    rename

The following object is masked from 'package:Hmisc':

    subplot

The following object is masked from 'package:ggplot2':

    last_plot

The following object is masked from 'package:MASS':

    select

The following object is masked from 'package:stats':

    filter

The following object is masked from 'package:graphics':

    layout

R was not square, finding R from data
R was not square, finding R from data

  |                                                                       
  |...............                                                  |  23%
  ordinary text without R code


  |                                                                       
  |....................                                             |  31%
label: unnamed-chunk-1

  |                                                                       
  |.........................                                        |  38%
  ordinary text without R code


  |                                                                       
  |..............................                                   |  46%
label: unnamed-chunk-2

  |                                                                       
  |...................................                              |  54%
  ordinary text without R code


  |                                                                       
  |........................................                         |  62%
label: unnamed-chunk-3

  |                                                                       
  |.............................................                    |  69%
  ordinary text without R code


  |                                                                       
  |..................................................               |  77%
label: unnamed-chunk-4

  |                                                                       
  |.......................................................          |  85%
  ordinary text without R code


  |                                                                       
  |............................................................     |  92%
label: unnamed-chunk-5 (with options) 
List of 3
 $ fig.width : num 5
 $ fig.height: num 5
 $ echo      : logi FALSE


  |                                                                       
  |.................................................................| 100%
  ordinary text without R code


output file: C:/Users/Pablo/AppData/Local/Temp/RtmpuWjXVZ/complete_norms_flex.knit.md

"C:/PROGRA~2/Pandoc/pandoc" +RTS -K512m -RTS "C:/Users/Pablo/AppData/Local/Temp/RtmpuWjXVZ/complete_norms_flex.utf8.md" --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pandoc1de01a9e76fc.html --smart --email-obfuscation none --standalone --section-divs --template "C:\Users\Pablo\Documents\R\win-library\3.5\flexdashboard\rmarkdown\templates\flex_dashboard\resources\default.html" --include-in-header "C:\Users\Pablo\AppData\Local\Temp\RtmpuWjXVZ\rmarkdown-str1de074483ff7.html" --id-prefix section- --variable "theme:cosmo" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --include-in-header "C:\Users\Pablo\AppData\Local\Temp\RtmpuWjXVZ\file1de02c6f317chtml" --include-before-body "C:\Users\Pablo\AppData\Local\Temp\RtmpuWjXVZ\file1de0258b6988.html" --include-after-body "C:\Users\Pablo\AppData\Local\Temp\RtmpuWjXVZ\file1de04c9e1cbf.html" --highlight-style pygments --include-before-body "C:\Users\Pablo\AppData\Local\Temp\RtmpuWjXVZ\file1de0220034f3.html" --include-after-body "C:\Users\Pablo\AppData\Local\Temp\RtmpuWjXVZ\file1de013ca2efd.html" 

Output created: C:/Users/Pablo/AppData/Local/Temp/RtmpuWjXVZ/file1de059b61073.html

I expected the dashboard to stay on one browser tab, but it multiplies itself.

Thank you very much.


Solution

  • Just use renderPlotly() instead of renderPlot(). Found through these two other questions: