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(data.table) | |
n <- 100 | |
df <- data.frame(id=LETTERS[1:10],meta=letters[1:10]) | |
other_dfs <- lapply(1:n,\(x) data.frame(id=LETTERS[1:10],values=rnorm(1:10))) | |
f <- function(n){ | |
for(i in 1:n){ |
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: "Untitled" | |
format: html | |
--- | |
```{r} | |
#| label: prepare | |
#| echo: 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
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"))+ |
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", |
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() |
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")) |> |
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 |
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]] |
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) |
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) { | |
} |
NewerOlder