Skip to content

Instantly share code, notes, and snippets.

@juanchiem
Last active April 6, 2023 18:30
Show Gist options
  • Save juanchiem/e2acc96c92825ff26ea2a12b7648b847 to your computer and use it in GitHub Desktop.
Save juanchiem/e2acc96c92825ff26ea2a12b7648b847 to your computer and use it in GitHub Desktop.
# 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)
# casos completos
wb %>%
drop_na(breaks) %>%
xtabs(~ wool + tension, .) %>%
ftable
# en proporcion
wb %>%
xtabs(breaks~ wool + tension, .) %>%
prop.table()*100
#sumas de valores de breaks
wb %>%
drop_na(breaks) %>%
xtabs(breaks ~ wool + tension, .) %>%
ftable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment