This file contains hidden or 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(readr) | |
library(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
library(lubridate) | |
library(RcppRoll) | |
source("~/theme.R") | |
datafiles <- list.files(pattern="csv$") | |
# remove the older provisional files that I have the directory |
This file contains hidden or 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(readr) | |
library(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
library(ggthemes) | |
source("~/theme.R") | |
WVS <- read_csv("~/Downloads/WVS_Cross-National_Wave_7_csv_v6_0.csv") | |
shorter <- WVS |> | |
filter(B_COUNTRY_ALPHA %in% c("DEU", "RUS","IND", "USA", "KOR", "NZL")) |> | |
select(B_COUNTRY_ALPHA, Q7:Q17) |
This file contains hidden or 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(maps) | |
library(dplyr) | |
# while the position data in the maps package | |
# is very basic, that makes it simple to transform | |
nz_map <- map_data("nz") | |
nz_anti <- nz_map %>% | |
mutate( |
This file contains hidden or 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
"Week_Ending","Border_Cases","Community_Cases","Deaths" | |
2020-02-23,0,0,0 | |
2020-03-01,1,0,0 | |
2020-03-08,4,2,0 | |
2020-03-15,3,0,0 | |
2020-03-22,56,22,0 | |
2020-03-29,273,180,1 | |
2020-04-05,160,350,0 | |
2020-04-12,52,232,4 | |
2020-04-19,16,81,7 |
This file contains hidden or 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(magick) | |
library(exiftoolr) | |
# Hard-coded folder path | |
folder <- "~/Desktop/photos" | |
# Function to process images | |
process_images <- function(folder) { | |
# Create the "texted" subfolder if it doesn't exist | |
texted_folder <- file.path(folder, "texted") |
This file contains hidden or 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(shiny) | |
library(magick) | |
ui <- fluidPage( | |
titlePanel("Image Upload and Text Overlay"), | |
sidebarLayout( | |
sidebarPanel( | |
fileInput("file1", "Choose an Image File", | |
accept = c('image/png', 'image/jpeg')), |
This file contains hidden or 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) | |
asLines <- readLines("d12.txt") | |
height <- length(asLines) | |
width <- nchar(asLines[1]) | |
chars <- strsplit(paste(asLines, collapse = ""), "")[[1]] | |
aCropMatrix <- matrix(chars, nrow = height, byrow = TRUE) | |
aFieldMatrix <- matrix(1:length(chars), nrow = height, byrow = TRUE) | |
priorFieldMatrix <- matrix(rep(1, length(chars)), nrow = height, byrow = TRUE) | |
while (!identical(priorFieldMatrix, aFieldMatrix)) { |
This file contains hidden or 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(gtools) | |
library(stringr) | |
library(dplyr) | |
library(tidyr) | |
d7 <- readLines("day07.txt") | |
#assumes you kept the resut of part1 to save work | |
d7p1 <- as.numeric(readLines("d7p1result.txt")) | |
p2data <- d7[d7p1 == 0] | |
p2sums <- as.numeric(gsub(":.*","",p2data)) | |
p2input <- gsub(".*: ","",p2data) |
This file contains hidden or 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(rvest) | |
library(dplyr) | |
library(RcppRoll) | |
library(tidygeocoder) | |
library(maps) | |
library(mapdata) | |
library(ggplot2) | |
library(viridis) | |
library(patchwork) | |
library(ggtext) |
This file contains hidden or 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
Period | Ages | RawDeaths | InterpPop | DeathRateMillion | |
---|---|---|---|---|---|
2000-01-09 | 30 to 59 | 74 | 1569863.62637363 | 47.1378524585218 | |
2000-01-09 | 60 to 79 | 189 | 495217.472527473 | 381.650508079589 | |
2000-01-09 | 80 and over | 194 | 104575.054945055 | 1855.12692392971 | |
2000-01-09 | Under 30 | 27 | 1681940.65934066 | 16.0528850111658 | |
2000-01-16 | 30 to 59 | 64 | 1570169.78021978 | 40.7599234211741 | |
2000-01-16 | 60 to 79 | 196 | 495324.395604396 | 395.700275898667 | |
2000-01-16 | 80 and over | 226 | 104711.208791209 | 2158.31717166629 | |
2000-01-16 | Under 30 | 14 | 1681754.50549451 | 8.32463950847774 | |
2000-01-23 | 30 to 59 | 73 | 1570475.93406593 | 46.4827243872527 |
NewerOlder