123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512 |
- status == "healthy" && mammogram == "+ve" ~ "incorrect"),
- status = fct_reorder(status,"healthy"))
- d <- tibble::tibble(age = age,
- status = c(rep("cancer", n*p_cancer),
- rep("healthy", n*(1-p_cancer))),
- mammogram = c(rep("+ve", n_c_p ),
- rep("-ve", n_c_n ),
- rep("+ve", n_h_p ) ,
- rep("-ve", n_h_n ))
- )
- d <- d %>%
- mutate(diagnosis = case_when(status == "cancer" && mammogram == "+ve" ~ "correct",
- status == "cancer" && mammogram == "-ve" ~ "incorrect",
- status == "healthy" && mammogram == "-ve" ~ "correct",
- status == "healthy" && mammogram == "+ve" ~ "incorrect"),
- status = fct_reorder(status,"healthy"))
- g1 <- ggplot(d, aes(area = age, fill = status)) +
- geom_treemap(layout="fixed") + scale_fill_brewer()
- g2 <- ggplot(d, aes(area = age, fill = mammogram)) +
- geom_treemap(layout="fixed") + scale_fill_brewer()
- g1
- g2
- g1 <- ggplot(d, aes(area = age, fill = status)) +
- geom_treemap() + scale_fill_brewer()
- g2 <- ggplot(d, aes(area = age, fill = mammogram)) +
- geom_treemap() + scale_fill_brewer()
- g1
- g2
- d <- d %>%
- mutate(diagnosis = case_when(status == "cancer" && mammogram == "+ve" ~ "correct",
- status == "cancer" && mammogram == "-ve" ~ "incorrect",
- status == "healthy" && mammogram == "-ve" ~ "correct",
- status == "healthy" && mammogram == "+ve" ~ "incorrect"),
- status = fct_reorder(status,"healthy", "cancer"),
- diagnosis = fct_reorder(status,"-ve", "+ve"))
- d <- d %>%
- mutate(diagnosis = case_when(status == "cancer" && mammogram == "+ve" ~ "correct",
- status == "cancer" && mammogram == "-ve" ~ "incorrect",
- status == "healthy" && mammogram == "-ve" ~ "correct",
- status == "healthy" && mammogram == "+ve" ~ "incorrect"),
- status = fct_reorder(status,"healthy", "cancer"),
- diagnosis = fct_reorder(diagnosis,"-ve", "+ve"))
- d <- tibble::tibble(age = age,
- status = c(rep("cancer", n*p_cancer),
- rep("healthy", n*(1-p_cancer))),
- mammogram = c(rep("+ve", n_c_p ),
- rep("-ve", n_c_n ),
- rep("+ve", n_h_p ) ,
- rep("-ve", n_h_n ))
- )
- d <- d %>%
- mutate(diagnosis = case_when(status == "cancer" && mammogram == "+ve" ~ "correct",
- status == "cancer" && mammogram == "-ve" ~ "incorrect",
- status == "healthy" && mammogram == "-ve" ~ "correct",
- status == "healthy" && mammogram == "+ve" ~ "incorrect"),
- status = fct_reorder(status,"healthy", "cancer"),
- mammogram = fct_reorder(mammpgram,"-ve", "+ve"))
- #
- library(tidyverse)
- library(ggbeeswarm)
- # library(cowplot)
- library(treemapify)
- n <- 1000
- age <- base::sample(35:45, n, replace=TRUE)
- p_cancer <- 0.01
- p_test_positive <- 0.8
- p_test_false_positive <- 0.1
- n_cancer <- n*p_cancer
- n_c_p <- n_cancer*p_test_positive
- n_c_n <- n_cancer - n_c_p
- n_h_p <- (n-n_cancer)*p_test_false_positive
- n_h_n <- (n-n_cancer) - n_h_p
- d <- tibble::tibble(age = age,
- status = c(rep("cancer", n*p_cancer),
- rep("healthy", n*(1-p_cancer))),
- mammogram = c(rep("+ve", n_c_p ),
- rep("-ve", n_c_n ),
- rep("+ve", n_h_p ) ,
- rep("-ve", n_h_n ))
- )
- d <- d %>%
- mutate(diagnosis = case_when(status == "cancer" && mammogram == "+ve" ~ "correct",
- status == "cancer" && mammogram == "-ve" ~ "incorrect",
- status == "healthy" && mammogram == "-ve" ~ "correct",
- status == "healthy" && mammogram == "+ve" ~ "incorrect"),
- status = fct_reorder(status,"healthy", "cancer"),
- mammogram = fct_reorder(mammpgram,"-ve", "+ve"))
- ?fct_relevel
- d <- d %>%
- mutate(diagnosis = case_when(status == "cancer" && mammogram == "+ve" ~ "correct",
- status == "cancer" && mammogram == "-ve" ~ "incorrect",
- status == "healthy" && mammogram == "-ve" ~ "correct",
- status == "healthy" && mammogram == "+ve" ~ "incorrect"),
- status = fct_relevel(status,"healthy", "cancer"),
- mammogram = fct_relevel(mammpgram,"-ve", "+ve"))
- d <- d %>%
- mutate(diagnosis = case_when(status == "cancer" && mammogram == "+ve" ~ "correct",
- status == "cancer" && mammogram == "-ve" ~ "incorrect",
- status == "healthy" && mammogram == "-ve" ~ "correct",
- status == "healthy" && mammogram == "+ve" ~ "incorrect"),
- status = fct_relevel(status,"healthy", "cancer"),
- mammogram = fct_relevel(mammogram,"-ve", "+ve"))
- g1 <- ggplot(d, aes(area = age, fill = status)) +
- geom_treemap() + scale_fill_brewer()
- g2 <- ggplot(d, aes(area = age, fill = mammogram)) +
- geom_treemap() + scale_fill_brewer()
- g1
- g2
- g3 <- ggplot(d, aes(area = age, fill = diagnosis)) +
- geom_treemap() + scale_fill_brewer(palette = "Set2")
- g3
- d <- d %>%
- mutate(diagnosis = case_when(status == "cancer" & mammogram == "+ve" ~ "correct",
- status == "cancer" & mammogram == "-ve" ~ "incorrect",
- status == "healthy" & mammogram == "-ve" ~ "correct",
- status == "healthy" & mammogram == "+ve" ~ "incorrect"),
- status = fct_relevel(status,"healthy", "cancer"),
- mammogram = fct_relevel(mammogram,"-ve", "+ve"))
- g3 <- ggplot(d, aes(area = age, fill = diagnosis)) +
- geom_treemap() + scale_fill_brewer(palette = "Set2")
- g3
- g3 <- ggplot(d, aes(area = age, group, status, fill = diagnosis)) +
- geom_treemap() + scale_fill_brewer(palette = "Set2")
- g3
- g3 <- ggplot(d, aes(area = age, group= status, fill = diagnosis)) +
- geom_treemap() + scale_fill_brewer(palette = "Set2")
- g3
- g3 <- ggplot(d, aes(area = age, group= status, fill = diagnosis)) +
- geom_treemap(layout="fixed") + scale_fill_brewer(palette = "Set2")
- g3
- g3 <- ggplot(d, aes(area = age, color= status, fill = diagnosis)) +
- geom_treemap(layout="fixed") + scale_fill_brewer(palette = "Set2")
- g3
- g3 <- ggplot(d, aes(area = age, width= status, fill = diagnosis)) +
- geom_treemap(layout="fixed") + scale_fill_brewer(palette = "Set2")
- g3
- ?geom_treemap
- g3 <- ggplot(d, aes(area = age, alpha= status, fill = diagnosis)) +
- geom_treemap(layout="fixed") + scale_fill_brewer(palette = "Set2")
- g3
- g1
- g2
- g3
- ?ggsave()
- ggsave("plot1.pdf", g1)
- ggsave("plot2.pdf", g2)
- ggsave("plot3.pdf", g3)
- source('~/OneDrive - The University of Nottingham/teaching/2019-tutorials/2019-11-17-bayes/bayes-bee-plot.R', echo=TRUE)
- ggsave("plot1.png", g1)
- ggsave("plot2.png", g2)
- ggsave("plot3.png", g3)
- #
- colorPalette <- "Set3"
- g1 <- ggplot(d, aes(area = age, fill = status)) +
- geom_treemap() + scale_fill_brewer(palette = colorPalette)
- g2 <- ggplot(d, aes(area = age, fill = mammogram)) +
- geom_treemap() + scale_fill_brewer(palette = colorPalette)
- g3 <- ggplot(d, aes(area = age, alpha=status, fill = diagnosis)) +
- geom_treemap(layout="fixed") + scale_fill_brewer(palette = "Set2") +
- scale_alpha_discrete(range = c(0.3, 1.o))
- g3 <- ggplot(d, aes(area = age, alpha=status, fill = diagnosis)) +
- geom_treemap(layout="fixed") + scale_fill_brewer(palette = "Set2") +
- scale_alpha_discrete(range = c(0.3, 1.0))
- ggsave("plot1.png", g1)
- ggsave("plot2.png", g2)
- ggsave("plot3.png", g3)
- ?scale_fill_brewer
- #
- colorPalette <- "Accent"
- g1 <- ggplot(d, aes(area = age, fill = status)) +
- geom_treemap() + scale_fill_brewer(palette = colorPalette)
- g2 <- ggplot(d, aes(area = age, fill = mammogram)) +
- geom_treemap() + scale_fill_brewer(palette = colorPalette)
- g3 <- ggplot(d, aes(area = age, alpha=status, fill = diagnosis)) +
- geom_treemap(layout="fixed") + scale_fill_brewer(palette = "Set2") +
- scale_alpha_discrete(range = c(0.3, 1.0))
- ggsave("plot1.png", g1)
- ggsave("plot2.png", g2)
- #
- colorPalette <- "Dark2"
- g1 <- ggplot(d, aes(area = age, fill = status)) +
- geom_treemap() + scale_fill_brewer(palette = colorPalette)
- g2 <- ggplot(d, aes(area = age, fill = mammogram)) +
- geom_treemap() + scale_fill_brewer(palette = colorPalette)
- ggsave("plot1.png", g1)
- ggsave("plot2.png", g2)
- #
- colorPalette <- "Pastel1"
- g1 <- ggplot(d, aes(area = age, fill = status)) +
- geom_treemap() + scale_fill_brewer(palette = colorPalette)
- g2 <- ggplot(d, aes(area = age, fill = mammogram)) +
- geom_treemap() + scale_fill_brewer(palette = colorPalette)
- ggsave("plot1.png", g1)
- ggsave("plot2.png", g2)
- #
- colorPalette <- "Set3"
- g1 <- ggplot(d, aes(area = age, fill = status)) +
- geom_treemap() + scale_fill_brewer(palette = colorPalette)
- g2 <- ggplot(d, aes(area = age, fill = mammogram)) +
- geom_treemap() + scale_fill_brewer(palette = colorPalette)
- ggsave("plot1.png", g1)
- ggsave("plot2.png", g2)
- #
- colorPalette <- "Set1"
- g1 <- ggplot(d, aes(area = age, fill = status)) +
- geom_treemap() + scale_fill_brewer(palette = colorPalette)
- g2 <- ggplot(d, aes(area = age, fill = mammogram)) +
- geom_treemap() + scale_fill_brewer(palette = colorPalette)
- ggsave("plot1.png", g1)
- ggsave("plot2.png", g2)
- g1 <- ggplot(d, aes(area = age, fill = status)) +
- geom_treemap() + scale_fill_brewer()
- ggsave("plot1.png", g1)
- g2 <- ggplot(d, aes(area = age, fill = mammogram)) +
- geom_treemap() + scale_fill_brewer()
- ggsave("plot1.png", g1)
- ggsave("plot2.png", g2)
- g3 <- ggplot(d, aes(area = age, alpha=status, fill = diagnosis)) +
- geom_treemap(layout="fixed") + scale_fill_brewer(palette = "Set2") +
- scale_alpha_discrete(range = c(0.6, 1.0))
- ggsave("plot3.png", g3)
- install.packages("reticulate")
- library(reticulate)
- use_python("/usr/local/bin/python3")
- reticulate::repl_python()
- knitr::opts_chunk$set(echo = TRUE)
- library(reticulate)
- use_python("/usr/local/bin/python3")
- summary(cars)
- library(tidyverse)
- ?qplot
- qplot(speed, distance, cars)
- glimpse(cars)
- qplot(speed, distance, data=cars)
- qplot(speed, dist, data=cars)
- cars
- with(cars, lm(dist~speed))
- install.packages("matlabr")
- install.packages("reticulate")
- library("reticulate")
- Sys.which("python")
- library(reticulate)
- use_python("/usr/local/bin/python3")
- repl_python()
- plumber::plumb(file='r/speech-to-text/api/define_api.R')$run()
- plumber::plumb(file='r/speech-to-text/api/define_api.R')$run()
- plumber::plumb(file='r/speech-to-text/api/define_api.R')$run()
- plumber::plumb(file='r/speech-to-text/api/define_api.R')$run()
- plumber::plumb(file='r/speech-to-text/api/define_api.R')$run()
- plumber::plumb(file='r/speech-to-text/api/define_api.R')$run()
- plumber::plumb(file='r/speech-to-text/api/define_api.R')$run()
- plumber::plumb(file='r/speech-to-text/api/define_api.R')$run()
- install.packages("tidyverse")
- install.packages("tidyverse")
- plumber::plumb(file='r/speech-to-text/api/define_api.R')$run()
- plumber::plumb(file='r/speech-to-text/api/define_api.R')$run()
- plumber::plumb(file='r/speech-to-text/api/define_api.R')$run()
- plumber::plumb(file='r/speech-to-text/api/define_api.R')$run()
- plumber::plumb(file='r/speech-to-text/api/define_api.R')$run()
- plumber::plumb(file='r/speech-to-text/api/define_api.R')$run()
- setwd()
- setwd('~')
- devtools::install_github('rstudio/bookdown')
- install.packages("gapminder")
- source('~/OneDrive - The University of Nottingham/teaching/_ug/2020-3rd-year-projects/example.R', echo=TRUE)
- 1+1
- "asf"
- 124*23
- meaningOfLife <- 42
- meaningOfLife * 2
- require(tidyverse)
- require(jsonlite)
- source("./perimetry_helpers.R")
- setwd("~/The University of Nottingham/Anthony's PhD Team - strkvis_pub_archive/strkvis-mri/code")
- require(tidyverse)
- require(jsonlite)
- source("./perimetry_helpers.R")
- # example file
- data_fname <- "../perimetry/sub-14196-perimetry-data.json"
- read_medmont(data_fname) %>%
- plot_medmont()
- plot_medmont <- function(the_points) {
- # NB-- the coord_polar step requires setting the starting point for 0 radians / 0 degrees...
- # to be offset from 12 o'clock
- the_points %>%
- mutate(
- xcoord = ecc * cos(pa),
- ycoord = ecc * sin(pa)
- ) %>%
- filter(State != "TS_UNTESTED") %>%
- ggplot(aes(x = ecc, y = pa, size = Value, symbol=State)) +
- geom_point(alpha = 0.9) +
- coord_fixed() +
- scale_colour_manual(values = c("red", "black", "gray")) + # "TS_SEEN" "TS_UNTESTED" "TS_NOT_SEEN"
- # coord_polar is kind of broken...
- # https://community.rstudio.com/t/making-coord-polar-behave-like-standard-polar-coordinate-plotting/3762/6
- # coord_polar(theta = "x", start = -pi/4, direction = -1) +
- theme_minimal()
- }
- read_medmont(data_fname) %>%
- plot_medmont()
- the_points %>%
- mutate(
- xcoord = ecc * cos(pa),
- ycoord = ecc * sin(pa)
- ) %>%
- filter(State != "TS_UNTESTED") %>%
- ggplot(aes(x = ecc, y = pa, size = Value, symbol=State)) +
- geom_point(alpha = 0.9) +
- coord_fixed() +
- scale_colour_manual(values = c("red", "black", "gray")) + # "TS_SEEN" "TS_UNTESTED" "TS_NOT_SEEN"
- # coord_polar is kind of broken...
- # https://community.rstudio.com/t/making-coord-polar-behave-like-standard-polar-coordinate-plotting/3762/6
- coord_polar(theta = "x", start = -pi/4, direction = -1) +
- theme_minimal()
- plot_medmont <- function(the_points) {
- # NB-- the coord_polar step requires setting the starting point for 0 radians / 0 degrees...
- # to be offset from 12 o'clock
- the_points %>%
- mutate(
- xcoord = ecc * cos(pa),
- ycoord = ecc * sin(pa)
- ) %>%
- filter(State != "TS_UNTESTED") %>%
- ggplot(aes(x = ecc, y = pa, size = Value, symbol=State)) +
- geom_point(alpha = 0.9) +
- coord_fixed() +
- scale_colour_manual(values = c("red", "black", "gray")) + # "TS_SEEN" "TS_UNTESTED" "TS_NOT_SEEN"
- # coord_polar is kind of broken...
- # https://community.rstudio.com/t/making-coord-polar-behave-like-standard-polar-coordinate-plotting/3762/6
- coord_polar(theta = "x", start = -pi/4, direction = -1) +
- theme_minimal()
- }
- read_medmont(data_fname) %>%
- plot_medmont()
- plot_medmont <- function(the_points) {
- # NB-- the coord_polar step requires setting the starting point for 0 radians / 0 degrees...
- # to be offset from 12 o'clock
- the_points %>%
- mutate(
- xcoord = ecc * cos(pa),
- ycoord = ecc * sin(pa)
- ) %>%
- filter(State != "TS_UNTESTED") %>%
- ggplot(aes(x = pa, y = ecc, size = Value, symbol=State)) +
- geom_point(alpha = 0.9) +
- # coord_fixed() +
- scale_colour_manual(values = c("red", "black", "gray")) + # "TS_SEEN" "TS_UNTESTED" "TS_NOT_SEEN"
- # coord_polar is kind of broken...
- # https://community.rstudio.com/t/making-coord-polar-behave-like-standard-polar-coordinate-plotting/3762/6
- coord_polar(theta = "x", start = -pi/4, direction = -1) +
- theme_minimal()
- }
- read_medmont(data_fname) %>%
- plot_medmont()
- coord_polar
- >coord_polar
- ?
- coord_polar
- plot_medmont <- function(the_points) {
- # NB-- the coord_polar step requires setting the starting point for 0 radians / 0 degrees...
- # to be offset from 12 o'clock
- the_points %>%
- mutate(
- xcoord = ecc * cos(pa),
- ycoord = ecc * sin(pa)
- ) %>%
- filter(State != "TS_UNTESTED") %>%
- ggplot(aes(x = pa, y = ecc, size = Value, symbol=State)) +
- geom_point(alpha = 0.9) +
- coord_fixed() +
- scale_colour_manual(values = c("red", "black", "gray")) + # "TS_SEEN" "TS_UNTESTED" "TS_NOT_SEEN"
- # coord_polar is kind of broken...
- # https://community.rstudio.com/t/making-coord-polar-behave-like-standard-polar-coordinate-plotting/3762/6
- coord_polar(theta = "x", start = -pi/4, direction = -1) +
- theme_minimal()
- }
- read_medmont(data_fname) %>%
- plot_medmont()
- plot_medmont(data)
- data <- read_medmont(data_fname)
- plot_medmont(data)
- the_points %>%
- mutate(
- pa_rad = pi * pa / 180.0,
- xcoord = ecc * cos(pa_rad),
- ycoord = ecc * sin(pa_rad)
- ) %>%
- filter(State != "TS_UNTESTED") %>%
- ggplot(aes(x = pa_rad, y = ecc, size = Value, symbol=State)) +
- geom_point(alpha = 0.9) +
- coord_fixed() +
- scale_colour_manual(values = c("red", "black", "gray")) + # "TS_SEEN" "TS_UNTESTED" "TS_NOT_SEEN"
- # coord_polar is kind of broken...
- # https://community.rstudio.com/t/making-coord-polar-behave-like-standard-polar-coordinate-plotting/3762/6
- coord_polar(theta = "x", start = -pi/4, direction = -1) +
- theme_minimal()
- data <- read_medmont(data_fname)
- plot_medmont(data)
- require(tidyverse)
- require(jsonlite)
- source("./perimetry_helpers.R")
- # example file
- data_fname <- "../perimetry/sub-14196-perimetry-data.json"
- data <- read_medmont(data_fname)
- plot_medmont(data)
- require(tidyverse)
- require(jsonlite)
- source("./perimetry_helpers.R")
- # example file
- data_fname <- "../perimetry/sub-14196-perimetry-data.json"
- data <- read_medmont(data_fname)
- #' convert medmont JSON to data frame
- #'
- #' returns
- #' list(result, the_points, d)
- #'
- read_medmont <- function(fname) {
- # get data
- j <- jsonlite::read_json(fname)
- d <- fromJSON(fname)
- # unpack what’s in JSON structure -----------------------------------------
- exam <- d$MedmontStudioExportFile[4]
- test <- exam$M600ThresholdExam$ThresholdTest$Test
- # e.g.
- # test$BlindSpot
- # Now look for the experiment data ----------------------------------------
- # test points are inside here
- n_points <- parse_integer(test$TestPoints$elements)
- the_points <- test$TestPoints$ThresholdTestPoint
- # exporting to CSV (tidy) style format --------------------------------------
- # this is how two write out a subset to CSV file...
- # make sure to take last set of measurements (if it's a list)
- # also length less than 5 (which is the right order of mag for ATTEMPTS, rather than points)
- # if there is only 1 test, a previous version of the check didn't seem to do the right thing/
- if (is_list(the_points) && length(the_points) < 5) {
- the_points <- the_points[[length(the_points)]]
- }
- result <- the_points %>%
- mutate(
- ecc = parse_double(Position$Ring),
- pa = parse_double(Position$Meridian),
- pa_rad = pi* pa / 180,
- Value = parse_double(Value)
- )
- }
- data <- read_medmont(data_fname)
- the_points %>%
- mutate(
- xcoord = ecc * cos(pa_rad),
- ycoord = ecc * sin(pa_rad)
- ) %>%
- filter(State != "TS_UNTESTED") %>%
- ggplot(aes(x = pa_rad, y = ecc, size = Value, symbol=State)) +
- geom_point(alpha = 0.9) +
- scale_colour_manual(values = c("red", "black", "gray")) + # "TS_SEEN" "TS_UNTESTED" "TS_NOT_SEEN"
- # coord_polar is kind of broken...
- # https://community.rstudio.com/t/making-coord-polar-behave-like-standard-polar-coordinate-plotting/3762/6
- coord_polar(theta = "x", start = -pi/4, direction = -1) +
- theme_minimal()
- ?coord_polar
- source("./perimetry_helpers.R")
- # example file
- data_fname <- "../perimetry/sub-14196-perimetry-data.json"
- data <- read_medmont(data_fname)
- plot_medmont(data)
- plot_medmont <- function(the_points) {
- # NB-- the coord_polar step requires setting the starting point for 0 radians / 0 degrees...
- # to be offset from 12 o'clock
- the_points %>%
- mutate(
- xcoord = ecc * cos(pa_rad),
- ycoord = ecc * sin(pa_rad)
- ) %>%
- filter(State != "TS_UNTESTED") %>%
- ggplot(aes(x = xcoord, y = ycoord, size = Value, symbol=State)) +
- geom_point(alpha = 0.9) +
- coord_fixed() +
- scale_colour_manual(values = c("red", "black", "gray")) + # "TS_SEEN" "TS_UNTESTED" "TS_NOT_SEEN"
- # coord_polar is kind of broken...
- # https://community.rstudio.com/t/making-coord-polar-behave-like-standard-polar-coordinate-plotting/3762/6
- # coord_polar(theta = "x", start = -pi/4, direction = -1) +
- theme_minimal()
- }
- source("./perimetry_helpers.R")
- # example file
- data_fname <- "../perimetry/sub-14196-perimetry-data.json"
- data <- read_medmont(data_fname)
- plot_medmont(data)
- plot_medmont <- function(the_points) {
- # NB-- the coord_polar step requires setting the starting point for 0 radians / 0 degrees...
- # to be offset from 12 o'clock
- the_points %>%
- mutate(
- xcoord = ecc * cos(pa_rad),
- ycoord = ecc * sin(pa_rad)
- ) %>%
- filter(State != "TS_UNTESTED") %>%
- ggplot(aes(x = xcoord, y = ycoord, size = Value, colour=State)) +
- geom_point(alpha = 0.9) +
- coord_fixed() +
- scale_colour_manual(values = c("red", "black", "gray")) + # "TS_SEEN" "TS_UNTESTED" "TS_NOT_SEEN"
- # coord_polar is kind of broken...
- # https://community.rstudio.com/t/making-coord-polar-behave-like-standard-polar-coordinate-plotting/3762/6
- # coord_polar(theta = "x", start = -pi/4, direction = -1) +
- theme_minimal()
- }
- plot_medmont(data)
- # example file
- data_fname <- "../perimetry/sub-14326-perimetry-data.json"
- data <- read_medmont(data_fname)
- plot_medmont(data)
|