Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add initial tutorial for shiny #982

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
* [Create a Streamlit site](tutorials/getting-started-streamlit/02-create-streamlit-site.md)
* [Launch, edit and delete a Streamlit site](tutorials/getting-started-streamlit/03-launch-streamlit-site.md)
* [Conclusion](tutorials/getting-started-streamlit/04-conclusion.md)
* [My first Shiny site](tutorials/getting-started-shiny/README.md)
* [Getting ready](tutorials/getting-started-shiny/01-getting-ready.md)
* [Create a Shiny site](tutorials/getting-started-shiny/02-create-shiny-site.md)
* [Launch a Shiny site](tutorials/getting-started-shiny/03-launch-shiny-site.md)
* [Delete a Shiny site](tutorials/getting-started-shiny/04-delete-shiny-site.md)
* [Conclusion](tutorials/getting-started-shiny/05-conclusion.md)
* [Packrat Quick-Start Guide](tutorials/packrat.md)
* [Conda Environments Quick-Start-Guide](tutorials/conda_environments.md)
* [Minio Browser](tutorials/minio-browser.md)
Expand Down
Binary file added docs/src/img/create-shiny-app-created.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/img/create-shiny-app-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/img/create-shiny-delete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/img/create-shiny-project-in-rstudio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/img/create-shiny-project-type.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/img/create-shiny-site-created.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/img/create-shiny-site.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions docs/src/tutorials/getting-started-shiny/01-getting-ready.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 1. Getting Ready

[Shiny][shiny] is an open source R package that provides an elegant and powerful web
framework for building web applications using R. Before continuing, you will need the
following:

[shiny]: https://shiny.posit.co/

* A project
* Project storage
* A RStudio Notebook

For tutorials on the above, see:

* [My First Notebook](../my-first-notebook/)
* [My first RStudio project](../getting-started-rstudio/)

This code will produce a simple dashboard with some controls that change a scatter plot.
65 changes: 65 additions & 0 deletions docs/src/tutorials/getting-started-shiny/02-create-shiny-site.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# 2. Create a Shiny site

In this section you will create a Shiny site.

Starting point: you should be logged in to DataLabs, in a project you have admin
permissions for. This project should contain a blank RStudio notebook.

In order to begin, open your RStudio notebook and create a new project ensuring
to select "Shiny". This will trigger some actions like initialising renv and may
take a few minutes.

![create shiny project type](../../img/create-shiny-project-type.png "create shiny project type")

***NOTE: When working on more advanced Shiny sites that use custom packages, you
should always enable `renv` when you create the RStudio project. This will track
all dependencies used in the project, and they can be loaded by the Shiny site once
it has been created by initialising `renv` in the Shiny code itself. While this isn't
required for this minimal example, generally it's advisable to work this way.***

![create shiny project](../../img/create-shiny-project-in-rstudio.png "create shiny project")

Once complete, this should have generated a new folder with an existing `app.R`
file in which serves as a good example on how to work with Shiny.

![shiny project created](../../img/create-shiny-app-example.png "shiny project created")

Next from DataLabs, on the left-hand side, select **Sites**.

![site page](../../img/project-site-page-empty.png "site page")

Select **Create Site** and fill out the form. In this form, the `Source Path`
should point to where your app.R code exists within your Project Storage,
for example `/data/notebooks/rstudio-notebook/tutorial`. (Assuming the project
created in RStudio was called tutorial).

When creating a site you can select a visibility status depending on the target
audience. These are as follows;

* Private - This option should be chosen when working alone with no need to share
access to the site.
* Project - When you wish to share access to the site with others within the project
in which you are working.
* Public - If you wish there to be no authentication in place - allowing you to share
access with the site with anyone on the internet.

Note that if you wish to change the visibility status after the notebook this is also
possible.

At this stage it is also possible to attach assets to your site, see
[this page](../../howto/use-the-asset-repo/) for further information.

By default, the Shiny site will look for app.R or main.R/server.R. If nothing
is present it will simply show a blank index page. The site will still be able to
access other files in the directory if necessary, such as data files and
scripts.

![shiny site settings](../../img/create-shiny-site.png "shiny site settings")

When happy with the settings, click **Create**.

Once created, you will be able to see your Site appear in the list, and
its status will change from `Requested` to `Ready` once it is available to
launch.

![shiny site created](../../img/create-shiny-site-created.png "shiny site created")
17 changes: 17 additions & 0 deletions docs/src/tutorials/getting-started-shiny/03-launch-shiny-site.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 3. Launch Shiny

In this section you will launch a Shiny site.

Starting point: you should be logged in to DataLabs, in a project you have at least
viewer permissions for. This project should contain a Shiny site connected to a
RStudio notebook.

On the left-hand side, select **Sites**.

![shiny site created](../../img/create-shiny-site-created.png "shiny site created")

Click on **Open** on your Shiny site.

![shiny site created](../../img/create-shiny-app-created.png "shiny site created")

You should be able to see the default Shiny example histogram successfully loaded.
17 changes: 17 additions & 0 deletions docs/src/tutorials/getting-started-shiny/04-delete-shiny-site.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 4. Delete Shiny site

In this section you will delete a Shiny site.

As sites are driven by the contents of a notebook and doesn't contain the code
itself, they can be deleted when they are no longer needed.

Starting point: you should be logged in to DataLabs, in a project you have admin
permissions for, and a Shiny site should already exist.

![shiny site created](../../img/create-shiny-site-created.png "shiny site created")

On the Shiny site, select the triple-dot *More* menu and select **Delete**.

![shiny site delete](../../img/create-shiny-delete.png "shiny site delete")

Select **Confirm deletion** to delete the Shiny site.
13 changes: 13 additions & 0 deletions docs/src/tutorials/getting-started-shiny/05-conclusion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 5. Conclusion

__Congratulations!__

In this tutorial, you have:

* Created a Shiny site linked to a notebook.
* Launched the site and used its interactive elements.
* Deleted the Shiny site.

__Where next?__

To learn more about Shiny, visit <https://shiny.posit.co/>
12 changes: 12 additions & 0 deletions docs/src/tutorials/getting-started-shiny/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# My first Shiny Site

In this tutorial you will create a *[Shiny][shiny]* site within Datalabs, allowing you to
visualise and interact with a notebook.

[shiny]: https://shiny.posit.co/

1. [Getting ready](01-getting-ready.md)
2. [Create a Shiny site](02-create-shiny-site.md)
3. [Launch Shiny](03-launch-shiny-site.md)
4. [Delete Shiny site](04-delete-shiny-site.md)
5. [Conclusion](05-conclusion.md)
Loading