Skip to content

Instantly share code, notes, and snippets.

Dewey Dunnington paleolimbot

Block or report user

Report or block paleolimbot

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View rclimateca_workaround.R
library(tidyverse)
files <- crossing(
tibble(station_id = 42583, timeframe = 1),
tibble(year = 2018:2019),
tibble(month = 1:12)
) %>%
mutate(
url = glue::glue(
"http://climate.weather.gc.ca/climate_data/bulk_data_e.html?format=csv&Month={month}&stationID={station_id}&submit=Download%20Data&timeframe=1&Year={year}"
View test_pyqt.py
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
View depth_heatmap.R
library(tidyverse)
# best case: your data is already in the right form
perfect_data <- tibble(
day_in_year = c(1, 101, 201, 1, 101, 201, 1, 101, 201),
depth = c(1, 1, 1, 2, 2, 2, 3, 3, 3),
temp = c(15, 16, 17, 14, 15, 16, 13, 14, 15)
)
ggplot(perfect_data, aes(x = day_in_year, y = depth, fill = temp)) +
View lightning_ggplot_internals.R
library(ggplot2)
library(ggdebug) # remotes::install_github("paleolimbot/ggdebug")
# the classic ggplot!
ggplot(mpg) +
geom_point(aes(x = displ, y = hwy, colour = class))
# ...is really this:
p <- ggplot(mpg) +
View symmetric_scale.R
library(ggplot2)
symmetric_range <- function(range) {
max_abs <- max(abs(range))
c(-max_abs, max_abs)
}
ggplot(mpg, aes(cty, hwy)) +
geom_point() +
View guide_axis_example.R
# remotes::install_github("paleolimbot/ggplot2@2b2f4fb9ad8ada3c2f614185441db1d790b8db2e")
library(ggplot2)
# plot with overlapping text
p <- ggplot(mpg, aes(cty * 100, hwy * 100)) +
geom_point() +
facet_wrap(vars(class))
# axis guides can now be customized!
View multiaxis.R
# remotes::install_github("paleolimbot/ggplot2@2b2f4fb9ad8ada3c2f614185441db1d790b8db2e")
library(ggplot2)
ggplot(mpg, aes(class, hwy)) +
geom_point() +
guides(
y = guide_axis(order = 2),
y.sec = guide_axis(position = "left", order = 2, angle = 45)
)
View scale_x_sorted.R
library(ggplot2)
library(dplyr)
library(tibble)
SortingRange <- ggproto(
"SortingRange", ggplot2:::Range,
counted_range = tibble(value = character(0), n = integer(0)),
train = function(self, x, ...) {
new_counted_range <- tibble(value = x) %>%
View gg_elipses_usage.R
library(tidyverse)
library(ggdebug)
calls_use_method <- function(expr) {
if (rlang::is_call(expr, "UseMethod")) {
TRUE
} else if (is.call(expr)) {
any(map_lgl(expr, calls_use_method))
} else {
FALSE
You can’t perform that action at this time.