From ddb845c0e3775c718525c5fe7d26a0c04f1b7f49 Mon Sep 17 00:00:00 2001 From: Gammerdinger Date: Wed, 18 Sep 2024 11:59:13 -0400 Subject: [PATCH] Polish --- RShiny/lessons/03_visuals.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/RShiny/lessons/03_visuals.md b/RShiny/lessons/03_visuals.md index 208354e..5759650 100644 --- a/RShiny/lessons/03_visuals.md +++ b/RShiny/lessons/03_visuals.md @@ -33,13 +33,6 @@ output$ <- renderDT({ Let's use the built-in dataset `mtcars` to visualize an example of a data table within a Shiny app. -On the UI side: -* We are using the input function described earlier `checkboxGroupInput()`, which will allow users to select which columns to display from the table. -* We use the `DTOutput()` with "table" as the ID to correspond with the output object in the server side code - -On the server side: -* We use `renderDT()` and provide the mtcars dataframe, using square brackets to subset the columns selected. - ``` # User interface ui <- fluidPage( @@ -61,6 +54,13 @@ server <- function(input, output) { shinyApp(ui = ui, server = server) ``` +On the UI side: +* We are using the input function described earlier `checkboxGroupInput()`, which will allow users to select which columns to display in the table. +* We are using the `DTOutput()` funtion with "table" as the ID to correspond with the output object in the server side code + +On the server side: +* We use `renderDT()` and providing the mtcars dataframe, while using square brackets to subset the columns selected. + This will visualize in the app as:

@@ -69,7 +69,7 @@ This will visualize in the app as: ## Creating a plot -Creating plots is an essential skill for being able to create apps in Shin, and it is exciting because there are so many ways in which you can enhance the visualization. Let's begin with first demonstrating static plots using the `mtcars` dataset again. We will be using `ggplot2`, which is part of the `tidyverse` package, so we will need to load `tidyverse`: +Creating plots is an essential skill for being able to create apps in Shiny, and it is exciting because there are so many ways in which you can enhance the visualization. Let's begin with first demonstrating static plots using the `mtcars` dataset again. We will be using `ggplot2`, which is part of the `tidyverse` package, so we will need to load `tidyverse`: ``` library(tidyverse) @@ -91,7 +91,7 @@ output$ <- renderPlot({ }) ``` -In the example below we are using the `selectInput()` function to allow users to select from which column to display on the x-axis and y-axis. The choices given are the column names of the dataframe. +In the example below we are using the `selectInput()` function to allow users to select which columns to display on the x-axis and y-axis. The choices given are the column names of the dataframe. On the server side, we place ggplot2 code inside the `renderPlot()` function, specifying what type of plot we want to draw. The `aes_string()` function allows us to provide information stored in the input object as the x and y values. @@ -121,7 +121,7 @@ server <- function(input, output) { shinyApp(ui = ui, server = server) ``` -> Note: In this lesson we are using the package `ggplot2` to create our visualizations, but plots used in Shiny can also be made using the base R graphics or any other packages. +> Note: In this lesson, we are using the package `ggplot2` to create our visualizations, but plots used in Shiny can also be made using the base R graphics or any other packages. This sample code would look like: @@ -134,7 +134,7 @@ While the above plot was interesting for being able to select various metrics to ### Clicking -The first way that we can interact will a plot is by clicking a point on the plot. The syntax for this is a bit interesting because it has an `input` buried within an `Output` function. +The first way that we can interact with a plot is by clicking a point on the plot. The syntax for this is a bit interesting because it has an `input` buried within an `Output` function. On the UI side: @@ -189,7 +189,7 @@ This app would look like: ### Hover -Instead of clicking on points in your plot, you can instead simply hover over them and identify more information. In order to do this, we need to tweak the UI side of the app. +Instead of clicking on points in your plot, you can instead hover over them and identify more information. In order to do this, we need to tweak the UI side of the app. On the UI side: ``` @@ -233,7 +233,7 @@ This app would look like: ### Brush -The last way that you can make your plots interactive is with brushing. Perhaps you notice a cluster on points in one part of your scatter plot that you'd like to investigate further. Brushing allows you to **use a rectangle to select the points that you would like to interact with**. We need a make a few changes to our UI to accommodate brushing: +The last way that you can make your plots interactive is with brushing. Perhaps you notice a cluster of points in one part of your scatter plot that you'd like to investigate further. Brushing allows you to **use a rectangle to select the points that you would like to interact with**. We need a make a few changes to our UI to accommodate brushing: On the UI side: @@ -254,7 +254,7 @@ On the server side we need to use: ``` output$table <- renderDT({ - brushedPoints(mtcars, input$) + brushedPoints(, input$) }) ```