Damiano Oldoni
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
      • No invitee
    • Publish Note

      Publish Note

      Everyone on the web can find and read all notes of this public team.
      Once published, notes can be searched and viewed by anyone online.
      See published notes
      Please check the box to agree to the Community Guidelines.
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
No invitee
Publish Note

Publish Note

Everyone on the web can find and read all notes of this public team.
Once published, notes can be searched and viewed by anyone online.
See published notes
Please check the box to agree to the Community Guidelines.
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# INBO CODING CLUB 6 October 2022 Welcome! ## Share your code snippet If you want to share your code snippet, copy paste your snippet within a section of three backticks (```): As an **example**: ``` library(tidyverse) ``` (*you can copy paste this example and add your code further down*) ## Yellow sticky notes No yellow sticky notes online. Put your name + " | " and add a "*" each time you solve a challenge (see below). ## Participants Name | Challenges --- | --- Damiano Oldoni | Lynn Pallemaerts |*** Cécile Herr |*** Hans Van Calster | * Sarah Broos| Adriaan Seynaeve | * Raïsa Carmen | *** Els Lommelen | Floris Vanderhaeghe | *** Wouter Van Landuyt Laura Marquez | * Toon Westra | *** ## Challenge 1 ### floris 3. `shinyApp(ui = ui, server = server)` 4. 5. `input` defined and generated by `sliderInput()` in `ui`, output defined by `renderPlot()` in the `server` function and picked up in `ui` by `plotOutput()` 6. Change the default `app.R` as follows: ```diff --- a/src/myfirstshinyapplication/app.R +++ b/src/myfirstshinyapplication/app.R @@ -37,13 +37,14 @@ server <- function(input, output) { output$distPlot <- renderPlot({ # generate bins based on input$bins from ui.R - x <- faithful[, 2] + x <- faithful[, 1] 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', - xlab = 'Waiting time to next eruption (in mins)', - main = 'Histogram of waiting times') + xlab = 'minutes', + ylab = 'number of eruptions', + main = 'Distribution of eruption times') }) } ``` 7. Change `app.R` as follows: ```diff --- a/src/myfirstshinyapplication/app.R +++ b/src/myfirstshinyapplication/app.R @@ -22,7 +22,7 @@ ui <- fluidPage( "Number of bins:", min = 1, max = 50, - value = 30) + value = 20) ), # Show a plot of the generated distribution ``` ## Challenge 2 ### floris Note that my solution uses an external folder for the data (the original data folder of the coding club project); this works but actually the app should be self-contained, i.e. have the data folder inside the app folder. <details><summary><code>app.R</code> (click to expand)</summary> ```r # # 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) butter <- read.csv("../../data/20221006/20221006_butterflies_data.txt") butter$species <- factor(butter$species) butter$biotope <- factor(butter$biotope) # Define UI for application that draws a histogram ui <- fluidPage( # Application title titlePanel("Butterflies in different biotopes"), # Sidebar with a slider input for number of bins sidebarLayout( sidebarPanel( radioButtons("buttons", "Biotope:", levels(butter$biotope)), selectInput("dropdown", "Species:", levels(butter$species)) ), # Show a plot of the generated distribution mainPanel( textOutput("textoutput") ) ) ) # Define server logic required to draw a histogram server <- function(input, output) { output$textoutput <- renderText( paste("You selected biotope", input$buttons, "and species", input$dropdown) ) } # Run the application shinyApp(ui = ui, server = server) ``` </details> ### Hans: ``` # # 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(tidyverse) ## CHALLENGE 3 # code to be on top of app.R # read dataset (path to be checked) butterfly_data <- read_csv(here::here("./data/20221006/20221006_butterflies_data.txt", na = "")) # biotopes biotopes <- unique(butterfly_data$biotope) # species sp <- unique(butterfly_data$species) biotopes_list <- as.list(biotopes) biotopes_list <- set_names(biotopes_list, biotopes) species_list <- as.list(sp) species_list <- set_names(species_list, sp) library(shiny) # Define UI for application that draws a histogram ui <- fluidPage( # Application title titlePanel("Butterflies biotope"), # Sidebar with a slider input for number of bins sidebarLayout( sidebarPanel( radioButtons("biotope", label = "Biotope", choices = biotopes_list), selectInput("species", label = "Species", choices = species_list) ), # Show a plot of the generated distribution mainPanel( textOutput("selected_choices") ) ) ) # Define server logic required to draw a histogram server <- function(input, output) { output$selected_choices <- renderText(sprintf("You have selected the biotope %s and the species %s", input$biotope, input$species)) } # Run the application shinyApp(ui = ui, server = server) ``` ## Challenge 3 ### Lynn: ```r library(shiny) library(tidyverse) df <- read_csv("./20221006_butterflies_data.txt", na = "") biotopes <- unique(df$biotope) sp <- unique(df$species) # Define UI for application that draws a histogram ui <- fluidPage( #Application title titlePanel("Butterfly biotopes"), #Sidebar input sidebarLayout(sidebarPanel(radioButtons(inputId = "btp", label = "Select biotope:", choices = c("Agriculture" = biotopes[1], "Forest" = biotopes[2], "Open" = biotopes[3], "Urban" = biotopes[4]), selected = character(0)), radioButtons(inputId = "sp", label = "Select species:", choices = c("Limenitis camilla" = sp[1], "Pararge aegeria" = sp[2]), selected = character(0))), #Main panel mainPanel(textOutput(outputId = "infoText"), plotOutput(outputId = "bioPlot"), tableOutput(outputId = "tbl"))) ) # Define server logic required to draw a histogram server <- function(input, output) { output$infoText <- renderText({ infoText <- paste0("You have selected the biotope ", input$btp, " and the species ", input$sp, ".") }) output$bioPlot <- renderPlot({ df %>% filter(species == input$sp, biotope == input$btp) %>% ggplot(aes(x = year, y = meanArea)) + geom_point() + geom_smooth() + labs(title = paste("Distribution of ", input$sp, "- biotope:", input$btp), y = "Area (%)") + facet_wrap(~ region) }) output$tbl <- renderTable({ df %>% filter(species == input$sp, biotope == input$btp) }, striped = T, bordered = T) } # Run the application shinyApp(ui = ui, server = server) ``` ### floris Change `app.R` from challenge 2 as follows: ```diff --- a/src/shinyapp_challenge_2_3/app.R +++ b/src/shinyapp_challenge_2_3/app.R @@ -8,6 +8,7 @@ # library(shiny) +library(ggplot2) butter <- read.csv("../../data/20221006/20221006_butterflies_data.txt") butter$species <- factor(butter$species) @@ -32,7 +33,7 @@ ui <- fluidPage( # Show a plot of the generated distribution mainPanel( - textOutput("textoutput") + plotOutput("plots") ) ) ) @@ -40,12 +41,19 @@ ui <- fluidPage( # Define server logic required to draw a histogram server <- function(input, output) { - output$textoutput <- renderText( - paste("You selected biotope", - input$buttons, - "and species", - input$dropdown) - ) + output$plots <- renderPlot({ + ggplot(subset(butter, + species == input$dropdown & + biotope == input$buttons), + aes(x = year, + y = meanArea)) + + geom_point() + + geom_smooth() + + labs(title = paste("Distribution of", input$dropdown, "in biotope", input$buttons), + y = "Area (%)") + + facet_wrap(~ region) + + }) } # Run the application ```

Import from clipboard

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template is not available.
Upgrade
All
  • All
  • Team
No template found.

Create custom template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

How to use Slide mode

API Docs

Edit in VSCode

Install browser extension

Get in Touch

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Upgrade to Prime Plan

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

No updates to save
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Upgrade

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Upgrade

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully