This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Bloomsday app ## | |
library(shiny) ; library(leaflet) ; library(timevis) | |
data <- data.frame( | |
id = sample(seq(20, 50, by=1), 18, replace=FALSE), | |
content = c("Telemachus", | |
"Nestor", | |
"Proteus", | |
"Calypso", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(jsonlite) | |
# df <- jsonlite::fromJSON(txt="https://data.police.uk/api/crimes-street/all-crime?lat=53.444853&lng=-2.278289&date=2017-02") | |
df <- jsonlite::fromJSON(txt="https://data.police.uk/api/crimes-street/all-crime?poly=52.268,0.543:52.794,0.238:52.130,0.478&date=2017-02") | |
df$location$longitude <- as.numeric(as.character(df$location$longitude)) | |
df$location$latitude <- as.numeric(as.character(df$location$latitude)) | |
library(tidyverse) | |
df %>% | |
count(category) %>% | |
ggplot(aes(x = reorder(category, n), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
plot <- starwars %>% | |
mutate(name, bmi = mass / ((height / 100) ^ 2)) %>% | |
ggplot(aes(x = bmi)) + | |
geom_histogram(fill = "#fc6721", alpha = 0.8, binwidth = 10) + | |
scale_x_continuous(expand = c(0, 0), limits=c(0, 450)) + | |
labs(x = "Body Mass Index [kg/m^2]", y = NULL, | |
title = "BMI distribution for Star Wars characters") | |
plot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plot + | |
# remove the background | |
theme(panel.background = element_blank()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plot + | |
theme(panel.background = element_blank(), | |
# hide all the axis tick marks | |
axis.ticks = element_blank()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plot + | |
theme(panel.background = element_blank(), | |
axis.ticks = element_blank(), | |
# hide the minor grid lines | |
panel.grid.minor = element_blank(), | |
# hide vertical major grid lines | |
panel.grid.major.x = element_blank(), | |
# change colour and thickness of horizontal grid lines | |
panel.grid.major.y = element_line(colour = "#757575", size = 0.3)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plot + | |
theme(panel.background = element_blank(), | |
axis.ticks = element_blank(), | |
panel.grid.minor = element_blank(), | |
panel.grid.major.x = element_blank(), | |
panel.grid.major.y = element_line(colour = "#757575", size = 0.3), | |
# change the title colour, font and alignment | |
plot.title = element_text(colour = "#2c7fb8", size = 14, face = "bold", h = 0), | |
# change the colour and font of the axis labels | |
axis.title = element_text(colour = "#212121", size = 10)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
theme_demo <- function () { | |
theme_grey() %+replace% | |
theme(panel.background = element_blank(), | |
axis.ticks = element_blank(), | |
panel.grid.minor = element_blank(), | |
panel.grid.major.x = element_blank(), | |
panel.grid.major.y = element_line(colour = "#757575", size = 0.3), | |
plot.title = element_text(colour = "#2c7fb8", size = 14, face = "bold", h = 0), | |
axis.title = element_text(colour = "#212121", size = 10)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source("https://trafforddatalab.github.io/assets/theme/ggplot2/theme_lab.R") | |
starwars %>% | |
mutate(name, bmi = mass / ((height / 100) ^ 2)) %>% | |
ggplot(aes(x = bmi)) + | |
geom_histogram(fill = "#fc6721", alpha = 0.8, binwidth = 10) + | |
scale_x_continuous(expand = c(0, 0), limits=c(0, 450)) + | |
labs(x = "Body Mass Index [kg/m^2]", y = NULL, | |
title = "BMI distribution for Star Wars characters") + | |
theme_lab() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: cc-by-4.0 | |
height: 500 | |
scrolling: no | |
border: yes |
OlderNewer