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
fmt_pval <- function(pvalues) { | |
p <- format.pval( | |
pv = pvalues, | |
digits = 1, | |
eps = 0.001, | |
na.form = '', | |
nsmall = 3 | |
) |
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
// using a useRef hook to manage form state with uncontrolled text area component | |
import { useRef } from 'react'; | |
export default function TextInputForm() { | |
const ref = useRef(); | |
const text = 'input'; | |
function submitForm() { | |
console.log(ref.current); | |
} |
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
# 7d endpoint average, ignoring missing values, equally weighted | |
endpoint_avg_7d <- function(x) { | |
RcppRoll::roll_mean(x, n = 7, align = 'right', | |
na.rm = T, fill = NA_real_) | |
} |
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
collect_wastewater_data <- function(){ | |
'https://raw.githubusercontent.com/Big-Life-Lab/PHESD/main/Wastewater/Ottawa/Data/wastewater_virus.csv' |> | |
read_csv(show_col_types = FALSE, guess_max = 1000) |> | |
janitor::clean_names() |> | |
janitor::remove_empty('cols') | |
} |
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
# ottawa wastewater data: daily means | |
regional_ww <- | |
read_rds(here('data/ww_ottawa.rds')) |> | |
select(sample_date, starts_with('cov_')) |> | |
pivot_longer(contains('cov_')) |> | |
mutate(target = str_extract(name, 'cov_n.'), | |
stat = str_extract(name, 'mean|sd'), | |
) |> | |
select(-name) |> | |
pivot_wider(names_from = stat, values_from = value) |> |
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
convert_cq_to_copies <- function(cq) { | |
return(10 ** ((40.1 - cq) / 3.23)) | |
} |
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(tidyverse) | |
iris |> | |
group_by(Species) |> | |
summarise(across(everything(), lst(median, min, max))) |> | |
pivot_longer(-Species) |> | |
pivot_wider(names_from = Species, values_from = value) |> | |
separate(name, sep = '_', into = c('var', 'stat')) | |
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
var today = new Date(); | |
var dd = String(today.getDate()).padStart(2, '0'); | |
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0! | |
var yyyy = today.getFullYear(); | |
today = mm + '/' + dd + '/' + yyyy; |
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_plot + | |
guides(color = guide_legend(override.aes = list(size = 5))) |
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_ggplot + | |
scale_x_date( | |
date_breaks = '1 month', | |
date_labels = "%b" | |
) |
NewerOlder