Skip to content

Instantly share code, notes, and snippets.

View Close-your-eyes's full-sized avatar

vonSkopnik Close-your-eyes

  • Charité / German Research Center for Rheumatism
  • Berlin
View GitHub Profile
library(tidyverse)
library(gganimate)
set.seed(777)
points <- 2* 1e3
x <- runif(points, min = -1, max=1)
y <- runif(points, min=-1, max=1)
inside <- x^2 + y^2 < 1
@kennedymwavu
kennedymwavu / .Rprofile
Last active June 18, 2023 23:00
Customize R's startup msg on Rstudio
setHook("rstudio.sessionInit", function(newSession) {
cat('\f')
hour <- format(Sys.time(), format = '%H') |> as.numeric() |> as.character()
morning <- 0:11
afternoon <- 12:16
evening <- c(17:23)
day_hrs <- rep(
@rasmusab
rasmusab / bowling-t-test.R
Created February 20, 2023 16:45
A much improved bowling T-test in R
bowling_animation_urls <- c(
"0.01" = "https://i.imgur.com/Kn8CQbj.gif",
"0.05" = "https://i.imgur.com/HFTKdDL.gif",
"0.1" = "https://i.imgur.com/8Sw54Mz.gif",
"1" = "https://i.imgur.com/kjROdhj.gif"
)
# We need to download the animations to the session temp dirercorty to display
# them in the Rstudio Viever pane
bowling_animation_html <- sapply(bowling_animation_urls, function(url) {
@rasmusab
rasmusab / chat-gtp-api-call.R
Last active June 22, 2023 06:46
How to call the ChatGTP API from R (in 2023-03-01)
# How to call the new (as of 2023-03-01) ChatGTP API from R
# Get your API key over here: https://platform.openai.com/
api_key <- "sk-5-your-actual-api-key-Fvau6" # Don't share this! 😅
library(httr)
library(stringr)
# Calls the ChatGTP API with the given promps and returns the answer
ask_chatgtp <- function(prompt) {
response <- POST(