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
#' @title Get Adaptive Delay Based on App Usage | |
#' @description Calculates the appropriate sleep delay based on Meta API usage percentages (calls, CPU time, total time). | |
#' Inspired by the [Wesleyan Media Project's utilities](https://github.com/Wesleyan-Media-Project/fb_ads_import/blob/main/race2022_utils.R). | |
#' | |
#' @param call_pct Numeric. Percentage of allowed call count used. | |
#' @param cpu_pct Numeric. Percentage of allowed CPU time used. | |
#' @param time_pct Numeric. Percentage of allowed total time used. | |
#' | |
#' @return A numeric value indicating the number of seconds to sleep. | |
#' @export |
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
# Load necessary libraries | |
library(shiny) | |
library(dplyr) | |
library(tidyr) | |
library(highcharter) | |
library(forcats) | |
library(bslib) | |
library(stringr) | |
library(shinyWidgets) | |
library(bsicons) |
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
# Import the required modules | |
from selenium import webdriver | |
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | |
import time | |
import json | |
def get_perf_log_on_load(url, headless = True, filter = None): | |
# Main Function | |
# Enable Performance Logging of Chrome. |
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(tidyverse) | |
library(rvest) | |
library(ggpubr) | |
library(COVID19) | |
## 1st step: | |
# go to http://www.sharkattackdata.com/place/united_states_of_america | |
## 2nd step: | |
# save HTML file to same location as script |
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(tidyverse) | |
## this r code is taking from here: https://github.com/mkearney/pkguse | |
read_r_files <- function(...) { | |
dirs <- unlist(list(...)) | |
r <- unlist(lapply(dirs, list.files, | |
pattern = "\\.(R|Rmd|Rmarkdown|rmd|r|Rhistory)$", | |
recursive = TRUE, | |
full.names = TRUE, | |
all.files = TRUE)) |
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
#=============================================================================== | |
# 2022-07-12 | |
# Extract data from Latent GOLD within R | |
# Fabio Votta (@favstats) | |
#=============================================================================== | |
library(tidyverse) | |
library(data.table) | |
setwd(here::here()) |
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
#=============================================================================== | |
# 2022-07-10 | |
# Year progress twitter | |
# Fabio Votta (@favstats) | |
# Idea blatantly stolen from Ilya Kashnitsky (@ikashnitsky) | |
#=============================================================================== | |
library(tidyverse) | |
library(magrittr) | |
library(lubridate) |
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
save_csv <- function(d, path) { | |
if(file.exists(path)){ | |
readr::write_csv(d, append = T, file = path) | |
} else { | |
dirs_to_create <- stringr::str_split(path, "\\/") %>% | |
unlist() %>% | |
purrr::discard(~stringr::str_detect(.x, "\\.")) %>% | |
paste0(collapse = "/") |
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(tidyverse) | |
library(httr) | |
token <- Sys.getenv("fb_marketing_token") | |
#link to fb api | |
my_lin k<- "https://graph.facebook.com" | |
#define fields you are interested in | |
search_fields=c("ad_creation_time", |
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(tidyverse) | |
library(modelbased) | |
library(magrittr) | |
overview <- readRDS("data/overview.rds") | |
## helper function | |
get_plabs <- function (pval) { | |
dplyr::case_when(is.na(pval) ~ "", pval < 0.001 ~ "***", | |
pval < 0.01 ~ "**", pval < 0.05 ~ "*", |
NewerOlder