Skip to content

Instantly share code, notes, and snippets.

View juanchiem's full-sized avatar
😳

Juan Edwards Molina juanchiem

😳
View GitHub Profile
@juanchiem
juanchiem / ordenar_meses_summer_season.txt
Last active July 27, 2023 01:25
ordenar_meses_summer_season
gruesa <- format(ISOdate(2000, c(6:12,1:3), 1), "%B")
tibble::tribble(
~sitio, ~pp_agosto, ~pp_septiembre, ~pp_octubre, ~pp_noviembre, ~pp_diciembre, ~pp_enero, ~pp_febrero, ~pp_marzo,
"CHASCOMUS", 0, 0, 14L, 22L, 30L, 52L, 27L, 94L,
"RIVERA", 0, 50, 48L, 109L, 15L, 158L, 25L, 85L
) |>
pivot_longer(contains("pp"),
names_prefix = "pp_") |>
library(tidyverse)
library(googlesheets4)
link <- "https://docs.google.com/spreadsheets/d/1OXHDK2S2rc5pp-aGKaTwvP8bSdo5faa6YN8QGqGDl7U/edit?usp=sharing"
gs4_deauth()
meteo_eea <- gs4_get(link)
bce22 <- read_sheet(meteo_eea, sheet="2022") %>%
mutate(date = ymd(date))
bce22
# remotes::install_github("ropensci/chirps", build_vignettes = TRUE)
pacman::p_load(chirps, terra, tidyverse)
library(tidyverse)
# https://stats.stackexchange.com/questions/309047/zero-inflated-beta-regression-using-gamlss-for-vegetation-cover-data
# Since the data are percentages/proportions on the interval [0,1),
# I figured a zero inflated beta regression would be appropriate.
# I do this using the gamlss package in R:
df <- data.frame(
cover = c(0.0013,0,0.0208,0.0038,0,0,0,0.0043,
0,0.002,0.0068,0.0213,0,0.0069,0.0075,0,0,0,0.013,
pacman::p_load(tidyverse, sf, ggspatial, geodata)
# theme_set: background theme
theme_set(theme_bw()+
theme(
panel.grid.major = element_line(color = gray(0.5),
linetype = "dashed",
linewidth = 0.1),
panel.background = element_rect(fill = "aliceblue"),
axis.text.x = element_text(size = 6),
# Muy util para explorar diseños experimentales
library(tidyverse)
# Agregamos algun NA
wb <- warpbreaks %>%
add_row(breaks= c(rep(30,5), NA), wool= rep(c("A","B"), 3), tension=rep(c("L","M", "H"), 2))
head(wb)
str(wb)
# https://agronomy4future.org/?p=17137
pacman::p_load(tidyverse, nlraa, minpack.lm)
github <- "https://raw.githubusercontent.com/agronomy4future/raw_data_practice/main/sulphur%20application.csv"
dataA <- readr::read_csv(github)
# QUADRATIC PLATEAU
# to find reasonable initial values for parameters
fit.lm<-lm(yield ~ poly(sulphur,2, raw=TRUE),data=dataA)
library(segmented)
library(tidyverse)
#view DataFrame
df <- data.frame(x=c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16),
y=c(2, 4, 5, 6, 8, 10, 12, 13, 15, 19, 24, 28, 31, 34, 39, 44))
df2 <- data.frame(x=c(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)+2,
y=c(4, 5, 6, 8, 10, 12, 13, 15, 19, 24, 28, 31, 34, 39))
"https://tiagoolivoto.github.io/paper_pliman/code.html#batch-processing"
```{r}
# install.packages("BiocManager")
# BiocManager::install("EBImage")
# devtools::install_github("TiagoOlivoto/pliman")
pacman::p_load(tidyverse, pliman)
```
1. Seleccione el working directory
library(tidyverse)
dat <- tibble::tribble(
~precio_cereal, ~gasto_comer, ~ingreso_neto, ~`kg/$`, ~producto, ~costo_dosis, ~mosquito, ~costo_apli, ~rinde_obj, ~`pisada_%`, ~pisada_kg, ~costo_trat_kg, ~costo_tot_kg,
310L, 20L, 248, 4.03, "MD", 22L, 8.5, 30.5, 2500L, 2.5, 62.5, 123L, 185L,
310L, 20L, 248, 4.03, "MD", 22L, 8.5, 30.5, 3000L, 2.5, 75, 123L, 198L,
310L, 20L, 248, 4.03, "MD", 22L, 8.5, 30.5, 3500L, 2.5, 87.5, 123L, 210L,
310L, 20L, 248, 4.03, "MD", 22L, 8.5, 30.5, 4000L, 2.5, 100, 123L, 223L,
320L, 20L, 256, 3.91, "MD", 22L, 8.5, 30.5, 2500L, 2.5, 62.5, 119L,
library(tidyverse)
dat <- tibble::tribble(
~hj, ~a_1, ~a_2, ~a_3, ~a_4, ~a_5, ~c_1, ~c_2, ~c_3, ~c_4, ~c_5,
"hb", 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L,
"hb-1", 0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 1L, 3L,
"hb-2", 0L, 2L, 3L, 1L, 0L, 4L, 5L, 5L, 8L, 10L,
"hb-3", 3L, 7L, 3L, 5L, 7L, 2L, 8L, 14L, 14L, 10L
)