library(ggplot2)
library(dplyr)
library(ggpubr)
library(rcompanion)
library(car)
library(googlesheets4)
En la base de datos ToothGrowth (esta ya está instalada
en R) se tienen datos de crecimiento dental de roedores con dos tipos de
suplemento de vitamina C, y a tres dosis
diente <- ToothGrowth
str(diente)
'data.frame': 60 obs. of 3 variables:
$ len : num 4.2 11.5 7.3 5.8 6.4 10 11.2 11.2 5.2 7 ...
$ supp: Factor w/ 2 levels "OJ","VC": 2 2 2 2 2 2 2 2 2 2 ...
$ dose: num 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 ...
diente
supp sobre crecimiento
dentalggplot(aes(y = len, x = supp), data = diente) +
geom_boxplot() +
geom_point(position = position_jitter(width=0.2))
dose sobre crecimiento
dentalggplot(aes(y = len, x = as.factor(dose)),
data = diente) +
geom_boxplot() +
geom_point(position = position_jitter(width = 0.3))
supp + dose sobre crecimiento dentalCada dosis tiene incluidos los dos tipos de suplemento. Y viceversa, cada tipo de suplemento tiene incluidas las tres dosis.
ggplot(aes(y = len, x = supp, col= as.factor(dose)),
data = diente) +
geom_point(position = position_jitter(width = 0.15))
ggplot(aes(y = len, x = as.factor(dose), col=supp),
data = diente) +
geom_point(position = position_jitter(width = 0.15))
NA
NA
Se necesita aislarlos entonces para saber el efecto de cada uno de los factores, por separado, en un modelo multifactorial.
ggplot(aes(y = len, x = as.factor(dose), col= supp),
data = diente) +
geom_boxplot() +
geom_point(position = position_jitter(width = 0.15))
interaction.plot(as.factor(ToothGrowth$dose),
ToothGrowth$supp,
ToothGrowth$len)
gs4_deauth()
ss= "https://docs.google.com/spreadsheets/d/1zXyXQMmiXmWIUqiwBDLEXUrq-7SH-0mxGeCX7uXSiuY/edit?usp=sharing"
hoja= "species"
rango = "B2:D92"
spp <- read_sheet(ss,
sheet= hoja,
range= rango,
col_names= TRUE
)
✔ Reading from " Deviance_Ancova_Reg_Glm".
✔ Range ''species'!B2:D92'.
spp$pH <- as.factor(spp$pH)
str(spp)
tibble [90 × 3] (S3: tbl_df/tbl/data.frame)
$ pH : Factor w/ 3 levels "a.low","b.mid",..: 1 1 1 1 1 1 1 1 1 1 ...
$ Biomass: num [1:90] 0.101 0.139 0.864 1.293 2.469 ...
$ Species: num [1:90] 18 19 15 19 12 11 15 9 3 2 ...
head(spp); tail(spp)
ggdensity(spp$Species)
shapiro.test(spp$Species)
Shapiro-Wilk normality test
data: spp$Species
W = 0.97805, p-value = 0.1317
ggplot(aes(y = Species, x=pH, col=Biomass), data= spp) +
geom_boxplot() +
geom_point(position=position_jitter(width=0.15))
ggplot(aes(y = Species, x=Biomass, col=pH), data= spp) +
geom_point()
ggplot(aes(y = Species, x = Biomass, color = pH), data= spp) +
geom_point() +
geom_smooth(method = "lm")
ggplot(aes(y = Species, x = Biomass, color = pH), data= spp) +
geom_boxplot() +
geom_point() +
geom_smooth(method = "lm")
p <- ggplot(aes(y = Species, x = Biomass, color = pH), data= spp) +
geom_point() +
geom_smooth(method = "lm")
#
ggplotly(p)
Error in ggplotly(p) : could not find function "ggplotly"