Skip to content

Instantly share code, notes, and snippets.

View juanchiem's full-sized avatar
😳

Juan Edwards Molina juanchiem

😳
View GitHub Profile
@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(tidyverse)
coop_dir = tempfile(fileext = ".xls")
dataURL <- "http://coopnecochea.com/web/download/lluvias/Lluvias-2020.xls"
download.file(dataURL, destfile=coop_dir)
total_2020 <- tibble(mes = coop_dir %>% readxl::excel_sheets()) %>%
mutate(data = map(mes, ~readxl::read_excel(coop_dir, sheet = .x) %>%
mutate_all(as.character))) %>%
slice(n()) %>%
unnest(cols = c(data)) %>%
library(tidyverse)
coop_dir = tempfile(fileext = ".xls")
dataURL <- "http://coopnecochea.com/web/download/lluvias/Lluvias-2021.xls"
download.file(dataURL, destfile=coop_dir)
ene_2021 <- tibble(mes = coop_dir %>% readxl::excel_sheets()) %>%
mutate(data = map(mes, ~readxl::read_excel(coop_dir, sheet = .x) %>%
mutate_all(as.character))) %>%
filter(mes=="ENE") %>%
unnest(cols = c(data)) %>%
library(tidyverse)
#temp
dates <- seq.Date(lubridate::dmy("1-6-2020"), lubridate::dmy("15-12-2020"), by = "1 day")
temp <- metR::GetSMNData(dates, type = "daily", bar = TRUE)
# temp %>% distinct(station) %>% pull()
temp %>%
filter(station == "TANDIL AERO") %>%
mutate(date = as.Date(date)) %>%
ggplot()+
# Definición matemática de los modelos logistico, gompertz e monomolecular
lo <- function(x, K, y0, r) {K/(1+((K-y0)/y0)*exp(-r*x))}
go <- function(x, K, y0, r) {K*(exp(-exp(y0-r*x)))}
mo <- function(x, K, y0, r) {K-(K-y0)*exp(-r*x)}
library(ggplot2)
# Graficar los 3 modelos con los mismos coeficientes
param = list(K=0.8, y0=0.01, r=0.3)
library(tidyverse)
# library(googlesheets4)
library(agricolae)
# gruesa <- gs4_get("1kga0p0jrgDihhoh-kEXVg5Fc5dsSBmj7zIuUOEWzVrY")
# gs4_browse(gruesa)
design.rcbd(trt = 1:10, r=4, first=F, serie=2)$sketch %>%
as_tibble() %>%
rownames_to_column("fila") %>%
dat <- tibble::tribble(
~date, ~ndvi,
"2020-05-18", 0.7655,
"2020-06-14", 0.723,
"2020-07-12", 0.6178,
"2020-08-21", 0.437,
"2020-09-07", 0.4763,
"2020-09-10", 0.4928,
"2020-09-12", 0.4831,
"2020-09-22", 0.4774,
library("tidyverse")
cebada <- tibble::tribble(
~trt, ~trat_id, ~bq, ~rend_seco,
1, "Test", 1, 7527.0792385361,
2, "Allegro 1000", 1, 7834.14085058484,
3, "Azoxy Pro 400", 1, 7105.33761425004,
1, "Test", 2, 7073.4451399919,
2, "Allegro 1000", 2, 8198.71524530747,
3, "Azoxy Pro 400", 2, 7312.61874119017,
dat <- tibble::tribble(
~fila, ~col, ~plot, ~trt, ~yield,
1, 1, 1, 1, 5879,
1, 2, 2, 2, 6278,
1, 3, 3, 3, 6114,
2, 1, 6, 2, 5965,
2, 2, 5, 3, 6208,
2, 3, 4, 1, 6179,
3, 1, 7, 3, 6833,
3, 2, 8, 1, 5904,
library("tidyverse")
dat <- tibble::tribble(
~localidad, ~hibrido, ~inc_pc, ~sevm_pc,
"Napaleufú", "Syn3970", 0, 0,
"Napaleufú", "Z74L60", 18, 3.6,
"Napaleufú", "Adv5205", 4, 0.4,
"Fulton", "Syn3970", 0, 0,
"Fulton", "Z74L60", 30, 9,
"Fulton", "Adv5205", 15, 3,
"Pablo Acosta", "Adv5205", 5, 0.75,