Flexdashboard opens new tab with every user input - shiny

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.

Just use renderPlotly() instead of renderPlot(). Found through these two other questions:
Shiny renderPlot within Interactive Document opens a new Browser Window with dygraph
https://stackoverflow.com/a/51378684/7050882

Related

ResumableUploadAbortException: Upload complete with 1141101995 additional bytes left in stream

I am doing a distributed training using GCP Vertex platform. The model is trained in parallel using 4 GPU's using Pytorch and HuggingFace. After training when I save the model from local container to GCP bucket it throws me the error.
Here is the code:
I launch the train.py this way:
python -m torch.distributed.launch --nproc_per_node 4 train.py
After training is complete I save model files using this. It has 3 files that needs to be saved.
trainer.save_model("model_mlm") #Saves in local directory
subprocess.call('gsutil -o GSUtil:parallel_composite_upload_threshold=0 cp -r /pythonPackage/trainer/model_mlm gs://*****/model_mlm', shell=True, stdout=subprocess.PIPE) #from local to GCP
Error:
ResumableUploadAbortException: Upload complete with 1141101995 additional bytes left in stream; this can happen if a file changes size while being uploaded
And sometimes I get this error:
ResumableUploadAbortException: 409 The object has already been created in an earlier attempt and was overwritten, possibly due to a race condition.
As per the documentation name conflict, you are trying to overwrite a file that has already been created.
So I would recommand you to change the destiny location with a unique identifier per training so you don't receive this type of error. For example, adding the timestamp in string format at the end of your bucket like:
- gs://pypl_bkt_prd_row_std_aiml_vertexai/model_mlm_vocab_exp2_50epocs/20220407150000
I would like to mention that this kind of error is retryable as mentioned in the error documentation error docs.

Getting "unmarshal failed" when trying to create first website post in Hugo after installation

I'm following the instructions at Hugo's Quickstart guide (https://gohugo.io/getting-started/quick-start/) but I keep getting this error message when I try to create a post:
unmarshal failed: Near line 1 (last key parsed 'theme'): expected value but found '\\' instead
I've posted some lines of my code below. The error message appears at the bottom. Could anyone help point out what I am doing wrong?
C:\Users\Scott\quickstart\MyHugoBlog\themes>git init
Initialized empty Git repository in C:/Users/Scott/quickstart/MyHugoBlog/themes/.git/
C:\Users\Scott\quickstart\MyHugoBlog\themes>git submodule add https://github.com/dashdashzako/paperback.git
Cloning into 'C:/Users/Scott/quickstart/MyHugoBlog/themes/paperback'...
remote: Enumerating objects: 16, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 194 (delta 3), reused 9 (delta 1), pack-reused 178 eceiving objects: 53% (103/194)
Receiving objects: 100% (194/194), 466.30 KiB | 5.62 MiB/s, done.
Resolving deltas: 100% (93/93), done.
warning: LF will be replaced by CRLF in .gitmodules.
The file will have its original line endings in your working directory
C:\Users\Scott\quickstart\MyHugoBlog\themes>echo theme = \"paperback\" >> config.toml
C:\Users\Scott\quickstart\MyHugoBlog\themes>hugo new posts/my-first-post.md
Error: "C:\Users\Scott\quickstart\MyHugoBlog\themes\config.toml:1:1": unmarshal failed: Near line 1 (last key parsed 'theme'): expected value but found '\\' instead
It looks like you're following instructions meant for Unix-like systems on Windows. This command isn't doing what you want:
echo theme = \"paperback\" >> config.toml
Using Bash on Linux, for example, this appends
theme = "paperback"
to your config.toml file, creating it if necessary. That's what Hugo expects to find in the file.
However, using cmd.exe on Windows I get the backslashes included:
theme = \"paperback\"
And using PowerShell, I get something even stranger:
theme
=
\paperback\
Neither of these looks like valid TOML to me, and both contain extraneous backslashes as referenced in your error message. I suggest you simply edit config.toml using your favourite text editor and add the expected
theme = "paperback"
line manually.
The issue on my end was that the file wasn't created as UTF-8
Delete the config.toml file and recreate it manually on your text editor, then paste the content like: theme = "ananke"
should work

Tensorflow- bidirectional_dynamic_rnn: Attempt to reuse RNNCell

The following code (taken from - https://github.com/dennybritz/tf-rnn/blob/master/bidirectional_rnn.ipynb)
import tensorflow as tf
import numpy as np
tf.reset_default_graph()
# Create input data
X = np.random.randn(2, 10, 8)
# The second example is of length 6
X[1,6:] = 0
X_lengths = [10, 6]
cell = tf.contrib.rnn.LSTMCell(num_units=64, state_is_tuple=True)
outputs, states = tf.nn.bidirectional_dynamic_rnn(
cell_fw=cell,
cell_bw=cell,
dtype=tf.float64,
sequence_length=X_lengths,
inputs=X)
output_fw, output_bw = outputs
states_fw, states_bw = states
is giving the following error for
tensorflow - 1.1 for both 2.7 and 3.5
ValueError: Attempt to reuse RNNCell <tensorflow.contrib.rnn.python.ops.core_rnn_cell_impl.LSTMCell object at 0x10ce0c2b0>
with a different variable scope than its first use. First use of cell was with scope
'bidirectional_rnn/fw/lstm_cell', this attempt is with scope 'bidirectional_rnn/bw/lstm_cell'.
Please create a new instance of the cell if you would like it to use a different set of weights.
If before you were using: MultiRNNCell([LSTMCell(...)] * num_layers), change to:
MultiRNNCell([LSTMCell(...) for _ in range(num_layers)]). If before you were using the same cell
instance as both the forward and reverse cell of a bidirectional RNN, simply create two instances
(one for forward, one for reverse). In May 2017, we will start transitioning this cell's behavior to use
existing stored weights, if any, when it is called with scope=None (which can lead to silent model degradation,
so this error will remain until then.)
But it is working in
tensorflow - 1.0.1 for python 3.5 (did not test on python - 2.7)
I tried with multiple code examples I found online but
tf.nn.bidirectional_dynamic_rnn
is giving the same error with tensorflow - 1.1
Is there a bug in tensorflow 1.1 or am i just missing something?
Sorry you ran into this. I can confirm that the error appears in 1.1 (docker run -it gcr.io/tensorflow/tensorflow:1.1.0 python) but not in 1.2 RC0 (docker run -it gcr.io/tensorflow/tensorflow:1.2.0-rc0 python).
So it looks like either 1.2-rc0 or 1.0.1 are your options for the moment.

R error: join_cols() / join_vert(): number of columns must be the same

I have a problem fitting instrumental variable models with covariates with the bayesm package in R. Adding covariates results in the error message :
"error: join_cols() / join_vert(): number of columns must be the same"
The error stems from the external function 'rivDP_rcpp_loop.cpp' called via Rcpp. I am however not skilled enough to handle the problem on R level.
I constructed an example based on the function example which results in the error on my machine.
##
## simulate scaled log-normal errors and run
##
set.seed(66)
k=10
delta=1.5
Sigma=matrix(c(1,.6,.6,1),ncol=2)
N=1000
tbeta=4
set.seed(66)
scalefactor=.6
root=chol(scalefactor*Sigma)
mu=c(1,1)
##
## compute interquartile ranges
##
ninterq=qnorm(.75)-qnorm(.25)
error=matrix(rnorm(100000*2),ncol=2)
error=t(t(error)+mu)
Err=t(t(exp(error))-exp(mu+.5*scalefactor*diag(Sigma)))
lnNinterq=quantile(Err[,1],prob=.75)-quantile(Err[,1],prob=.25)
##
## simulate data
##
error=matrix(rnorm(N*2),ncol=2)%*%root
error=t(t(error)+mu)
Err=t(t(exp(error))-exp(mu+.5*scalefactor*diag(Sigma)))
#
# scale appropriately
Err[,1]=Err[,1]*ninterq/lnNinterq
Err[,2]=Err[,2]*ninterq/lnNinterq
z=matrix(runif(k*N),ncol=k)
x=z%*%(delta*c(rep(1,k)))+Err[,1]
y=x*tbeta+Err[,2]
w<-matrix(rnorm(10000),ncol=10)
# set intial values for MCMC
Data = list(); Mcmc=list()
Data$z<-cbind(z,w); Data$x=x; Data$y=y; Data$w<-w
# start MCMC and keep results
Mcmc$maxuniq=100
Mcmc$R=R
end=Mcmc$R
begin=100
out=rivDP(Data=Data,Mcmc=Mcmc)
I had the same problem and have contacted the package maintainer for clarification. In the mean time I was able to get the rivDP() function to work by downloading the version 2.2-5 from 2012. Make sure to install Rtools first (from here: https://cran.r-project.org/bin/windows/Rtools/) and then run the following code:
packageurl <- "https://cran.r-project.org/src/contrib/Archive/bayesm/bayesm_2.2-5.tar.gz"
install.packages(packageurl, repos=NULL, type="source")
library(bayesm)

Empty folders after fitting using VOSM (Vision Open Statistical Models)

I am trying to develop an Active Appearance model using the VOSM package (http://www.visionopen.com/downloads/open-source-software/vosm/). I'm on Ubuntu 13.10 64b and use OpenCV-2.4.8, Boost-1.55 and VOSM-0.33.
I have successfully trained the model using facial databases, and have the trained data stored in a subfolder. When I try to test the AAM fitting on some test images, there are no saved files, but the terminal output indicates the fitting process has completed properly.
Command: test_smfitting -o trained_data/ -t "AAM_BASIC" -i images/test_2/ -r "true" -s "true"
output:
detection times = 5
Average Interation Times = 0
Averaget Detection time (in ms) = 0
There are output folders created named after the .jpg files, but they are empty.
How do I solve this?