Customising an existing Shiny App
Editing a Shiny App's source code
When you create a Shiny App in the workspace, a folder containing all the app's scripts and files is also created. You can view and edit the code by navigating to the Files tab and moving inside the folder named after your Shiny App. Note that any libraries that the Shiny App uses will need to be installed in the workspace R Console for that R version.
If you edit the source code while the Shiny App is running, you will see a notice reminding you to refresh the app in order for the changes to be applied.
Adding an image to your Shiny App tile
You can add an image to your Shiny App tile, this image must be saved directly in the Shiny App's folder and should be named 'tile.png'.
The recommended image size is 336 pixels by 150 pixels. Please note that the bottom 30 pixels will be covered by the action buttons.
If you add an image, the name of the Shiny App will no longer be visible on the tile. Thus, the image should include the name of the App.
The tile on the right shows the default Shiny App image. The tile on the left had a custom image added to its source code.
Shiny Apps and R versions
Shiny Apps can be set to run on a specific version of R. When creating a new Shiny App, you can choose which version of R you wish the Shiny App to run on. This will be specified in a .version
file saved in your Shiny App folder.
If you wish to change the version of R, edit the .version
file and save it. Note, the version you select must be available in your workspace. Additionally, if the version later becomes unavailable, the Shiny App will run on the default version of R unless you change the configuration in the .version
file.
The format of the R version can be any of the following (e.g. for R 4.1.1):
- 4.1.1
- r:4.1.1
Workspaces currently support 4.1.1, 4.0.2, and 3.6.3 (soon to be deprecated).
If you specify an incomplete version, such as 3.6, or a complete but non-available version, such as 3.6.6, the Shiny App will use the highest complete version available, such as 3.6.3.
Importing data into a Shiny App
As part of your Shiny App, you may wish to import files stored within your workspace. For CSV files, this can be done using readr library:
library(readr)
dataset <- read_csv("~/files/your_folder/file_name.csv")
You can also import database tables located in the workspace using the following function:
xap.read_table("table_name")
For more information, see the reading and writing data in R article.