Skip to content

Commit 78f94c5

Browse files
committed
brissy workshop
1 parent f476f82 commit 78f94c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+145351
-0
lines changed

Brissy_girls/.DS_Store

6 KB
Binary file not shown.

Brissy_girls/brissy_wildlife.zip

3.59 MB
Binary file not shown.
6 KB
Binary file not shown.

Brissy_girls/brissy_wildlife/app.R

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#
2+
# This is a Shiny web application. You can run the application by clicking
3+
# the 'Run App' button above.
4+
#
5+
# Find out more about building applications with Shiny here:
6+
#
7+
# http://shiny.rstudio.com/
8+
#
9+
10+
# Load necessary packages
11+
library(shiny)
12+
library(shinydashboard)
13+
library(shinythemes)
14+
library(tidyverse)
15+
library(lubridate)
16+
library(tsibble)
17+
library(sugrrants)
18+
library(glue)
19+
library(bomrang)
20+
library(viridis)
21+
library(plotly)
22+
library(ggmap)
23+
library(ggthemes)
24+
25+
# Read map data
26+
load("data/brissy_map.rda")
27+
28+
# Read data, and create species list for menu, and create a date
29+
wildlife <- read_csv("data/brissy_ala.csv")
30+
species <- wildlife %>%
31+
select(`Vernacular name`) %>%
32+
distinct() %>%
33+
arrange(`Vernacular name`)
34+
wildlife <- wildlife %>%
35+
mutate(date = ymd(paste0(Year,Month,Day)))
36+
37+
# Define UI for application
38+
ui <- fluidPage(theme = shinytheme("flatly"),
39+
titlePanel("Exploring wildlife spotted around Brisbane"),
40+
tabsetPanel(
41+
# Set up the user interface for the calendar tab
42+
# to select variables to plot, labels and colouring
43+
tabPanel("Choose a species",
44+
# Sidebar choosing variables, labels and colour
45+
sidebarLayout(
46+
sidebarPanel(
47+
selectInput("species", "pick one", choices = species, selected = "Australian Brush-turkey")
48+
),
49+
50+
# Show the scatterplot, with a fixed height
51+
mainPanel(
52+
plotlyOutput("map", height="400px")
53+
)
54+
)
55+
),
56+
tabPanel("Choose a time period",
57+
# Sidebar choosing variables, labels and colour
58+
sidebarLayout(
59+
sidebarPanel(
60+
selectInput("species2", "pick one", choices = species, selected = "Australian Brush-turkey"),
61+
dateInput("from", "From:", value = ymd(min(wildlife$date))),
62+
dateInput("to", "To:", value = ymd(max(wildlife$date)))
63+
),
64+
65+
# Show the scatterplot, with a fixed height
66+
mainPanel(
67+
plotlyOutput("time", height="400px")
68+
)
69+
)
70+
)
71+
)
72+
)
73+
74+
server <- function(input, output) {
75+
76+
# Make the interactive scatterplot of occurrence on map
77+
output$map <- renderPlotly({
78+
# Filter to species of interest and plot locations
79+
wildlife_sub <- wildlife %>% filter(`Vernacular name` == input$species)
80+
p <- ggmap(brissy_map) +
81+
geom_point(data=wildlife_sub, aes(x=Longitude, y=Latitude, label=date),
82+
alpha=0.5, colour="orange") +
83+
ggtitle(paste(input$species, ": ", nrow(wildlife_sub))) +
84+
theme_map()
85+
ggplotly(p, tooltip = "label")
86+
})
87+
88+
# Make the interactive time series plot
89+
output$time <- renderPlotly({
90+
# Filter to species of interest, count number per day and plot over time
91+
wildlife_sub <- wildlife %>% filter(`Vernacular name` == input$species2)
92+
wildlife_count <- wildlife_sub %>% count(date) %>%
93+
filter(date >= input$from, date <= input$to)
94+
p2 <- ggplot(data=wildlife_count, aes(x=date, y=n, label=date)) +
95+
geom_point(colour="black", alpha=0.5) +
96+
geom_smooth(colour="orange", se=FALSE) +
97+
xlab("") + ylab("Number") +
98+
ggtitle(paste(input$species2, ": ", nrow(wildlife_sub)))
99+
ggplotly(p2, tooltip = c("label", "y"))
100+
})
101+
102+
}
103+
104+
# Run the application
105+
shinyApp(ui = ui, server = server)
106+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Version: 1.0
2+
3+
RestoreWorkspace: Default
4+
SaveWorkspace: Default
5+
AlwaysSaveHistory: Default
6+
7+
EnableCodeIndexing: Yes
8+
UseSpacesForTab: Yes
9+
NumSpacesForTab: 2
10+
Encoding: UTF-8
11+
12+
RnwWeave: Sweave
13+
LaTeX: pdfLaTeX
6 KB
Binary file not shown.

Brissy_girls/brissy_wildlife/data/brissy_ala.csv

+71,753
Large diffs are not rendered by default.
1010 KB
Binary file not shown.

Brissy_girls/sunny_tutorial/.DS_Store

6 KB
Binary file not shown.

Brissy_girls/sunny_tutorial/brissy_ala.csv

+71,753
Large diffs are not rendered by default.
1010 KB
Binary file not shown.
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.tutorialTitle:before {
2+
content: url("../images/forwards.png");
3+
display: block;
4+
}
Binary file not shown.
Loading
50.1 KB
Loading
Loading
10.5 KB
Loading
Loading
52.4 KB
Loading
69.2 KB
Loading
23.2 KB
Loading

Brissy_girls/sunny_tutorial/images/forwards.svg

+165
Loading
Loading
15 KB
Loading
13.5 KB
Loading
26.1 KB
Loading
Loading

0 commit comments

Comments
 (0)