Skip to content

Instantly share code, notes, and snippets.

View juanchiem's full-sized avatar
😳

Juan Edwards Molina juanchiem

😳
View GitHub Profile
library(ggpubr)
x <- 1:100
y <- (x + x^2 + x^3) + rnorm(length(x), mean = 0, sd = mean(x^3) / 4)
my.data <- data.frame(x, y, group = c("A", "B"),
y2 = y * c(0.5,2), block = c("a", "a", "b", "b"))
# Fit polynomial regression line and add labels
formula <- y ~ poly(x, 3, raw = TRUE)
p <- ggplot(my.data, aes(x, y2, color = group)) +
geom_point() +
# library("googledrive")
library("googlesheets4")
library("tidyverse")
library("ggpubr")
# drive_auth(use_oob = TRUE, cache = TRUE)
#
mysheets <- googledrive::drive_find(type = "spreadsheet")
mysheets
# reuse token to Sheet Auth.
# https://itsalocke.com/blog/understanding-rolling-calculations-in-r/
# https://inta.gob.ar/sites/default/files/inta_impacto_de_los_factores_ambientales_en_la_definicion_de_los_rendimientos_de_los_cultivos_resultados_de_la_campana_2013_de_trigo.pdf
# http://rafaela.inta.gov.ar/info/miscelaneas/101/trigo2004_n1.pdf
library(tidyverse)
library(lubridate)
stations <- tibble::tribble(
~station, ~lat, ~lon,
"Balcarce INTA", -37.75, -58.3,
# https://itsalocke.com/blog/understanding-rolling-calculations-in-r/
# https://inta.gob.ar/sites/default/files/inta_impacto_de_los_factores_ambientales_en_la_definicion_de_los_rendimientos_de_los_cultivos_resultados_de_la_campana_2013_de_trigo.pdf
# http://rafaela.inta.gov.ar/info/miscelaneas/101/trigo2004_n1.pdf
pacman::p_load(tidyverse, lubridate, zoo)
stations <- tibble::tribble(
~station, ~lat, ~lon,
"Balcarce INTA", -37.75, -58.3,
"Mar del Plata AERO", -37.93, -57.58,
library(tidyverse)
library(patchwork)
dat_wide <- tibble(
x = 1:3,
top = c(4.5, 4, 5.5),
middle = c(4, 4.75, 5),
bottom = c(3.5, 3.75, 4.5)
)
library(tidyverse)
library(ggforce)
tibble::tribble(
~patogeno, ~hum_min, ~hum_max, ~temp_min, ~temp_max,
"RE",3L,6L,8L,14L,
"RH",6L,10L,18L,25L,
"RT",8L,12L,20L,30L,
"MA",28L,32L,18L,28L,
"SEP",72L,96L,10L,15L) %>%
library(ggplot2)
pic <- magick::image_read("https://i.imgur.com/GOjBfBu.png")
(tibble::tribble(
~patogeno, ~hum_min, ~hum_max, ~temp_min, ~temp_max,
"Esc",48L,58L,8L,15L,
"Red",36L,46L,10L,18L,
"MB",48L,58L,20L,24L,
"Ram",16L,26L,15L,20L) %>%
library(ggplot2)
ggplot() +
geom_col(aes(x = lubridate::month(1:12, label = TRUE, abbr = T),
y = c(5,2,0,60,80,20,22,6,2,8,22,7)))+
labs(x = "", y = "pl/m²")
library(extrafont)
download.file("http://simonsoftware.se/other/xkcd.ttf",
dest="xkcd.ttf", mode="wb")
system("mkdir ~/.fonts")
system("cp xkcd.ttf ~/.fonts")
font_import(paths = "~/.fonts", pattern="[X/x]kcd")
fonts()
loadfonts()
ggplot(data.frame(x = c(0, 1)), aes(x = x)) +
@juanchiem
juanchiem / gglm
Last active March 18, 2021 17:03
Grammar of Graphics for Linear Model Diagnostics
devtools::install_github("graysonwhite/gglm")
library(gglm) # Load the package
data(mtcars) # Load example data
model <- lm(mpg ~ ., data = mtcars) # Create your model
gglm(model) #