Skip to content

Instantly share code, notes, and snippets.

View LukasWallrich's full-sized avatar

Lukas Wallrich LukasWallrich

View GitHub Profile
@LukasWallrich
LukasWallrich / manual_dedup.R
Created April 5, 2024 11:51
A Shiny interface to deal with ASySD's manual dedup step
# Derived from revtools code, copyright Martin J Westgate
# Adapted by Lukas Wallrich, still unter GPL-3 licence
library(magrittr)
manual_dedup <- function(
df, cols = names(df), suffixes = c("1", "2"), id = "id"
){
input_data <- list(
@LukasWallrich
LukasWallrich / Gmodel.py
Last active February 14, 2023 17:09
Gmodel.py
# Model proposed by Grim et al
# with different perspectives added - i.e. shortcuts
# Used this to avoid duplicating files
import httpimport
url = "https://gist.githubusercontent.com/LukasWallrich/05f445821fbae694b37a205dc08b2b4f/raw/"
with httpimport.remote_repo(url):
from HPmodel import HPProblem, PSAgent
@LukasWallrich
LukasWallrich / my_data_color.R
Last active November 3, 2022 12:02
gt data_color extension to target column
my_data_color <- function (data, SOURCE_columns, TARGET_columns, colors, alpha = NULL, apply_to = c("fill",
"text"), autocolor_text = TRUE)
{
stop_if_not_gt(data = data)
apply_to <- match.arg(apply_to)
colors <- rlang::enquo(colors)
data_tbl <- dt_data_get(data = data)
colors <- rlang::eval_tidy(colors, data_tbl)
resolved_source_columns <- resolve_cols_c(expr = {
{
# Used this to avoid duplicating files
import httpimport
url = "https://gist.githubusercontent.com/LukasWallrich/05f445821fbae694b37a205dc08b2b4f/raw/"
with httpimport.remote_repo(url):
from HPmodel import HPProblem, PSAgent
# Alternative: download file into same folder, then run
# from HPmodel import HPProblem, PSAgent
# ABM as proposed by Hong & Page (2004)
from statistics import mean
from collections import Counter
from itertools import permutations
from mesa import Agent, Model, DataCollector
from mesa.time import BaseScheduler
import copy
class PSAgent(Agent):
# Test case for httpimport
# https://github.com/operatorequals/httpimport/
def hello():
print("Hello world")