Skip to content

Instantly share code, notes, and snippets.

View JosiahParry's full-sized avatar
💻
on the 'puter

Josiah Parry JosiahParry

💻
on the 'puter
View GitHub Profile
library(ggplot2)
tmp <- tempdir()
clone_call <- glue::glue("
cd {tmp}
git clone [email protected]:marcosci/scooter_scraping.git")
# clone repo into temp dir
system(clone_call)
Okay, so the goal is to have access to tidymodels from Databricks. My answer is a more general approach to package access in Databricks. This approach will lead to slightly slower spin up time.
The idea is to have persistent storage in the form of a ADLS blob storage container where packages are installed to. Then, when you spin up a cluster, install any required system deps and change your `options("repos")` to the ADLS container.
You can mount the container using one of these two approaches:
- [directly to the workspace](https://docs.microsoft.com/en-us/azure/databricks/data/mounts)
- [using blobfuse](https://docs.microsoft.com/en-us/azure/storage/blobs/storage-how-to-mount-container-linux)
```{r}
fp <- "https://raw.githubusercontent.com/gdsbook/book/master/data/tokyo/tokyo_clean.csv"
user <- readr::read_csv(fp) |>
dplyr::filter(user_id == "95795770@N00") |>
sf::st_as_sf(coords = c("x", "y"))
hull <- sf::st_geometry(user) |>
geos::geos_make_collection() |>
geos::geos_concave_hull(ratio = 1)
data(guerry, package = "sfdep")
library(dplyr)
library(spdep)
transmute(guerry, neighbors = spdep::poly2nb(geometry))
class_modify <- function(x, class = "list") {
current <- class(x)
class(x) <- c(current, class)
/* rs-theme-name: Light theme {rsthemes} */
/* rs-theme-is-dark: FALSE */
.ace_gutter {
background: #e8e8e8;
color: #6b6b6b;
}
.ace_print-margin {
width: 2px;
background: rgba(136, 114, 50, 0.188235);
@JosiahParry
JosiahParry / light-theme.rstheme
Created October 3, 2022 21:06
My light rstudio theme
/* rs-theme-name: Light theme {rsthemes} */
/* rs-theme-is-dark: FALSE */
.ace_gutter {
background: #e8e8e8;
color: #6b6b6b;
}
.ace_print-margin {
width: 2px;
background: rgba(136, 114, 50, 0.188235);
@JosiahParry
JosiahParry / route-names.R
Created November 10, 2022 21:39
tidy up route names
make_route_name <- function(x) {
strsplit(x, ", ") |>
unlist() |>
unique() |>
paste(collapse = ", ")
}
routes <- c("426, 442, 450, 455, T116", "113, 99, T109, T110")
@JosiahParry
JosiahParry / rectangles.R
Created November 26, 2022 15:44
creating a data-frame like class in R
# create a new class called df
# it recreates a printing method for lists.
# recreates a subsetting function
# constructor
new_rectangle <- function(.data, ...) {
# checking function for assertions
structure(.data, class = "rectangle")
}
@JosiahParry
JosiahParry / check_missing_value.R
Last active December 16, 2022 15:36
Checks if there are missing value tags in any man pages
# Function to run to check if you have any missing `\value{}` tags
check_missing_value <- function(pkg = ".") {
pkg_root <- rprojroot::find_package_root_file(path = pkg)
# find exported functions
ns <- readLines(file.path(pkg_root, "NAMESPACE"))
exports <- ns[which(grepl("export", ns))]
# https://stackoverflow.com/questions/8613237/extract-info-inside-all-parenthesis-in-r
exported_fxs <- stringr::str_extract(exports, "(?<=\\().+?(?=\\))")
# parse all man pages
---
title: "Spatial Relationships"
format:
revealjs:
incremental: true
---
```{r, include = FALSE}
# plots for later