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
#!/bin/bash | |
# Requires the sendemail package being installed on the host machine | |
# Get container health status | |
healthy=$(docker inspect -f '{{.State.Health.Status}}' airflow-airflow-scheduler-1) | |
# Check if healthy | |
if [[ $healthy != "healthy" ]]; then | |
# attempt to restart Airflow - the scheduler will stop if the Azure Postgres DB becomes unavailable due to maintenance |
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
# Exploring download counts of a single package | |
x <- cranlogs::cran_downloads("janitor", from = "2016-10-03", to = "2021-03-12") | |
library(tidyverse) | |
library(lubridate) | |
library(tntpr) # from devtools::install_github("tntp/tntpr") | |
x$wday <- wday(x$date) | |
x$weekday <- ifelse(x$wday %in% c(1,7), "Weekend", "Weekday") | |
x$year <- tntpr::date_to_sy(x$date, as.Date("2016-10-02")) # segments into years using a cutoff date |
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
package | total_downloads | |
---|---|---|
A3 | 2769 | |
aaSEA | 1254 | |
AATtools | 855 | |
ABACUS | 1298 | |
abbyyR | 1745 | |
abc | 3119 | |
abc.data | 3364 | |
ABC.RAP | 1412 | |
abcADM | 1135 |
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
import pandas as pd | |
import solaredge | |
import time | |
s = solaredge.Solaredge("YOUR-API-KEY") | |
site_id = YOUR-SITE-ID | |
# Edit this date range as you see fit | |
# If querying at the maximum resolution of 15 minute intervals, the API is limited to queries of a month at a time | |
# This script queries one day at a time, with a one-second pause per day that is polite but probably not necessary |
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(pacman) | |
p_load(tidytext, wordcloud, janeaustenr, dplyr) | |
data("stop_words") | |
ppdf <- data.frame(prideprejudice, stringsAsFactors = FALSE) | |
# create a word cloud | |
create_word_cloud <- function(dat, col_name, exclude = "", max.words = 50, colors = "#034772", ...){ | |
col <- deparse(substitute(col_name)) | |
dat %>% |
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
# I want to remove duplicate mpg rows where cylinder is 4 | |
# Split, tinker with the data.frames by name, bind_rows | |
library(magrittr) | |
library(dplyr) | |
mtcars %>% | |
split(., .$cyl == 4) %$% | |
bind_rows(`FALSE`, | |
`TRUE` %>% | |
distinct(mpg, .keep_all = TRUE)) |
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
# From https://stackoverflow.com/questions/45575971/compile-a-vignette-using-devtoolsbuild-vignette-so-that-md-is-kept-in-the-v | |
# Usage: render_keep_md("tabyls") | |
render_keep_md <- function(vignette_name){ | |
# added the "encoding" argument to get the oe character passed through correctly to the resulting .Md | |
rmarkdown::render(paste0("./vignettes/",vignette_name, ".Rmd"), clean=FALSE, encoding = 'UTF-8') | |
files_to_remove = paste0("./vignettes/",vignette_name, c(".html",".knit.md",".utf8.md")) | |
lapply(files_to_remove, file.remove) | |
} |
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
# Fix dual-row names: if the first row is not NA or containing the word "response", use the one from the first row | |
# Note: read your SurveyMonkey .csv with readr::read_csv, not read.csv - otherwise this may not work | |
library(dplyr) | |
library(janitor) | |
fix_SM_dual_row_names <- function(dat){ | |
current_names <- names(dat) | |
row_1 <- unlist(dat[1, ]) | |
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(dplyr) | |
library(grid) | |
library(gridExtra) | |
add_centered_title <- function(p, text, font_size){ | |
title.grob <- textGrob( | |
label = text, | |
gp = gpar(fontsize = font_size, |
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
Package: janitor | |
Title: Simple Tools for Examining and Cleaning Dirty Data | |
Version: 0.3.0.9000 | |
Authors@R: c(person("Sam", "Firke", email = "[email protected]", role = c("aut", "cre")), | |
person("Chris", "Haid", email = "[email protected]", role = "ctb"), | |
person("Ryan", "Knight", email = "[email protected]", role = "ctb")) | |
Description: The main janitor functions can: perfectly format data.frame column | |
names; provide quick one- and two-variable tabulations (i.e., frequency | |
tables and crosstabs); and isolate duplicate records. Other janitor functions | |
nicely format the tabulation results. These tabulate-and-report functions |
NewerOlder