Skip to content

Instantly share code, notes, and snippets.

View juanchiem's full-sized avatar
😳

Juan Edwards Molina juanchiem

😳
View GitHub Profile
@juanchiem
juanchiem / super-and-sub-script-labels.R
Created April 29, 2022 22:58 — forked from benmarwick/super-and-sub-script-labels.R
ggplot axis labels with superscript and subscript
AntroSO42<-read.csv("antroSO42-.csv", header = TRUE)
Bp <- AntroSO42[ ,(2:4), ]
library(tidyverse)
Bp %>%
gather(value, variable, -Class) %>%
ggplot(aes(Class,
variable)) +
geom_boxplot() +
facet_wrap( ~ value) +
@juanchiem
juanchiem / get_genotypes.R
Last active April 10, 2022 13:14 — forked from agustin-alesso/get_genotypes.R
find genotypes that are repeatead in selected environments
pacman::p_load(tidyverse)
# Fake data
full_grid <- expand_grid(
gen = paste0("G", 1:3),
loc = paste0("L", 1:3),
season = paste0("S", 1:4)
) %>%
mutate(env = paste(loc, season))
replications(~ gen * env, full_grid)
@juanchiem
juanchiem / github.R
Last active March 12, 2022 00:19 — forked from z3tt/github.R
Configure GitHub for Rstudio
#### 1. Sign up at GitHub.com ################################################
## If you do not have a GitHub account, sign up here:
## https://github.com/join
# ----------------------------------------------------------------------------
#### 2. Install git ##########################################################
## If you do not have git installed, please do so:
library(quantreg)
library(dplyr)
library(lubridate)
library(stringr)
library(readr)
library(ggplot2)
library(devtools)
library(splines)
@juanchiem
juanchiem / logistic_regression.R
Created January 11, 2021 21:52 — forked from darioappsilon/logistic_regression.R
001_logistic_regression
library(titanic)
library(Amelia)
library(dplyr)
library(modeest)
library(ggplot2)
library(cowplot)
library(mice)
library(caTools)
library(caret)
library(ggplot2)
ggplot(data = data.frame(x = c(-4, 6)), aes(x)) +
stat_function(fun = dnorm, n = 101, args = list(mean = 0, sd = 1), geom = "area", fill = "#F5BB87", alpha = 0.9) +
stat_function(fun = dnorm, n = 101, args = list(mean = 2.7, sd = 1), geom = "area", fill = "#BBD4EB", alpha = 0.9) +
coord_fixed(xlim = c(-5, 7), ratio = 8, clip = "off") +
annotate("segment", x = -3.9, y = 0, xend = 6, yend = 0, color = "grey60", size = 1.3) +
annotate("segment", x = -3.5, y = -0.04, xend = -3.5, yend = 0.42, color = "grey60", size = 1.3) +
annotate("text", x = 0, y = 0.18, label = "what people\nactually do\nin R", family = "Arial Bold", color = "white", size = 5.2) +
annotate("text", x = 2.75, y = 0.18, label = "what people\nassume others\ndo in R", family = "Arial Bold", color = "white", size = 5.2) +
library(tidyverse)
# devtools::install_github('rensa/ggflags')
library(ggflags) # https://github.com/rensa/ggflags
library(ggrepel)
library(ggthemes)
library(gganimate)
# Hecho por Rafa @GonzalezGouveia
# Con gusto para #DatosDeMiercoles, propuesto por @R4DS_es
@juanchiem
juanchiem / script_exemplo_metanalise.R
Created May 12, 2017 19:17 — forked from joaovissoci/script_exemplo_metanalise.R
example of R script for metanalysis in R
#######################################################################################
#example_metanalysis.R is licensed under a Creative Commons Attribution - Non commercial 3.0 Unported License. see full license at the end of this file.
#######################################################################################
#this script follows a combination of the guidelines proposed by Hadley Wickham http://goo.gl/c04kq as well as using the formatR package http://goo.gl/ri6ky
#if this is the first time you are conducting an analysis using this protocol, please watch http://goo.gl/DajIN while following step by step
#link to manuscript
#####################################################################################
#SETTING ENVIRONMENT
@juanchiem
juanchiem / outlierRemoval.R
Created February 27, 2017 12:20 — forked from smithdanielle/outlierRemoval.R
Outlier removal in R with MAD criterion: equations taken from [Leys et al (2013)](http://www.sciencedirect.com/science/article/pii/S0022103113000668).
require(plyr)
require(dplyr)
data.outliersRemoved<-ddply(data, .(withinIV1, withinIV2), function(d){
limits.outliers = median(d$DV) + 2.5*c(-1, 1)*mad(d$DV))
d$DV[which(((d$DV - limits.outliers[1])*(limits.outliers[2] - d$DV)) <= 0)]<-NA
return(d)
})