This file contains hidden or 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
| tribble( | |
| ~Aus.City, ~Pop, | |
| "Sydney", "4920970", | |
| "Melbourne", "4529496", | |
| "Brisbane", "2308720", | |
| "Perth", "2039193", | |
| "Adelaide", "1316779", | |
| "Gold Coast", " 624918", | |
| "Newcastle", " 434454", | |
| "Canberra", " 424666" |
This file contains hidden or 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(tibble) | |
| library(ggplot2) | |
| library(dplyr) | |
| library(ggrepel) | |
| library(ggthemes) | |
| stackR <- tribble( | |
| ~Aus.City, ~R, ~TotalVisits, ~Pop, | |
| "Melbourne", "23176", "1544868", "4529496", | |
| "Adelaide", "7181", "350850", "1316779", |
This file contains hidden or 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
| --- | |
| title: "Expected Repsponse plot" | |
| author: "Miles McBain" | |
| date: "20 October 2016" | |
| output: html_document | |
| --- | |
| #Read Data |
This file contains hidden or 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(rgdal) | |
| shp=readOGR('/home/milesmcbain/data/aep/vectors/ANT_EVA/GIS_EVA/EVA_Paddocks_201003.TAB', 'EVA_Paddocks_201003') | |
| writeOGR(obj = shp, | |
| dsn = 'EVA_Paddocks', | |
| layer = 'EVA_Paddocks', | |
| driver = "GeoJSON") | |
| #Extract metadata | |
| library(jsonlite) | |
| library(readr) |
This file contains hidden or 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
| na_block_idx <-cppFunction("NumericVector na_block_idx(LogicalVector complete_case_vec){ | |
| int n = complete_case_vec.size(); | |
| NumericVector na_block_idxs(n); | |
| int block_counter = 0; | |
| if(complete_case_vec[0] == TRUE){ | |
| na_block_idxs[0] = ++block_counter; | |
| }else{ | |
| na_block_idxs[0] = 0; | |
| } |
This file contains hidden or 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
| ```{r} | |
| tb_cases_sep %>% | |
| group_by(gender, year) %>% | |
| summarise(total_cases = sum(num_cases, na.rm = T)) %>% | |
| ggplot(aes(x = year, y = total_cases, colour = gender)) + | |
| geom_point() + geom_path() + | |
| ggtitle("Worldwide Tuberculosis Cases Over Time vs Patient Gender", subtitle = "Reported by the WHO") | |
| ``` |
This file contains hidden or 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
| simple_roc <- function(labels, scores){ | |
| labels <- labels[order(scores, decreasing=TRUE)] | |
| data.frame(TPR=cumsum(labels)/sum(labels), FPR=cumsum(!labels)/sum(!labels), labels) | |
| } |
This file contains hidden or 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
| dates <- tribble( | |
| ~dob, | |
| "10/06/1968", | |
| "16/07/1969", | |
| "01/07/1966", | |
| "15/09/1977", | |
| "29/01/1971", | |
| "12/01/1960", | |
| "05/10/1973", | |
| "21/04/1972", |
This file contains hidden or 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
| dat <- readr::read_csv("municipality\n- Ticino\n>> Distretto di Bellinzona\n......5001 Arbedo-Castione\n......5002 Bellinzona\n......5003 Cadenazzo\n......5004 Camorino\n") | |
| dat %>% mutate(municipality = gsub(pattern = '[\\.\\>]|^-', | |
| replacement = "", | |
| municipality)) %>% | |
| separate(col = municipality, | |
| sep = '(?<=[0-9])\\s', | |
| into = c ("code","municipality"), | |
| fill = "left") |
This file contains hidden or 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(readr) | |
| library(tidyverse) | |
| sra <- read_csv("sra (4).csv") | |
| sra_mobs <- | |
| sra %>% | |
| mutate(phone_number = ifelse(grepl(pattern = "^4", x = `Mobile Phone`), yes = paste0("0",as.character(`Mobile Phone`)), no = `Mobile Phone`), | |
| type = "Member" | |
| ) %>% |