output | ||||
---|---|---|---|---|
|
This guide will help you deploy a Shiny dashboard that displays book usage metrics. You will need a GitHub account, a Docker account and a ShinyApps.io account.
- You'll need Docker installed. You can get it here. A helpful guide to using Docker and R is available here.
- Next, clone/fork the Github repository.
- At this stage, the dashboard will require a file named
metrics.csv
to replace to sample data. It should be added to thedata
folder. This.csv
file should contain at least five named columns:
measure_id
(all measures are listed here; an example ishttps://metrics.operas-eu.org/classics-library/sessions/v1
)timestamp
(as date, formatted asyyyy-mm-dd
)work_uri
(asinfo:doi:theDOIof/thework.ofinterest
)country_uri
(asurn:isso:std:3166:-2:XX
where XX is the 2-letter iso code)value
(a number, representing number of views/downloads, etc.)
- From the command line, set your directory to the folder you downloaded from Github. It must contain the
Dockerfile
. - Now run
docker build --rm --force-rm -t rstudio/hirmeos .
. Note the full stop. This will build your Docker image, which will contain a stable version of R, RStudio and the tidyverse package. You can check that it worked by runningdocker image list
. - We want the
data
folder to be available inside the container; that way we can import and export our data easily. To do this, first setDATA_DIR=${PWD}/data
, then spin up an instance of RStudio by runningdocker run -d --rm -p 28787:8787 --name hirmeos-dashboard -e USERID=$UID -e PASSWORD=hirmeos -v $DATA_DIR:/home/rstudio/data rstudio/hirmeos
- You can now use RStudio by opening your browser and visiting the address
127.0.0.1:28787
. The username isrstudio
and the password, as set above, ishirmeos
. You can set the password to whatever you like. - With RStudio now open, there are two optional steps:
- If your file
metrics.csv
included DOIs but not titles, you can retrieve the titles by runningsource(get_metadata.R)
in the console. This will edit your.csv
and append titles data. - In future, if you need altimetric data (like tweets), you will be able to call
source(get_altmetrics.R)
in the console; this will write a new file calledaltmetrics.csv
.
- Now you're ready to run the app. Still in RStudio (in your browser), open app.R. At the top-right of the script, hit
Run App
(or click the drop-down and selectRun in Window
). You may be prompted that the browser prevented a pop-up. Allow pop-up windows for this address, and check that the app is working normally. If a new page opens but saysConnection refused
, close your browser windows, access127.0.0.1:28787
in a new window, and try again. - From within the app, you can press
Publish
in the top-right corner. If prompted to download some extra packages to allow this, do so. You will then be guided through the steps to publish the app. Only publish theapp.R
script, thedata
folder and any logos in thewww
folder. Sign into your ShinyApps.io account and follow the prompts to get a token. Once you give RStudio the token, the app will be deployed at your url. Simply visit the url and verify that it works.
And that should be all! To stop the container, go back to the command line and run docker stop hirmeos-dashboard
.