Skip to content

Instantly share code, notes, and snippets.

View darokun's full-sized avatar

Daloha Rodriguez-Molina darokun

  • Munich, Germany
View GitHub Profile
library(tidyverse)
library(here)
papers_filenames <- list.files(path = here::here("Library"),
pattern = "(201[8-9]|2020)",
full.names = TRUE)
file.copy(from = papers_filenames, to = here::here("Library", "subset"))
# PLASMID - abbreviations script
# install.packages("tidyverse") # run only if not previously installed
# install.packages("googlesheets4") # run only if not previously installed
library(tidyverse)
library(googlesheets4)
gs4_deauth() # deactivate authorization mode so it doesn't ask for google sign-in. Useful when only reading data
# read data
abb <- read_sheet("https://docs.google.com/spreadsheets/d/1ePlZC0FmFuqiq0B59wtNu4RCDEgypn_ucyBzFb8oK0g/edit#gid=0")
# install.packages("ggchicklet", repos = "https://cinc.rud.is")
library(ggchicklet)
library(tidyverse)
x <- rep(letters[1:7], seq.int(0, 30, 5))
hb <- tibble(x)
hex_codes1 <- scales::hue_pal()(length(unique(hb$x)))
p1 <- ggplot(count(hb, x), aes(x = x, y = n)) +
geom_chicklet(radius = grid::unit(2, 'mm'), fill = hex_codes1, colour = "black") +
# log_scale_exercises.R
format(1*10^-4, scientific = FALSE) # starting point: 1*10^-4 = 1e-04 = 0.0001
format(1*10^-3, scientific = FALSE) # ending point: 1*10^-3 = 1e-03 = 0.001
x <- seq(0.0001:0.001, by = 0.0001, length.out = 10) # 10 datapoints ascending from 0.0001 to 0.001
format(x, scientific = FALSE) # 0.0001, 0.0002, 0.0003, [...], 0.0008, 0.0009, 0.001
format(x, scientific = TRUE) # the same, but in scientific notation: 1e-04, 2e-04, 3e-04, [...], 8e-04, 9e-04, 1e-03
plot(x, xlim = c(0, 10), ylim = c(0.0001, 0.001), pch = 20, log = "y") # plot log scale on y axis, (intervals are not equally spaced)
plot(x, xlim = c(0, 10), ylim = c(0.0001, 0.001), pch = 20) # plot linear scale, (equally spaced intervals)
# Causallang screening process animated plot
# author: Daloha Rodriguez-Molina @darokun
# load packages
library(tidyverse)
library(gganimate)
library(readxl)
library(here)
# data
# data from http://www.edisonresearch.com/wp-content/uploads/2017/04/Podcast-Consumer-2017.pdf
library(tidyverse)
set.seed(20210311)
podcast_women <- tibble(
gender = rep("female", 2000*.44),
y2013 = sample(c("yes", "no"), size = 2000*.44, replace = TRUE, prob = c(0.09, 1 - 0.09)),
y2014 = sample(c("yes", "no"), size = 2000*.44, replace = TRUE, prob = c(0.13, 1 - 0.13)),
y2015 = sample(c("yes", "no"), size = 2000*.44, replace = TRUE, prob = c(0.16, 1 - 0.16)),
y2016 = sample(c("yes", "no"), size = 2000*.44, replace = TRUE, prob = c(0.18, 1 - 0.18)),
@darokun
darokun / cals_with_calendR
Last active December 1, 2020 14:57
Create 2020 and 2021 calendars to keep track of daily activities by crossing out days
pacman::p_load(tidyverse, suncalc, ggimage, lubridate)
src_calendR <- "https://raw.githubusercontent.com/R-CoderDotCom/calendR/master/R/calendR.R"
download.file(src_calendR, "calendR.R")
source("calendR.R") # installing package doesn't work in my system (old R version), sourcing instead.
days_until_20201130 <- seq(ymd("20200101"), ymd("20201130"), "days")
### habits to track
# arms
calendR(orientation = "landscape", pdf = TRUE, doc_name = "arms_cal2020", special.days = 1:length(days_until_20201130), special.col = "black", low.col = "white", title = "arms 2020")
calendR(year = 2021, orientation = "landscape", pdf = TRUE, doc_name = "arms_cal2021", title = "arms 2021")
# from a tweet I found around, by @WeAreRLadies maybe?
x <- 1:4
y <- 3:6
compare <- function(x, y) {
list(
"These values are in x but not in y" = setdiff(x, y),
"These values are in y but not in x" = setdiff(y, x),
"These values are shared between x and y" = intersect(x, y),
@darokun
darokun / f.R
Created September 25, 2018 12:40
ANOVA year older
install.packages("extrafont")
install.packages("extrafontdb")
library(extrafont)
library(extrafontdb)
library(ggplot2)
# make sure to install the desired font in the computer at this point
# then:
@darokun
darokun / clean_adobe_connect_session_grading_data.R
Created April 27, 2018 11:04
This is a gist to clean the spreadsheet containing grades for my students on Adobe Connect sessions
library(tidyverse)
library(readxl)
library(stringr)
xl_data <- read_excel("Feedback_Job_Interview.xlsx")
col_names <- c("student", "date", "preparation", "fluency", "grammar", "vocabulary", "questions", "grade", "comments")
colnames(xl_data) <- col_names