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(dplyr) | |
library(purrr) | |
library(ggplot2) | |
#;; Data | |
df <- tibble(cat=c("A", "A", "B", "B"), | |
x=c(1, 2, 1, 2), | |
y=c(1, 2, 2, 1)) | |
#;; List of dataframes to plot |
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
#' --- | |
#' title: "Graph_Explorations.R" | |
#' author: "Matt Pettis ([email protected])" | |
#' date: "`r Sys.Date()`" | |
#' output: | |
#' html_document: | |
#' toc: true | |
#' toc_depth: 3 | |
#' code_folding: hide | |
#' editor_options: |
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
#;; Transform an input into shape fit for updating | |
#;; Here, each row has 3 observations, a modelnumber, serialnumber, and | |
#;; salesordernumber for each object. | |
library(readxl) | |
library(janitor) | |
#> | |
#> Attaching package: 'janitor' | |
#> The following objects are masked from 'package:stats': | |
#> | |
#> chisq.test, fisher.test |
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
#;; Find the local midnight time in UTC for a given timezone | |
library(tidyverse) | |
library(lubridate) | |
library(glue) | |
# tgtTimezone <- "America/Chicago" | |
# tgtTimezone <- "America/Sao_Paulo" | |
# tgtYear <- 2021 | |
# |
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
# https://pypi.org/project/scoping/ | |
# See also: https://github.com/bskinn/tempvars | |
from scoping import scoping | |
aofl = [{"a":1, "b":2}, {"a":3, "b":4}] | |
with scoping(): | |
for d in aofl: | |
x = d | |
scoping.keep('x') |
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
# Plot date ranges with color scheme, using scale_fill_manual() | |
library(tidyverse) | |
plot_df <- | |
tribble( | |
~start_date, ~end_date, ~cat, | |
"2021-01-01","2021-01-02","a", | |
"2021-01-03","2021-01-05","b" | |
) %>% | |
mutate(cat = factor(cat)) %>% | |
mutate(start_date = ymd(start_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
``` r | |
library(httr) | |
library(httr2curl) | |
cat( | |
h2c( | |
httr::POST("https://api.tis-dev.trane.com/tis-security-context/securityContext", | |
httr::add_headers(.headers=c("Content-Type"="application/json", "Accept"="application/json")), | |
body = '{"username":"myusername","password":"mypassword"}', | |
encode = "json") |
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
# See: https://gist.github.com/drsimonj/2038ff9f9c67063f384f10fac95de566 | |
# See: https://adv-r.hadley.nz/meta-big-picture.html | |
# See: https://dplyr.tidyverse.org/reference/tidyeval.html | |
# See: https://dplyr.tidyverse.org/articles/programming.html | |
library(dplyr) | |
# Set up lags | |
lags <- c(1:30) |
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
``` r | |
# Load libraries | |
library(lubridate) | |
#> Warning: package 'lubridate' was built under R version 3.6.3 | |
#> | |
#> Attaching package: 'lubridate' | |
#> The following objects are masked from 'package:base': | |
#> | |
#> date, intersect, setdiff, union | |
library(dplyr) |
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
### Let's say you get timestamps that do not have their tzone info as part of the timestamp string, | |
### but stored in a separate field. Further, assume your system has read them in using your local | |
### tzone. How do use knowledge of our local timezone and that of the the intended timezone to | |
### correct the timestamp to be in the intended timezone? | |
### | |
### In this exercise, we have the following: | |
### - The timestamp, with no explicit timezone which was read into system using default initial | |
### timezone of the first user. | |
### - A second system that has timezone different from the first timezone. | |
### - The intended timezone of the timestamp, which is what the timestamp should be in. |
NewerOlder