Skip to content

Instantly share code, notes, and snippets.

Information on how to configure a new (empty) gh-pages branch and publish a quarto document there.

From: https://quarto.org/docs/publishing/github-pages.html#source-branch

Create GitHub Pages Source Branch (gh-pages)

Before attempting to publish you should ensure that the Source branch for your repository is gh-pages and that the site directory is set to the repository root (/).

If you do not already have a gh-pages branch, you can create one as follows:

# This script shows how to filter and/or download a resource from the CA Open
# Data Portal (https://data.ca.gov/) as a csv file using a persistent link
# (i.e., a link that doesn't change based on the resource's filename)
# load packages -----------------------------------------------------------
library(tidyverse)
@daltare
daltare / esmr_parquet_file_example.R
Last active November 25, 2021 01:49
eSMR parquet file example
# load packages -----------------------------------------------------------
library(arrow)
library(dplyr)
library(glue)
library(zip)
library(tools)
# download parquet file ---------------------------------------------------
# This example shows one way to access subsets of CEDEN data via the California Open Data Portal API (it's not
# necessarily the only or best way though) - if you find any problems or have questions, please contact: david.altare@waterboards.ca.gov
# This example applies to the following CEDEN datasets, which have been split into separate
# resources by year (due to file size limitations)
# Water Chemistry: https://data.ca.gov/dataset/surface-water-chemistry-results
# Habitat: https://data.ca.gov/dataset/surface-water-habitat-results
# Tissue: https://data.ca.gov/dataset/surface-water-aquatic-organism-tissue-sample-results
# It assumes that you have your own API key saved in a system environment variable
# This example shows one way to access subsets of CEDEN data via the California open data portal API (it's not
# necessarily the only or best way though) - if you find any problems or have questions, please contact: david.altare@waterboards.ca.gov
# This example applies to the following CEDEN datasets on the open data portal:
# Toxicity: https://data.ca.gov/dataset/surface-water-toxicity-results/resource/bd484e9b-426a-4ba6-ba4d-f5f8ce095836
# Benthic Macroinvertebrates: https://data.ca.gov/dataset/surface-water-benthic-macroinvertebrate-results/resource/3dfee140-47d5-4e29-99ae-16b9b12a404f
# (NOTE: other CEDEN datasets are split by year, and cannont be queried across multiple years using this method -- for other CEDEN datasets, see: https://gist.github.com/daltare/2de1517ad1e315c4b1cad01278de96dd)
# This example assumes that you have your own API key saved in a system environment variable
# named: "data_portal_key" (to obtain an API key, create an account at data.ca.gov, then go to your
@daltare
daltare / ceden_arrow_files_example.r
Last active November 1, 2022 21:34
CEDEN Arrow Files Example
# This example shows how to work with CEDEN data in the Apache parquet file format, using the arrow package in R
# The data (in parquet file format) for each type of CEDEN data is available on the California Open Data Portal at the
# following links:
# Water Chemistry: https://data.ca.gov/dataset/surface-water-chemistry-results/resource/f4aa224d-4a59-403d-aad8-187955aa2e38
# Habitat: https://data.ca.gov/dataset/surface-water-habitat-results/resource/0184c4d0-1e1d-4a33-92ad-e967b5491274
# Tissue: https://data.ca.gov/dataset/surface-water-aquatic-organism-tissue-sample-results/resource/dea5e450-4196-4a8a-afbb-e5eb89119516
# Toxicity: https://data.ca.gov/dataset/surface-water-toxicity-results/resource/a6c91662-d324-43c2-8166-a94dddd22982
# Benthic Macroinvertebrates: https://data.ca.gov/dataset/surface-water-benthic-macroinvertebrate-results/resource/eb61f9a1-b1c6-4840-99c7-420a2c494a43
# load packages
@daltare
daltare / ear_data_download.R
Last active December 2, 2020 17:15
Steps to load Electronic Annual Report (EAR) Data from the CA State Water Resouces Control Board's web site into R
# data for multiple years is available at: https://www.waterboards.ca.gov/drinking_water/certlic/drinkingwater/ear.html
# this script downloads data for one year to a temporary file, and loads the data into an R data frame
# load R packages
library(dplyr)
library(readr)
# create link to the dataset
year <- 2018
dataset_link <- paste0('https://www.waterboards.ca.gov/drinking_water/certlic/drinkingwater/documents/ear/earsurveyresults_',