shiny example apps not running - r

I just installed shiny in RStudio and tried to run the example apps with runExample()
e.g. runExample("01_hello") but all I get as output is just the title, some input box and then the script code of the app.r, no plot though. In the console just a bunch of error messages:
Warning: Error in .Call: "_httpuv_decodeURIComponent" not available for .Call() for package "httpuv"
Stack trace (innermost first):
1: runApp
Can you see the problem from the picture?
Thanks a lot.

Thank you, #hpesoj626 the httpuv package was installed in my R version, indeed, it just needed an update. So I resolved the problem by updating the httpuv package. On a side note, I'm just wondering why having clicked the option "Install dependencies" (RStudio -> Tools -> Install packages...) does not include the newest versions (updated packages) of dependencies needed for the actual package to run correctly? How am I as a user supposed to know what packages (dependencies) that e.g. shiny needs to run, need an update? Anyway, thank you both again for your interest.

Related

install.packages() not working on R-Portable-Mac with electron-quick-start

I want to create a standalone app from my shiny app in R. My shiny app works correctly and I have followed the instructions in this link https://github.com/COVAIL/electron-quick-start/ I have been able to create the example app it is in the folder provided by COVAIL.
The problem comes when I try to install the required packages for my real app in shiny. I open the R-Portable.Mac/bin R executable and try to install the different packages I need (for example ggplot2). The thing is it appears the error message shown in the image
I tried installing rlang itself but it is not being installed. I have used .libPaths() to make sure the path is ok and it is. Can it be that the Portable-Mac-R is an old version and that is the reason why the packages are not being installed? I have also read that people were having issues with packages that required compilation.
As an example I could install dplyr but ggplot2 and shiny busy not.
Any ideas or suggestions?
Thank you in advance.
Edited: The output when I try to install ggplot2 (if I write no the land message won't appear but it is not installed)
and this is the whole output when trying to install rlang

R Studio 1.1.456 (Windows): Why do I sometimes have to install binary packages instead of installing from the source?

I am asking this question because I recently solved a problem installing R Shiny (see below). However, the answers I find don't expand in detail about why this problem occurs and I really want to understand to improve my knowledge of R and why these things happen.
So my attempt to install Shiny in RStudio failed and I believe these are the important error messages:
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
namespace 'httpuv' 1.3.3 is being loaded, but >= 1.4.3 is required
ERROR: lazy loading failed for package 'shiny'
* removing 'C:/Program Files/R/R-3.2.2/library/shiny'
* restoring previous 'C:/Program Files/R/R-3.2.2/library/shiny'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-32~1.2/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.2.2\library" C:\Users\Sam\AppData\Local\Temp\RtmpuI3XHe/downloaded_packages/shiny_1.1.0.tar.gz' had status 1
Warning in install.packages :
installation of package ‘shiny’ had non-zero exit status
I went through the usual processes first to find a solution.
Checked my RStudio was up to date
Checked for and installed package updates
Among the further solutions I tried were:
Downloading the package directly from the R Studio interface
Using devtools to install Shiny from Github
Using install.packages("shiny", dependencies=TRUE).
None of these solutions worked and I believe it is to do with the dependency httpuv, but I'm not sure why.
So in the end the code I was able to use is: install.packages('shiny', type = "binary") and this allowed me to begin using Shiny.
While it wasn't too difficult for me to find a work around for this problem, I would really appreciate someone taking some time out of their day to explain why my version of RStudio in Windows (Version 1.1.456) doesn't support the source package of Shiny and why installing the binary package works. I hate fixing an issue but having zero understanding of it.
R version 3.2.2
Thank you.
Binary versus Source Code Options and Issue
You are experiencing the push-pull friction between the old and new code and R environment dependencies. The reality here is you have to choose between stability and progress. It is difficult to have both.
Consider:
You are running R version 3.2.2 in binary form, that R version was released on August 15th 2015. Yet, you are trying to install the latest source code version of Shiny.
There is a 3-year delta between the package source code version and R version you are using. The package code and R environment source code have evolved.
A lot of changes have occurred between then and now in the compile and source code environment.
Think of it this way.
The binary package image is a snapshot of the compile and source code environment assumptions at the time of compilation. If you download the current source code image you are using a snapshot of the current code environment (Now) which includes literally thousands of small incremental changes to the assumptions and dependencies in the source code files and compile environment. if you look in the shiny package description you note:
Shiny depends on httpuv which depends on Rcpp
httpuv is built on top of the libuv and http-parser C libraries.
To get httpuv to compile from source you'll need to match the R Environment, the dependent libraries and source dependencies manually. No small feat.
Case in point to compile the above packages from source code (github) you'll likely be using Devtools which if you download in binary form was compiled under R version 3.2.5.
The changes, assumptions and inter-dependencies make for a complex backport compile situation. Hence, the advantage of binary package snapshots.
Options:
In this situation, you generally have two options. You can either:
Download a source version that is old that matches your R version and environment.
The downside of this approach is you cannot access current package features.
The upside is that the package and R environment match historical context.
Upgrade to a current R environment
The downside of this approach is you have to roll with the R releases.
The upside is that you get to gain access to the latest package features made available in the current source code.
Solution Options:
How to do the above? In the first case, you might use devtools::install_git and pull the source for a particular branch or version of a package and compile it. In the second, you can upgrade your environment, and then pull and upgrade your packages.
If you want to work off a particular R environment version you have to use the binary versions. Why? These will match the R environment version coding environment assumptions.
This is a classic problem highlighting the push-pull between current code and old code. You have to choose between stability and progress. It is difficult to have both.
I hope the above helps explain the situation.

R Shiny - Error: there is no package called ‘shinyjs’

My app works perfectly when I run it locally, but when I host it in shinyapps.io this error comes out:
An error has occurred
The application failed to start.
Error in value[3L] : there is no package called ‘shinyjs’
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> Anonymous
I have two more apps online with the same ui.R and server.R layouts and both work fine. Even if I avoid the code involving shinyjs, it shows the app in the browser but the same error appears in the app log with the package openxlsx. The other two almost-identical apps working perfect got me completely lost.
In my experience, the issue happens in RStudio projects with a DESCRIPTION file, when the offending package (e.g. shinyjs) is NOT included in the Imports section of the DESCRIPTION file.
I know this answer is late but in case is useful, here it is:
1.- Open a terminal and run: sudo R
2.- I installed shinyjs: install.packages("shinyjs", dependencies=TRUE)
3.- Create shinyjs directory: mkdir /usr/local/lib/R/site-library/shinyjs
4.- cd /usr/local/lib/R/site-library/shinyjs
4.- copy the shinyjs folder from the active username home R directory:
cp /home/username/R/x86_64-pc-linux-gnu-library/3.5/shinyjs/* -r .
Go to your web browsers and it will open your app.
Note. Be sure to change username for correct value and remember to set the privileges.
When you deploy your app on shinyapps.io the serve has to understand where the packages were installed from. The two most common sources of package installations probably are:
CRAN
Github
Looking at the documentation you see that Github packages must be installed with devtools. I have had the same issue you face because I had packages installed with remotes or pak, simply reinstall the packages locally you need using either install.packages for CRAN versions and devtools for dev versions and re-deploy:
install.packages("openxlsx")
# install.packages("devtools")
devtools::install_github("daattali/shinyjs")

error in using shinyserver

I have run shinyAPP in server, some APP doesn't work and error message show as picture, I don't know how to solve it.
It seems there is no dplyr package installed in the library used by the R process which your shiny server is using.
from browser console:
Listening on http://127.0.0.1:56037
Warning: Error in library: there is no package called ‘dplyr’
Stack trace (innermost first):
38: library
1: runApp
Error in library(dplyr) : there is no package called ‘dplyr’
Ensure that you have the package installed in the library folder used by shiny server.
E.g. in my case I have separate R used by RStudio so that development is separated from live app.
My library sits in usr//lib64//R//library therefore in linux i will run R as superuser sudo R and then install.packages("dplyr", lib="usr//lib64//R//library//")

Installed package (Dygraphs) not detected by my Shiny Application (R)

I am facing a problem that you might already have seen : I am trying to create a Shiny app using dygraphs. But, for the first time, when I call the library(dygraphs), in my ui.R file, I get an error :
ERROR: there is no package called ‘dygraphs’
I checked whether it was correctly installed on my server :
installed.packages() gives me the line :
OS_type MD5sum NeedsCompilation Built
dygraphs NA NA "no" "3.2.1"
require(dygraphs) gives me :
Loading required package: dygraphs
I have the same version of R on my computer and my server, which is :
R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
And, the weirdest thing : my code works on my computer (with runApp() on Rstudio), but not on my server.
If anyone know how to cope with this problem... Thanks a bunch !
I found the solution, it's possible to see the dependencies of a package with CRAN : https://cran.r-project.org/web/packages/dygraphs/index.html
And eventually, the following line does the trick !
install.packages(c("htmlwidgets","xts","zoo","rmarkdown","yaml","dygraphs"),lib="/usr/local/lib/R/site-library",dependencies=TRUE)
Enjoy :)

Resources