View mailify.R
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(ggpubr) | |
library(ggtext) | |
df <- data.frame(x=seq.Date(as.Date("2020-04-01"),as.Date("2022-07-01"),by="month"),y=(1:28)^2) | |
p <- ggplot(df, aes(x, y))+ | |
geom_line(linewidth = 2.2,color="white",lineend = "round")+ | |
geom_line(linewidth = 1,color="red",lineend = "round")+ | |
scale_x_date(labels=scales::label_date("%b\n%Y"))+ |
View signed_triad_census.R
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(signnet) | |
library(igraph) | |
library(ggraph) | |
library(patchwork) | |
triads <- c("003-000000", "012-0000P0", "012-0000N0", | |
"102-0000PP", "102-0000NP", "102-0000NN", "021C-0PP000", | |
"021C-0NP000", "021C-0PN000", "021C-0NN000", "021U-0P0P00", | |
"021U-0N0P00", "021U-0N0N00", "021D-P0P000", "021D-N0P000", | |
"021D-N0N000", "111U-0P00PP", "111U-0N00PP", "111U-0P00NP", | |
"111U-0P00PN", "111U-0N00NP", "111U-0N00PN", "111U-0P00NN", |
View ngram_search.R
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
# original python code: https://fosstodon.org/@jasonbaumgartner@infosec.exchange/109376317839501128 | |
# mapping: https://twitter-elastic.pushshift.io/twitter_user/_mapping | |
library(curl) | |
library(jsonlite) | |
ngram_search <- function(q="",size = 10){ | |
data <- list(query=list()) | |
data[["query"]][["bool"]] <- list() | |
data[["query"]][["bool"]][["must"]] <- list() | |
match <- list() |
View weather_spain.R
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(tidyverse) | |
library(sf) | |
library(ggraph) | |
library(igraph) | |
# create some random data | |
country <- mapSpain::esp_get_prov(moveCAN=TRUE) | |
provinces <- st_cast(country,"MULTIPOLYGON") |> st_cast("POLYGON") | |
centroids <- distinct(provinces,iso2.prov.name.es,.keep_all = TRUE) |> | |
dplyr::filter(!iso2.prov.name.es%in%c("Baleares","Las Palmas","Santa Cruz de Tenerife","Ceuta","Melilla")) |> |
View cran.lua
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
function CRAN(handle) | |
local output = '<span class="cran-pkg"><a href="https://cran.r-project.org/package=' .. | |
pandoc.utils.stringify(handle) .. '">'.. | |
pandoc.utils.stringify(handle)..'</a><i class="fa-brands fa-r-project fa-2xs"></i></span>' | |
return pandoc.RawBlock('html', output) | |
end |
View pack_circles.cpp
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
#include <Rcpp.h> | |
using namespace Rcpp; | |
// [[Rcpp::export]] | |
double distance(double x1, double x2, double y1, double y2){ | |
double dist = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)); | |
return dist; | |
} | |
// [[Rcpp::export]] |
View layout_yearly.R
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(igraph) | |
library(ggraph) | |
library(graphlayouts) | |
#handdrawn graph without isolates | |
el <- matrix(c(1,3,1,3,1,6,2,3,2,6, | |
3,4,3,4,3,6,4,6,4,8, | |
5,7,5,8,7,8,7,9,7,10, | |
7,11,9,10,10,11,9,11),ncol = 2,byrow = TRUE) | |
g <- graph_from_edgelist(el,F) |
View yt_rstudio.R
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(shiny) | |
xy <- c(784,479) #output of grDevices::dev.size("px") | |
url <- "https://www.youtube.com/watch?v=Ef2jmf2vy00" #copy yt link here | |
url <- gsub("watch\\?v=","embed/",url) | |
ui <- fluidPage( | |
HTML(paste0('<iframe width="',xy[1],'" height="',xy[2],'" src="',url,'" frameborder="0"></iframe>')) | |
) | |
server <- function(input, output, session) { | |
} |
View get_tweets.R
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
# start_time: %Y-%m-%dT%H:%M:%SZ | |
# end_time: %Y-%m-%dT%H:%M:%SZ | |
# needs jsonlite and httr | |
# next_token can be obtained from meta$next_token to paginate through results | |
get_tweets <- function(q="",n=10,start_time,end_time,token,next_token=""){ | |
if(n>500){ | |
warning("n too big. Using 500 instead") | |
n <- 500 | |
} | |
if(n<5){ |
View prime_viz.R
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
# Recreation of https://twitter.com/stevenstrogatz/status/1295915404574040065/photo/1 | |
library(tidyverse) | |
library(Polychrome) | |
fun <- function(x){ | |
n <- c() | |
i <- 2 | |
r <- x | |
while(prod(n)!=x){ | |
if(!r%%i) {n=c(n,i);r=r/i;i=1} | |
i <- i+1 |
NewerOlder