rmarkdown on shiny

201 views
Skip to first unread message

p...@unh.edu

unread,
May 13, 2018, 5:35:26 PM5/13/18
to shinyapps.io Users
Hi everyone,

To thoroughly understand shinyapps.io, I cloned the "Simple Example" from "R Markdown Websites," https://rmarkdown.rstudio.com/rmarkdown_websites.html#simple_example. I followed the step-by-step instructions given is the section called  "Site Authoring." 

Given the simplicity of the example, I expected no problems. While I was able to create a website locally, I was unable to create one with shinyapps.io

Along the way, I ran into Warnings, which I don't fully understand even after scouring the web for answers. I have listed my concerns below as Issue 12, ... 5. I did my best in correcting each issue, as shown below. I attached the code as a zip file. The code was modified slightly from the original one. These modifications were made to address issues after inspecting the R Markdown and shinyapps.io logs. 

 rsconnect::accountInfo("pjossen", server = NULL)
$name
[1] "pjossen"

$userId
[1] "149160"

$accountId
[1] "127657"

$token
[1] "22DB10541D0C9C6FCC50463E5B63591A"

$secret
[1] "ImAxWhorzkUJOcpvH3IeN36BYX4PPxy1dhHwgi16"

$server

devtools::session_info()
─ Session info ──────────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.4.4 (2018-03-15)
 os       macOS High Sierra 10.13.4   
 system   x86_64, darwin15.6.0        
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/New_York            
 date     2018-05-13                  

─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────
 package     * version     date       source                             
 assertthat    0.2.0       2017-04-11 CRAN (R 3.4.0)                     
 backports     1.1.2       2017-12-13 CRAN (R 3.4.3)                     
 bitops        1.0-6       2013-08-17 CRAN (R 3.4.0)                     
 callr         2.0.3-9000  2018-04-29 Github (r-lib/callr@f3ee85a)       
 cli           1.0.0.9002  2018-05-11 Github (r-lib/cli@18bbaa0)         
 clisymbols    1.2.0       2017-05-21 CRAN (R 3.4.0)                     
 crayon        1.3.4       2018-04-12 Github (gaborcsardi/crayon@95b3eae)
 debugme       1.1.0       2017-10-22 CRAN (R 3.4.2)                     
 desc          1.2.0       2018-05-01 CRAN (R 3.4.4)                     
 devtools      1.13.5.9000 2018-05-11 Github (hadley/devtools@13ee56b)   
 digest        0.6.15      2018-01-28 CRAN (R 3.4.3)                     
 evaluate      0.10.1      2017-06-24 CRAN (R 3.4.1)                     
 fansi         0.2.3       2018-05-06 CRAN (R 3.4.4)                     
 glue          1.2.0       2017-10-29 CRAN (R 3.4.2)                     
 hms           0.4.2       2018-03-10 CRAN (R 3.4.4)                     
 htmltools     0.3.6       2017-04-28 CRAN (R 3.4.0)                     
 knitr         1.20        2018-02-20 CRAN (R 3.4.3)                     
 magrittr      1.5         2014-11-22 CRAN (R 3.4.0)                     
 memoise       1.1.0       2017-04-21 CRAN (R 3.4.0)                     
 packrat       0.4.9-2     2018-04-20 CRAN (R 3.4.4)                     
 pkgbuild      1.0.0       2018-05-11 Github (r-lib/pkgbuild@0457039)    
 pkgconfig     2.0.1       2017-03-21 CRAN (R 3.4.0)                     
 pkgload       1.0.0       2018-05-11 Github (r-lib/pkgload@35efedd)     
 prettyunits   1.0.2       2015-07-13 CRAN (R 3.4.2)                     
 progress      1.2.0       2018-05-11 Github (r-lib/progress@a2678e8)    
 R6            2.2.2       2017-06-17 CRAN (R 3.4.0)                     
 Rcpp          0.12.16     2018-03-13 CRAN (R 3.4.4)                     
 RCurl         1.95-4.10   2018-01-04 CRAN (R 3.4.3)                     
 RJSONIO       1.3-0       2014-07-28 CRAN (R 3.4.0)                     
 rlang         0.2.0       2018-02-20 CRAN (R 3.4.3)                     
 rmarkdown     1.9.9       2018-04-29 Github (rstudio/rmarkdown@91d071f) 
 rprojroot     1.3-2       2018-01-03 CRAN (R 3.4.3)                     
 rsconnect     0.8.8       2018-05-12 Github (rstudio/rsconnect@bcdf9b9) 
 rstudioapi    0.7         2017-09-07 CRAN (R 3.4.1)                     
 selectr       0.4-1       2018-04-06 CRAN (R 3.4.4)                     
 sessioninfo   1.0.1.9000  2018-04-12 Github (r-lib/sessioninfo@c871d01) 
 stringi       1.2.2       2018-05-02 CRAN (R 3.4.4)                     
 stringr       1.3.1       2018-05-10 CRAN (R 3.4.4)                     
 testthat      2.0.0       2017-12-13 CRAN (R 3.4.3)                     
 usethis       1.3.0.9000  2018-05-11 Github (r-lib/usethis@bb191e9)     
 withr         2.1.2       2018-03-15 CRAN (R 3.4.4)                     
 xml2          1.2.0       2018-01-24 CRAN (R 3.4.2)                     
 yaml          2.1.19      2018-05-01 CRAN (R 3.4.4)                     


The front matter for the index.Rmd is as follows:

---
title: "My Website"
output: html_document
---

Hello, Website!

'Knit' is used.

```{r index}
# site: rmarkdown::render_site  Amanda suggestion gives /rmd_output/1/about.html not found
library(knitr)
library(rmarkdown)
library(shiny)
library(plumber)
```

The site.yml is as follows:

name: "my-website"
navbar:
  title: "My Website"
  left:
    - text: "Home"
      href: index.html
    - text: "About"
      href: about.html
output:
  html_document:
    highlight: textmate
    include:
      after_body: footer.html
    css: styles.css

Issue 1: Build Website Error

==> rmarkdown::render_site(encoding = 'UTF-8')

Error in rmarkdown::render_site(encoding = "UTF-8") : 
  No site generator found.
Execution halted
Exited with status 1.
'
This was a surprise because 'Knit' created a fully functional instance without issue locally. I ignored this issue.

Issue 2: unexpected INCOMPLETE_STRING

1. Use Global Options -> Disconnect -> Apply -> Okay

2. login using GitHub to obtain "pjossen"

3. Use Global Options -> Connect -> Copy Token -> Paste 

The downloaded source packages are in ‘/private/var/folders/1h/5nhp6jsd6jb3c7fz1n3rg3ph0000gp/T/Rtmppu3fCx/downloaded_packages’

Error in parse(text = accountCmd) : 

  <text>:1:92: unexpected INCOMPLETE_STRING

1: rsconnect::setAccountInfo(name='pjossen', token='22DB10541D0C9C6FCC50463E5B63591A', secret='ImAxWhorzkUJOcpvH3IeN36BYX4PPxy1dhHwgi16’)

2: 

I overcame this issue by Input Manually: 

rsconnect::setAccountInfo(name='pjossen', token='22DB10541D0C9C6FCC50463E5B63591A', secret='ImAxWhorzkUJOcpvH3IeN36BYX4PPxy1dhHwgi16')

4. rsconnect::deployApp()

Error in lint(appDir, appFiles, appPrimaryDoc) : 

  Cancelling deployment: invalid project layout.

The project should have one of the following layouts:

1. 'shiny.R' and 'ui.R' in the application base directory,

2. 'shiny.R' and 'www/index.html' in the application base directory,

3. 'app.R' or a single-file Shiny .R file,

4. An R Markdown (.Rmd) document,

5. A static HTML (.html) or PDF (.pdf) document.

6. 'plumber.R' API description .R file

7. 'entrypoint.R' plumber startup script

8. A tensorflow saved model

Remedy: an empty app.R file (Clearly, this step was never anticipated, given app.R was not part of the code that I cloned form GitHub.)

Preparing to deploy application...DONE

Uploading bundle for application: 342225...[WARNING] This document format requires a nonempty <title> element.

  Please specify either 'title' or 'pagetitle' in the metadata.

  Falling back to '_sessioninfo.utf8'

DONE

Deploying bundle: 1371482 for application: 342225 ...

Waiting for task: 525519911

  building: Parsing manifest

  building: Building image: 1384386

  building: Installing system dependencies

  building: Fetching packages

  building: Installing packages

  building: Installing files

  building: Pushing image: 1384386

  deploying: Starting instances

  rollforward: Activating new instances

  success: Stopping old instances

Application successfully deployed to https://pjossen.shinyapps.io/rmarkdown-website-examples-master/

Issue 3: app.R did not return a shiny.appobj object

shinyapps.io log

Error in value[[3L]](cond) : app.R did not return a shiny.appobj object.

2018-05-13T15:16:57.658906+00:00 shinyapps[342225]: Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>


Issue 4: Error in rsconnect::deploySite() :

5. rsconnect::deploySite()

Error in rsconnect::deploySite() : 

  index file with site entry not found in /Users/PJO/Desktop/rmarkdown-website-examples-master

Remedies

6. rsconnect::appDependencies

Uploading bundle for application: 342225...[WARNING] This document format requires a nonempty <title> element.

  Please specify either 'title' or 'pagetitle' in the metadata.

  Falling back to '_sessioninfo.utf8'

Note "plumber" installed

rsconnect::deploySite()

Error in value[[3L]](cond) : app.R did not return a shiny.appobj object.

2018-05-13T15:16:57.658906+00:00 shinyapps[342225]: Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>


Issue 5: [WARNING] This document format requires a nonempty <title> element. (I don't understand the warning or discussion that I discovered on the web.)

7. rsconnect::deployApp(appDir = getwd(),  account = "pjossen", server = "shinyapps.io", upload = TRUE,  launch.browser = "rsconnect.launch.browser", lint = TRUE,  metadata = list())

https://pjossen.shinyapps.io/rmarkdown-website-examples-master/? [Y/n] y

DONE

Uploading bundle for application: 342225...[WARNING] This document format requires a nonempty <title> element.

  Please specify either 'title' or 'pagetitle' in the metadata.

  Falling back to '_sessioninfo.utf8'

DONE

Deploying bundle: 1371563 for application: 342225 ...

Waiting for task: 525526607

  building: Parsing manifest

  building: Building image: 1384459

  building: Installing system dependencies

  building: Fetching packages

  building: Installing packages

  building: Installing files

  building: Pushing image: 1384459

  deploying: Starting instances

  rollforward: Activating new instances

  unstaging: Stopping old instances

Application successfully deployed to https://pjossen.shinyapps.io/rmarkdown-website-examples-master/

shinyapps.io log

2018-05-13T16:17:03.667702+00:00 shinyapps[342225]: knitr version: 1.20

2018-05-13T16:17:03.667617+00:00 shinyapps[342225]: Server version: 1.6.2-2

2018-05-13T16:17:03.667657+00:00 shinyapps[342225]: LANG: en_US.UTF-8

2018-05-13T16:17:03.667713+00:00 shinyapps[342225]: jsonlite version: 1.5

2018-05-13T16:17:03.667714+00:00 shinyapps[342225]: RJSONIO version: 1.3.0

2018-05-13T16:17:03.667670+00:00 shinyapps[342225]: R version: 3.4.4

2018-05-13T16:17:03.896902+00:00 shinyapps[342225]: 

2018-05-13T16:17:03.896904+00:00 shinyapps[342225]: Starting R with process ID: '92'

2018-05-13T16:17:03.667715+00:00 shinyapps[342225]: htmltools version: 0.3.6

2018-05-13T16:17:03.667672+00:00 shinyapps[342225]: shiny version: 1.0.5

2018-05-13T16:17:03.667701+00:00 shinyapps[342225]: rmarkdown version: 1.9.9

2018-05-13T16:17:03.807550+00:00 shinyapps[342225]: Using jsonlite for JSON processing

2018-05-13T16:17:03.956220+00:00 shinyapps[342225]: Error in value[[3L]](cond) : app.R did not return a shiny.appobj object.

2018-05-13T16:17:03.956221+00:00 shinyapps[342225]: Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>

2018-05-13T16:17:03.956222+00:00 shinyapps[342225]: Execution halted


Obviously, I am overlooking something. Adding app.R does not seem right to me. Especially, when it does not resolve the issue.

Any help will be greatly appreciated.
Paul

Message has been deleted

p...@unh.edu

unread,
May 14, 2018, 4:36:23 PM5/14/18
to shinyapps.io Users
I have worked on the code described above. After simplifying it, shinyapps.io creates a website, but it is not the kind of website that I want. I want the ability to click on the Home and About menu buttons and have them successfully open. 


For some reason, the Home and About menu items appear but produce rubbish. In fact, these two items should not appear at all. My code does not call for them. Somewhere behind the scenes, these menu items are created. I don't understand why.

Any comments would be appreciated.

Thanks,
Paul

Joshua Spiewak

unread,
May 15, 2018, 5:40:13 PM5/15/18
to shinyapps.io Users
You may be confusing RStudio Connect and shinyapps.io in several of your attempts.
Furthermore, app.R is for Shiny applications and should not be involved in an RMarkdown that is using the Shiny runtime, as it will confuse the detection of what kind of application you are attempting to deploy.

That said, have you tried starting with the examples that center on RMarkdown and Shiny?

I would suggest posting on the Community site for follow up with particular questions about how RMarkdown and Shiny work together if the interactive example linked above does get you where you want to be.

Joshua Spiewak

unread,
May 16, 2018, 9:48:56 AM5/16/18
to shinyapps.io Users
To be clear here, the purpose of shinyapps.io is to host Shiny applications. When that application is actually RMarkdown, shinyapps.io will treat it as an RMarkdown Shiny document and use rmarkdown::run to launch it. If you use that command locally, you should encounter exactly the same situation as when you deploy to shinyapps.io.

If you are simply looking for a way to host the static output of rendering a non-interactive RMarkdown site, you might be better off pursuing GitHub Pages or Netlify.
Reply all
Reply to author
Forward
0 new messages