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(httr2) | |
# Requests are composable. For example, you could set a bunch of options in a base request used by many other functions | |
base_req <- | |
request("https://services.usanpn.org/npn_portal/") |> | |
req_retry(max_tries = 3, retry_on_failure = TRUE) |> #retry on errors | |
req_progress(type = "down") |> #display progress bar for large downloads | |
req_throttle(rate = 30/60) |> #limit request rate to 30 requests per minute | |
req_user_agent("rnpn (https://github.com/usa-npn/rnpn/)") |
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
gistr |
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
gistr |
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(targets) | |
tar_dir({ | |
#create 10 identical CSVs as a demo | |
orig <- tibble::tibble(group = c("A", "A", "A", "B", "B", "C"), | |
value = 1) | |
purrr::walk(c(1:10), \(x) write_csv(orig, paste0(x, "-data.csv"))) | |
#_targets.R | |
tar_script({ | |
library(targets) |
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(ggplot2) | |
library(scales) | |
breaks_limits <- function (n = 5, tol = 0.1, min = TRUE, max = TRUE, ...) | |
{ | |
n_default <- n | |
scales:::force_all(n, tol, min, max, ...) | |
function(x, n = n_default) { | |
breaks <- pretty(x, n, ...) | |
#force limits to be included and remove breaks outside of limits |
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) | |
#fake excedences data | |
excedences <- tribble( | |
~analyte, ~threshold, | |
"x", 0, | |
"y", 1 | |
) | |
excedences |
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) | |
# Create fake data -------------------------------------------------------- | |
t1 <- tibble( | |
x = 1:5, | |
y = c("A", NA, "C", "D", "E"), | |
z = rnorm(5) | |
) |
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 31 columns, instead of 30 in line 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
type,recipe_id,baking powder,baking soda,butter,buttermilk,chocolate,cornmeal,cream cheese,eggs,flour,fruit,fruit juice,honey,margarine,milk,nut,oats,oil,other,salt,sour cream,spice,starch,sugar,unitless,vanilla,vegetable,vinegar,water,yogurt | |
Cupcake,145206,0.0017361083333333333,8.680541666666666e-4,0,0,0,0,0,0,0.09375,0,0,0.010416666666666666,0,0.0625,0.04513888333333333,0,0.027777777777777776,0,4.340270833333333e-4,0,0,0,0.05555555555555555,0,0.0034722166666666665,0,0.0034722166666666665,0,0 | |
Cupcake,240140,8.680541666666666e-4,6.944433333333333e-4,0.016666666666666666,0,0,0,0.03333333333333333,0.13333333333333333,0.08333333333333333,0,0,0,0,0,0,0,0.05,0,3.4722166666666663e-4,0,0.0024305516666666667,0,0.16666666666666666,0,0,0.05,0,0,0 | |
Cupcake,161019,8.680541666666666e-4,0.0017361083333333333,0,0.041666666666666664,0.033854166666666664,0,0,0.08333333333333333,0.08333333333333333,0,0,0,0,0,0,0,0.020833333333333332,0.041666666666666664,4.340270833333333e-4,0,0,0,0.08333333333333333,0.041666666666666664,0,0,0,0 |
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(readr) | |
library(dplyr) | |
library(purrr) | |
#create data for testing | |
split_cars <- mtcars |> | |
group_by(cyl) |> | |
group_split() | |
tmp <- tempdir() |
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
site | ensemble | date_start | date_end | finished | ed_error | ed_error_reason | model2netcdf_error | |
---|---|---|---|---|---|---|---|---|
MANDIFORE-PNW-4538 | 1 | 2002-06-01 | 2012-05-01 | TRUE | FALSE | NA | FALSE | |
MANDIFORE-PNW-4538 | 2 | 2002-06-01 | 2012-05-01 | TRUE | FALSE | NA | FALSE | |
MANDIFORE-PNW-4538 | 3 | 2002-06-01 | 2012-05-01 | TRUE | FALSE | NA | FALSE | |
MANDIFORE-PNW-4538 | 4 | 2002-06-01 | 2012-05-01 | FALSE | TRUE | Program received signal SIGABRT: Process abort signal. | FALSE | |
MANDIFORE-PNW-4538 | 5 | 2002-06-01 | 2012-05-01 | FALSE | FALSE | NA | TRUE | |
MANDIFORE-PNW-4538 | 6 | 2002-06-01 | 2012-05-01 | FALSE | FALSE | NA | TRUE | |
MANDIFORE-PNW-4538 | 7 | 2002-06-01 | 2012-05-01 | FALSE | TRUE | Program received signal SIGABRT: Process abort signal. | FALSE | |
MANDIFORE-PNW-4538 | 8 | 2002-06-01 | 2010-08-01 | FALSE | FALSE | NA | FALSE | |
MANDIFORE-PNW-4538 | 9 | 2002-06-01 | 2012-05-01 | TRUE | FALSE | NA | FALSE |
NewerOlder