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
| Count_censored <- function(my.df) { | |
| # number left censored | |
| .Count_leftCensored <- function(x) { | |
| sum(str_detect(x, '[<]'), na.rm = TRUE) | |
| } | |
| .Count_rightCensored <- function(x) { | |
| sum(str_detect(x, '[>]'), na.rm = TRUE) | |
| } |
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
| # Arguements: | |
| # my_df - name of a data frame | |
| # my_col - name of column to check and summarise e.g. 'DO' | |
| # | |
| # Usage | |
| # Check_col(my_df, my_col) | |
| # | |
| # Value | |
| # Outputs a dataframe with summarised values |
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
| # my_df - data frame with DO and temperature data | |
| # DO - (quoted) name of column of DO values (mg/L) e.g. 'DO' | |
| # temp - (quoted) name of column of temperature values (degrees Celcius) e.g. 'temp' | |
| # outputs a graph | |
| CheckPlot_DO <- function(my_df, DO_col, temp_col) { | |
| DO <- my_df[[DO_col]] | |
| temp <- my_df[[temp_col]] |
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
| # Function to convert a time value to a fraction of a day | |
| # | |
| # Intended to be used for time data from Excel | |
| # | |
| # x is the time | |
| # | |
| # if x is between 0 and 1 it is assumed to be a fraction of a day and returned | |
| # if x is > 24 the decimal part is assumed to represent a fraction of a day and is returned | |
| # # if x contains a colon it is assumed to be in the form HH:MM:SS and converted to | |
| # a fraction of a day. |
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(ggplot2) | |
| library(dplyr) | |
| library(lubridate) | |
| library(cowplot) | |
| # Storms on days of the week | |
| # Storm archive | |
| # http://www.bom.gov.au/australia/stormarchive/ | |
| # Victoria | |
| # 1 Jan 2010 to present |
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(plotrix) | |
| library(RColorBrewer) | |
| ################### | |
| # The slopegraphs use the plotrix::bumpchart function | |
| # Here I've tweaked plotrix::bumpchart to increase the spacing between the 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
| # my_col - name of column to plot, must be quoted | |
| # datetime_col - name of column that contains datetime information | |
| # my_df - name of dataframe | |
| # | |
| # Plot graphs for the whole time series | |
| # | |
| # pdf('fname.pdf') | |
| # lapply(names(my_df), FUN = Plot_col, 'datetime_col', my_df) | |
| # dev.off() |
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
| # function to calculate k of the max and min of a dataset | |
| # k > 3 suggests data are 'far out' | |
| Tukey_k <- function(x){ | |
| my.quantile <- quantile(x, na.rm = TRUE) | |
| Q_25 <- my.quantile[2] | |
| Q_75 <- my.quantile[4] | |
| k_max <- as.vector((max(x, na.rm = TRUE) - Q_75)/(Q_75 - Q_25)) | |
| k_min <- as.vector((Q_25 - min(x, na.rm = TRUE))/(Q_75 - Q_25)) |
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: "Events_blog" | |
| author: "Tony Ladson" | |
| date: "3 October 2016" | |
| output: | |
| html_fragment: | |
| fig_caption: yes | |
| fig_height: 4 | |
| fig_width: 6 | |
| --- |
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(ggplot2) | |
| library(RColorBrewer) | |
| library(grid) | |
| library(cowplot) | |
| ILb_hill <- function(d, MAR = 700){ | |
| 1 - 1/(1+142*sqrt(d)/MAR) | |
| } |