Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
gulinan committed Jan 2, 2022
1 parent 3489d08 commit 589364a
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 104 deletions.
Binary file modified .DS_Store
Binary file not shown.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# Week_13_14_Lecture_Notes

# Week_13_14_Lecture_Notes: Building Interactive Web Applications

There is one `.Rmd/html` file to follow:

- `intro_rshiny.Rmd/intro_rshiny.html`.
5 changes: 3 additions & 2 deletions countries-01/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ library(shiny)
library(tidyverse)

## read data -------------------------------------------------------------------
countries_data <- read_csv("/Users/gulinan/Desktop/Introduction to Data Science with R/Week_13-14/Week13_Lecture_Notes/source_files/data/countries_1998_2011.csv")
countries_data <-
read_csv("/Users/gulinan/Desktop/MAT381E_Introduction to Data Science/Week_13-14/Week_13_14_Lecture_Notes/data/countries_1998_2011.csv")

## subset data
countries_data_2011 <- countries_data %>%
Expand Down Expand Up @@ -49,7 +50,7 @@ server <- function(input, output) {
## output is a reserved word.
## countries_scatter is given by me.
## input has two parts: x_axis and y_axis
## renderPlot({expr}): Renders a reactive plot that is suitable for assigning to an output slot.
## renderPlot({expr}): Renders a reactive plot that is suitable for assigning to an output plot.
## expr: An expression that generates a plot.

output$countries_scatter <- renderPlot({
Expand Down
3 changes: 2 additions & 1 deletion countries-02/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ library(shiny)
library(tidyverse)

## read data -------------------------------------------------------------------
countries_data <- read_csv("/Users/gulinan/Desktop/Introduction to Data Science with R/Week_13-14/Week13_Lecture_Notes/source_files/data/countries_1998_2011.csv")
countries_data <-read_csv("/Users/gulinan/Desktop/MAT381E_Introduction to Data Science/Week_13-14/Week_13_14_Lecture_Notes/data/countries_1998_2011.csv")


## subset data
countries_data_2011 <- countries_data %>%
Expand Down
2 changes: 1 addition & 1 deletion countries-03/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ library(shiny)
library(tidyverse)

## read data -------------------------------------------------------------------
countries_data <- read_csv("/Users/gulinan/Desktop/Introduction to Data Science with R/Week_13-14/Week13_Lecture_Notes/source_files/data/countries_1998_2011.csv")
countries_data <-read_csv("/Users/gulinan/Desktop/MAT381E_Introduction to Data Science/Week_13-14/Week_13_14_Lecture_Notes/data/countries_1998_2011.csv")

## subset data
countries_data_2011 <- countries_data %>%
Expand Down
2 changes: 1 addition & 1 deletion countries-04/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ library(tidyverse)
library(DT)

## read data -------------------------------------------------------------------
countries_data <- read_csv("/Users/gulinan/Desktop/Introduction to Data Science with R/Week_13-14/Week13_Lecture_Notes/source_files/data/countries_1998_2011.csv")
countries_data <-read_csv("/Users/gulinan/Desktop/MAT381E_Introduction to Data Science/Week_13-14/Week_13_14_Lecture_Notes/data/countries_1998_2011.csv")

## subset data
countries_data_2011 <- countries_data %>%
Expand Down
2 changes: 1 addition & 1 deletion countries-05/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ library(tidyverse)
library(DT)

## read data -------------------------------------------------------------------
countries_data <- read_csv("/Users/gulinan/Desktop/Introduction to Data Science with R/Week_13-14/Week13_Lecture_Notes/source_files/data/countries_1998_2011.csv")
countries_data <-read_csv("/Users/gulinan/Desktop/MAT381E_Introduction to Data Science/Week_13-14/Week_13_14_Lecture_Notes/data/countries_1998_2011.csv")

## subset data
countries_data_2011 <- countries_data %>%
Expand Down
2 changes: 1 addition & 1 deletion countries-06/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ library(DT)
library(plotly)

## read data -------------------------------------------------------------------
countries_data <- read_csv("/Users/gulinan/Desktop/Introduction to Data Science with R/Week_13-14/Week13_Lecture_Notes/source_files/data/countries_1998_2011.csv")
countries_data <-read_csv("/Users/gulinan/Desktop/MAT381E_Introduction to Data Science/Week_13-14/Week_13_14_Lecture_Notes/data/countries_1998_2011.csv")

## subset data
countries_data_2011 <- countries_data %>%
Expand Down
2 changes: 1 addition & 1 deletion countries-07/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ library(plotly)

# we are not doing any sub-setting on data here.

countries_data <- read_csv("/Users/gulinan/Desktop/Introduction to Data Science with R/Week_13-14/Week13_Lecture_Notes/source_files/data/countries_1998_2011.csv")
countries_data <-read_csv("/Users/gulinan/Desktop/MAT381E_Introduction to Data Science/Week_13-14/Week_13_14_Lecture_Notes/data/countries_1998_2011.csv")


## UI ##########################################################################
Expand Down
2 changes: 1 addition & 1 deletion countries-08/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ library(tidyverse)
library(plotly)

## read data -------------------------------------------------------------------
countries_data <- read_csv("/Users/gulinan/Desktop/Introduction to Data Science with R/Week_13-14/Week13_Lecture_Notes/source_files/data/countries_1998_2011.csv")
countries_data <-read_csv("/Users/gulinan/Desktop/MAT381E_Introduction to Data Science/Week_13-14/Week_13_14_Lecture_Notes/data/countries_1998_2011.csv")


## UI ##########################################################################
Expand Down
2 changes: 1 addition & 1 deletion countries-09/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ library(plotly)
library(shinythemes)

## read data -------------------------------------------------------------------
countries_data <- read_csv("/Users/gulinan/Desktop/Introduction to Data Science with R/Week_13-14/Week13_Lecture_Notes/source_files/data/countries_1998_2011.csv")
countries_data <-read_csv("/Users/gulinan/Desktop/MAT381E_Introduction to Data Science/Week_13-14/Week_13_14_Lecture_Notes/data/countries_1998_2011.csv")

## numeric columns to plot
numeric_columns <- c("human_development_index", "corruption_perception_index",
Expand Down
49 changes: 49 additions & 0 deletions denemefall21/app.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#

library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(

# Application title
titlePanel("Old Faithful Geyser Data"),

# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),

# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)

# Define server logic required to draw a histogram
server <- function(input, output) {

output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)

# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}

# Run the application
shinyApp(ui = ui, server = server)
Binary file added images/hdi_index.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 14 additions & 46 deletions intro_rshiny.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -52,46 +52,6 @@ class: left
* Introduction to `Shiny` package.
* Examples.


---
#### <span style="color:red"> Some important notes on Interim report</span>
<p>
<ul>
<li> State your aim and provide some information on your topic.</li>
<li> Provide information on your data set (do not expect us to understand your data) and tells us about the variables in your data set.</li>
<li> Tells us where you obtained your data (access link etc) and save your data set in your R project, so that we can see the content.</li>
<li> If you use abbreviations, be sure that you have given the long form of the abbreviation at your first mention.</li>
<li> Do not use abbreviations such as "we'll do". Use the full form, such as "we will do".</li>
<li> In addition to outputs, include your codes in the report as well.</li>
<li> Turn off warnings and messages (warning=F, message=F).</li>
<li> Align your code vertically, not horizontally. If it does not fit into a line, break down it into smaller pieces at appropriate places. </li>
<li> Do not try to give too much information with a single graphic. It is overwhelming. Instead, use faceting (side-by-side small graphs).</li>
<li> Do not forget to put x-axis title, y-axis title, main title. Graphics should be
informative.</li>
<li> Explain the graphics with a few sentences in your report. </li>
<li> Have a visualization style and be consistent throughout the report.</li>
<li> Do not use default ggplot2 colors. Try out different palettes for object colors and background colors.</li>
<li> If you mention something at the introduction such as "we will do this", then show it in the report. Otherwise, omit it.</li>
<li> In conclusion, shortly summarize your aim and findings.</li>
<li> In the end this is a report!..It should be appealing for people to read it!..</li>
</ul> </p>
---
#### **Office Hours**

- May 31, 2021 between 20:30-22:30.
- June 7, 2021 between 20:30-22:30.
- June 14, 2021 between 20:30-22:30.
- June 21, 2021 between 20:30-22:30.

#### **Zoom meeting link details**:


[Join Zoom Meeting](https://itu-edu-tr.zoom.us/j/99088059412?pwd=bTNZcElreWd3Z1MyS0hvVnpLOEdrQT09)

Meeting ID: 990 8805 9412
Passcode: 396830


---

- Please visit the [NASA Earth Data's Covid-19 Dashboard](
Expand All @@ -110,14 +70,14 @@ knitr::include_graphics("logo/rshiny.png")

---
#### Shiny package
- [`Shiny`](https://shiny.rstudio.com/) is an `R` package that provides elegant and powerful web framework for **building interactive web applications (apps)** directly from `R`.
- [R Shiny](https://shiny.rstudio.com/) is an `R` package that provides elegant and powerful web framework for **building interactive web applications (apps)** directly from `R`.
- You can host standalone apps on a **webpage** or build **dashboards**.
- Shiny applications are automatically live and outputs change instantly as users modify inputs, without requiring a reload of the browser.
- You can also extend your Shiny apps with [CSS themes](http://rstudio.github.io/shinythemes/?_ga=2.128822476.1106871023.1621587722-51308884.1621587722), [htmlwidgets](http://www.htmlwidgets.org/), and [JavaScript](https://github.com/daattali/shinyjs/blob/master/README.md) actions.
- To install and load the package:

```{r, eval=F}
install.packages("shiny")
```{r}
#install.packages("shiny")
library(shiny)
```

Expand Down Expand Up @@ -449,7 +409,7 @@ server <- function(input, output) {



- Each `render*()` function takes a single argument: an `R expression` surrounded by braces {} and and do some light pre-processing on the expression.
- Each `render*()` function takes a single argument: an `R expression` surrounded by braces {} and do some light pre-processing on the expression.

---
- The `R expression` can be one simple line of text, or it can involve many lines of code, as if it were a complicated function call.
Expand Down Expand Up @@ -529,6 +489,10 @@ shinyApp(ui = ui, server = server)

- <span style="color:purple">**The Human Development Index (HDI)** is a summary measure of average achievement in key dimensions of human development: a long and healthy life, being knowledgeable and have a decent standard of living. The HDI is the geometric mean of normalized indices for each of the three dimensions.</span>

```{r, echo=FALSE, out.width="100%"}
knitr::include_graphics("images/hdi_index.png")
```

---

class: middle, center
Expand All @@ -555,7 +519,7 @@ View(data)

---
#### Example: Countries-01
- Filter the data for the year 2011 and develop a `Shiny` app which enables to select one of variables **human_development_index**, **corruption_perception_index**, **population**, **life_exp**, and **gdp_per_capita** through a `input widget` to plot the selected variable on the horizontal axis and also enables to select another variable through another `input widget` to plot that selected variable on the vertical axis.
- Filter the data for the year 2011 and develop a `Shiny` app which enables to select one of variables **human_development_index**, **corruption_perception_index**, **population**, **life_exp**, and **gdp_per_capita** through an `input widget` to plot the selected variable on the horizontal axis and also enables to select another variable through another `input widget` to plot that selected variable on the vertical axis.
- Afterwards, get a scatter plot of the selected two variables and identify the points by their **continent type** by assigning different **colors**.

---
Expand Down Expand Up @@ -1038,7 +1002,11 @@ on this selection, create `SliderInput` widgets for "pct_noba", "pct_rent", "med
---
class: middle, center

<span style="color:purple">WISH YOU A GOOD WINTER BREAK!..☃️</span>
<span style="color:purple">WISH YOU A GOOD FINAL EXAM WEEK & WINTER BREAK!..</span>

<br>

✏️ 📚 ☃️


Expand Down
60 changes: 13 additions & 47 deletions intro_rshiny.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>MAT381E-Week 13-14: Building Interactive Web Applications</title>
<meta charset="utf-8" />
<meta name="author" content="Gül İnan" />
<meta name="date" content="2022-01-01" />
<meta name="date" content="2022-01-02" />
<script src="intro_rshiny_files/header-attrs-2.11/header-attrs.js"></script>
<link href="intro_rshiny_files/remark-css-0.0.1/default.css" rel="stylesheet" />
<script src="intro_rshiny_files/fabric-4.3.1/fabric.min.js"></script>
Expand All @@ -26,7 +26,7 @@
# MAT381E-Week 13-14: Building Interactive Web Applications
### Gül İnan
### Department of Mathematics<br/>Istanbul Technical University
### January 1, 2022
### January 2, 2022

---

Expand All @@ -47,46 +47,6 @@
* Introduction to `Shiny` package.
* Examples.


---
#### &lt;span style="color:red"&gt; Some important notes on Interim report&lt;/span&gt;
&lt;p&gt;
&lt;ul&gt;
&lt;li&gt; State your aim and provide some information on your topic.&lt;/li&gt;
&lt;li&gt; Provide information on your data set (do not expect us to understand your data) and tells us about the variables in your data set.&lt;/li&gt;
&lt;li&gt; Tells us where you obtained your data (access link etc) and save your data set in your R project, so that we can see the content.&lt;/li&gt;
&lt;li&gt; If you use abbreviations, be sure that you have given the long form of the abbreviation at your first mention.&lt;/li&gt;
&lt;li&gt; Do not use abbreviations such as "we'll do". Use the full form, such as "we will do".&lt;/li&gt;
&lt;li&gt; In addition to outputs, include your codes in the report as well.&lt;/li&gt;
&lt;li&gt; Turn off warnings and messages (warning=F, message=F).&lt;/li&gt;
&lt;li&gt; Align your code vertically, not horizontally. If it does not fit into a line, break down it into smaller pieces at appropriate places. &lt;/li&gt;
&lt;li&gt; Do not try to give too much information with a single graphic. It is overwhelming. Instead, use faceting (side-by-side small graphs).&lt;/li&gt;
&lt;li&gt; Do not forget to put x-axis title, y-axis title, main title. Graphics should be
informative.&lt;/li&gt;
&lt;li&gt; Explain the graphics with a few sentences in your report. &lt;/li&gt;
&lt;li&gt; Have a visualization style and be consistent throughout the report.&lt;/li&gt;
&lt;li&gt; Do not use default ggplot2 colors. Try out different palettes for object colors and background colors.&lt;/li&gt;
&lt;li&gt; If you mention something at the introduction such as "we will do this", then show it in the report. Otherwise, omit it.&lt;/li&gt;
&lt;li&gt; In conclusion, shortly summarize your aim and findings.&lt;/li&gt;
&lt;li&gt; In the end this is a report!..It should be appealing for people to read it!..&lt;/li&gt;
&lt;/ul&gt; &lt;/p&gt;
---
#### **Office Hours**

- May 31, 2021 between 20:30-22:30.
- June 7, 2021 between 20:30-22:30.
- June 14, 2021 between 20:30-22:30.
- June 21, 2021 between 20:30-22:30.

#### **Zoom meeting link details**:


[Join Zoom Meeting](https://itu-edu-tr.zoom.us/j/99088059412?pwd=bTNZcElreWd3Z1MyS0hvVnpLOEdrQT09)

Meeting ID: 990 8805 9412
Passcode: 396830


---

- Please visit the [NASA Earth Data's Covid-19 Dashboard](
Expand All @@ -101,15 +61,15 @@

---
#### Shiny package
- [`Shiny`](https://shiny.rstudio.com/) is an `R` package that provides elegant and powerful web framework for **building interactive web applications (apps)** directly from `R`.
- [R Shiny](https://shiny.rstudio.com/) is an `R` package that provides elegant and powerful web framework for **building interactive web applications (apps)** directly from `R`.
- You can host standalone apps on a **webpage** or build **dashboards**.
- Shiny applications are automatically live and outputs change instantly as users modify inputs, without requiring a reload of the browser.
- You can also extend your Shiny apps with [CSS themes](http://rstudio.github.io/shinythemes/?_ga=2.128822476.1106871023.1621587722-51308884.1621587722), [htmlwidgets](http://www.htmlwidgets.org/), and [JavaScript](https://github.com/daattali/shinyjs/blob/master/README.md) actions.
- To install and load the package:


```r
install.packages("shiny")
#install.packages("shiny")
library(shiny)
```

Expand Down Expand Up @@ -427,7 +387,7 @@



- Each `render*()` function takes a single argument: an `R expression` surrounded by braces {} and and do some light pre-processing on the expression.
- Each `render*()` function takes a single argument: an `R expression` surrounded by braces {} and do some light pre-processing on the expression.

---
- The `R expression` can be one simple line of text, or it can involve many lines of code, as if it were a complicated function call.
Expand Down Expand Up @@ -507,6 +467,8 @@

- &lt;span style="color:purple"&gt;**The Human Development Index (HDI)** is a summary measure of average achievement in key dimensions of human development: a long and healthy life, being knowledgeable and have a decent standard of living. The HDI is the geometric mean of normalized indices for each of the three dimensions.&lt;/span&gt;

&lt;img src="images/hdi_index.png" width="100%" /&gt;

---

class: middle, center
Expand Down Expand Up @@ -547,7 +509,7 @@

---
#### Example: Countries-01
- Filter the data for the year 2011 and develop a `Shiny` app which enables to select one of variables **human_development_index**, **corruption_perception_index**, **population**, **life_exp**, and **gdp_per_capita** through a `input widget` to plot the selected variable on the horizontal axis and also enables to select another variable through another `input widget` to plot that selected variable on the vertical axis.
- Filter the data for the year 2011 and develop a `Shiny` app which enables to select one of variables **human_development_index**, **corruption_perception_index**, **population**, **life_exp**, and **gdp_per_capita** through an `input widget` to plot the selected variable on the horizontal axis and also enables to select another variable through another `input widget` to plot that selected variable on the vertical axis.
- Afterwards, get a scatter plot of the selected two variables and identify the points by their **continent type** by assigning different **colors**.

---
Expand Down Expand Up @@ -1004,7 +966,11 @@
---
class: middle, center

&lt;span style="color:purple"&gt;WISH YOU A GOOD WINTER BREAK!..☃️&lt;/span&gt;
&lt;span style="color:purple"&gt;WISH YOU A GOOD FINAL EXAM WEEK &amp; WINTER BREAK!..&lt;/span&gt;

&lt;br&gt;

✏️ 📚 ☃️



Expand Down

0 comments on commit 589364a

Please sign in to comment.