https://fosstodon.org/@HeathrTurnr ; Heather Turner
https://fosstodon.org/@trevin_flick ; Trevin Flickinger
https://fosstodon.org/@jonthegeek ; Jon Harmon
https://fosstodon.org/@samherniman ; Sam Herniman
https://mastodon.social/@SagePhoenixDM ; Alan Jackson
https://fosstodon.org/@ivelasq3 ; Isabella Velásquez
https://mastodon.social/@bhogale ; Prasanna Bhogale
https://fosstodon.org/@Drmowinckels ; Mo - Athanasia Mowinckel
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
# Remove ProjectID from .Rproj files if freshly added | |
local({ | |
xfun <- requireNamespace("xfun", quietly = TRUE) | |
rproj_files <- list.files(pattern = "\\.Rproj$", full.names = TRUE) | |
if (!xfun || length(rproj_files) == 0L) return(invisible(NULL)) | |
lapply(rproj_files, function(f) { | |
diff_cmd <- system(paste("git diff --", shQuote(f)), intern = TRUE) | |
diff_out <- tryCatch(diff_cmd, error = function(e) character(0)) |
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
# What do i want from an object oriented R class system? | |
# opt-in public immutability - neither. Accomplished with private property with active binding in R6 | |
# interior mutability - R6 | |
# type safety - S7 | |
# self-referential methods - R6 | |
# private methods don't have any type safety they can be whatever you want. | |
# immutables can only be set at creation and class doesn't matter | |
# Each .public & .private element must be named |
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
# Top-level | |
thefuck <- function(e = rlang::last_error()) { | |
stopifnot(rlang::is_call_simple(e$call)) | |
if (grep("^unused argument", e$message)) { | |
fix_unused_arg(e) | |
} | |
# ... more cases | |
} | |
# Internal methods |
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
n | 1 | 2 | 4 | 8 | 16 | |
---|---|---|---|---|---|---|
dplyr | 5093.77 | 2671.44 | 1447.21 | 810.42 | 446.06 | |
data.table | 1336.79 | 677.94 | 364.5 | 217.75 | 143.95 |
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
# Clone repo | |
git clone https://github.com/keaven/gsDesign.git | |
cd gsDesign | |
# Run gource - this will generate a 411GB ppm file | |
gource -3840x2160 --seconds-per-day 0.1 --auto-skip-seconds 0.01 --file-idle-time 0 --font-size 34 --key --logo man/figures/logo.png -o gsDesign.ppm | |
# Convert ppm to mp4 | |
ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i gsDesign.ppm -vcodec libx264 -preset medium -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 gsDesign.mp4 | |
# Merge audio to video | |
ffmpeg -i gsDesign.mp4 -i music.mp3 -c:v copy -c:a aac output.mp4 | |
# Recommended by YouTube |
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
data(diamonds, package = "ggplot2") | |
# Most straightforward | |
diamonds$ppc <- diamonds$price / diamonds$carat | |
# Avoid repeating diamonds | |
diamonds$ppc <- with(diamonds, price / carat) | |
# The inspiration for dplyr's mutate | |
diamonds <- transform(diamonds, ppc = price / carat) |
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(rvest) | |
library(jsonlite) | |
downloads_from_conda = function(pkg) { | |
x = read_html(paste0("https://anaconda.org/search?q=r-", pkg)) | |
tb = html_nodes(x, "table") %>% html_table() | |
if(length(tb) > 0) { | |
tb = tb[[1]] | |
sum(tb[, 2]) | |
} else { | |
0 |
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
> ############################################################################ | |
> | |
> # A comparison of for-loops versus apply() and sapply() for 1) computing the | |
> # row means in a matrix and 2) for computing the means of all elements in a | |
> # list. For task 1), we can also examine the performance of rowMeans() as a | |
> # specialized / vectorized function and for task 2), we can also compare | |
> # sapply() with vapply() (note: vapply() was added in version R-2.12.0). Also, | |
> # for the for-loop, we can examine what the impact is of pre-allocating the | |
> # vector in which to store the results versus 'growing' the vector in each | |
> # iteration. |
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
#!/usr/bin/env bash | |
# | |
# Script to query UCSC MySQL server for SNP coordinates (but could easily be | |
# repurposed to query any arbitrary database/table) | |
# | |
# Author: Kevin Ernst | |
# Date: 2 March 2019; updated 30 August 2021 | |
# Source: https://gist.github.com/ernstki/91b427d6714cdd4dd6560e5b4fb961f4 | |
# License: MIT | |
# |
NewerOlder