library("dplyr")
library("ggplot2")
library("tidyr")
library("readr")
library("car") # para sp
df <- read.csv("mediciones.csv", header = T, sep = ",")
str(df)
'data.frame': 108 obs. of 7 variables:
$ Tipo : Factor w/ 2 levels "Lesion","Sellante": 1 1 1 2 2 2 1 1 1 2 ...
$ Muestra : Factor w/ 18 levels "A1","A2","A3",..: 1 1 1 1 1 1 2 2 2 2 ...
$ Muestra.2: int 1 1 1 1 1 1 2 2 2 2 ...
$ Grupo : Factor w/ 3 levels "A","B","C": 1 1 1 1 1 1 1 1 1 1 ...
$ N : int 1 2 3 4 5 6 7 8 9 10 ...
$ Angulo : num 90 17.4 18.4 21.8 18.4 ...
$ LD : num 0.097 0.102 0.077 0.019 0.019 0.022 0.546 0.228 0.134 0.023 ...
df$Muestra.2 <- as.factor(df$Muestra.2)
df$N <- as.factor(df$N)
levels(df$Grupo)[levels(df$Grupo)=="A"] <- "H3PO4"
levels(df$Grupo)[levels(df$Grupo)=="B"] <- "H3PO4 + NaOCL"
levels(df$Grupo)[levels(df$Grupo)=="C"] <- "NaOCL + H3PO4"
df$LD <- df$LD*1000 # convierto a micrones
df2 <- read.csv("mediciones_2.csv", header = T, sep = ",", encoding = "UTF-8")
df2$Lesión <- df2$Lesión*100
df2$Sellante <- df2$Sellante*100
tbl_df(df2)
df3 <- read.csv("mediciones_3.csv", header = T, sep = ";")
str(df3)
'data.frame': 67 obs. of 9 variables:
$ Tipo : Factor w/ 2 levels "","Lesion": 2 2 2 2 2 2 2 2 2 2 ...
$ Muestra : Factor w/ 19 levels "","A1","A2","A3",..: 2 2 2 3 3 3 4 4 4 5 ...
$ Muestra.2 : int 1 1 1 2 2 2 3 3 3 4 ...
$ Grupo : Factor w/ 4 levels "","A","B","C": 2 2 2 2 2 2 2 2 2 2 ...
$ N : int 3 1 2 7 8 9 13 14 15 19 ...
$ AnguloLesion : num 18.4 90 17.4 -20.8 -13.1 ...
$ Lesion : num 0.077 0.097 0.102 0.546 0.228 0.134 0.827 0.126 0.122 0.591 ...
$ AnguloSellante: num 18.43 21.8 18.43 -7.12 -3.81 ...
$ Sellante : num 0.022 0.019 0.019 0.047 0.037 0.023 0.032 0.032 0.018 0.095 ...
df3$Lesion <- df3$Lesion*100
df3$Sellante <- df3$Sellante*100
df3$Muestra.2 <- as.factor(df3$Muestra.2)
df3 <- na.omit(df3) #omito los NA
df3 <- df3 %>%
mutate(Porcentaje.Penetracion = (Sellante/Lesion)*100)
levels(df3$Grupo)[levels(df3$Grupo)=="A"] <- "H3PO4"
levels(df3$Grupo)[levels(df3$Grupo)=="B"] <- "H3PO4 + NaOCL"
levels(df3$Grupo)[levels(df3$Grupo)=="C"] <- "NaOCL + H3PO4"
df3 <- df3 %>%
filter(Lesion <60)
df %>%
group_by(Grupo) %>%
summarise( n= n(), "Promedio lesión um" = mean(LD), DE = sd(LD)) %>%
ungroup()
df %>%
group_by(Tipo) %>%
summarise( n= n(), "Promedio um" = mean(LD), DE = sd(LD)) %>%
ungroup()
df %>%
filter(Tipo == "Sellante") %>%
ggplot(aes(x=Grupo, y=LD)) + geom_boxplot() +
ggtitle("Profundidad penetración sellante por grupo") +
labs(x="Grupo", y= "Profundidad " * mu ~ "m" ) +
ylim(0,350) +
theme_minimal()
df %>%
filter(Tipo == "Lesion") %>%
ggplot(aes(x=Grupo, y=LD)) + geom_boxplot() +
ggtitle("Profundidad lesión grupo") +
labs(x="Grupo", y= "Profundidad " * mu ~ "m" ) +
ylim(0,350) +
theme_minimal()
ggplot(aes(y = LD, x = Grupo, fill = Tipo), data = df) +
geom_boxplot() +
ggtitle("Profundidad de lesiones y penetracion de sellante por grupo") +
labs(x="Grupo",y= "Profundidad en (" * mu ~ "m)" ) +
theme_minimal()
df3 %>%
group_by(Grupo) %>%
summarise(
n = n(),
Promedio.Lesion=mean(Lesion), SD.Lesion=sd(Lesion),
Promedio.Sellante=mean(Sellante), SD.Sellante=sd(Sellante),
Promedio.Penetracion=mean(Porcentaje.Penetracion), SD.Penetracion=sd(Porcentaje.Penetracion)
)
anova.lesion <- aov(df3$Lesion~df3$Grupo)
anova.lesion
summary(anova.lesion)
Df Sum Sq Mean Sq F value Pr(>F)
df3$Grupo 2 1218 609.1 3.969 0.0251 *
Residuals 50 7674 153.5
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
TukeyHSD(anova.lesion, conf.level = 0.95)
Tukey multiple comparisons of means
95% family-wise confidence level
Fit: aov(formula = df3$Lesion ~ df3$Grupo)
$`df3$Grupo`
diff lwr upr p adj
H3PO4 + NaOCL-H3PO4 -9.873529 -19.9935623 0.2465035 0.0572316
NaOCL + H3PO4-H3PO4 0.470915 -9.6491179 10.5909479 0.9930604
NaOCL + H3PO4-H3PO4 + NaOCL 10.344444 0.3700311 20.3188578 0.0405094
anova.sellante <- aov(df3$Sellante~df3$Grupo)
anova.sellante
Call:
aov(formula = df3$Sellante ~ df3$Grupo)
Terms:
df3$Grupo Residuals
Sum of Squares 77.7382 1157.3629
Deg. of Freedom 2 50
Residual standard error: 4.81116
Estimated effects may be unbalanced
summary(anova.sellante)
Df Sum Sq Mean Sq F value Pr(>F)
df3$Grupo 2 77.7 38.87 1.679 0.197
Residuals 50 1157.4 23.15
ggplot(aes(y = Porcentaje.Penetracion, x = Grupo), data = df2) +
geom_boxplot() +
ggtitle("Porcentaje de penetración del sellante en lesión por grupo") +
labs(x="Grupo",y= "Porcentaje de penetración" ) +
ylim(0,100) +
theme_minimal()
ggplot(aes(y = Porcentaje.Penetracion, x = Grupo), data = df3) +
geom_boxplot() +
ggtitle("Porcentaje de penetración del sellante en lesión por grupo") +
labs(x="Grupo",y= "Porcentaje de penetración" ) +
ylim(0,100) +
theme_minimal()
acido <- df2 %>%
filter(Grupo == "H3PO4")
acido.desprot <- df2 %>%
filter(Grupo == "H3PO4 + NaOCL")
desprot.acido <- df2 %>%
wilcox.test(acido$Porcentaje.Penetracion)
Wilcoxon signed rank test
data: acido$Porcentaje.Penetracion
V = 21, p-value = 0.03125
alternative hypothesis: true location is not equal to 0
wilcox.test(acido.desprot$Porcentaje.Penetracion)
Wilcoxon signed rank test
data: acido.desprot$Porcentaje.Penetracion
V = 21, p-value = 0.03125
alternative hypothesis: true location is not equal to 0
wilcox.test(desprot.acido$Porcentaje.Penetracion)
Wilcoxon signed rank test
data: desprot.acido$Porcentaje.Penetracion
V = 21, p-value = 0.03125
alternative hypothesis: true location is not equal to 0
m1 <- aov(df2$Porcentaje.Penetracion~df2$Grupo)
summary(m1)
Df Sum Sq Mean Sq F value Pr(>F)
df2$Grupo 2 129 64.4 0.113 0.894
Residuals 15 8547 569.8
m1
Call:
aov(formula = df2$Porcentaje.Penetracion ~ df2$Grupo)
Terms:
df2$Grupo Residuals
Sum of Squares 128.897 8546.594
Deg. of Freedom 2 15
Residual standard error: 23.86992
Estimated effects may be unbalanced
ggplot(df2, aes(Sellante, Lesión, color=Grupo, shape = Grupo)) +
geom_point(size = 3) +
xlab("Profundidad penetración sellante en um") + ylab("Profundidad lesión en um") +
labs(title = "Relación entre profundidad de la lesión y penetración del sellante") +
ylim(0, 120) + xlim(0, 75) +
geom_smooth(method="lm", fill=NA) +
theme_minimal()
layout(matrix(c(1,2,3,4),2,2))
plot(m1)
m2 <- aov(df3$Lesion ~ df3$Grupo)
m2
Call:
aov(formula = df3$Lesion ~ df3$Grupo)
Terms:
df3$Grupo Residuals
Sum of Squares 1218.287 7673.645
Deg. of Freedom 2 50
Residual standard error: 12.38842
Estimated effects may be unbalanced
summary(m3)
Df Sum Sq Mean Sq F value Pr(>F)
df3$Grupo 2 77.7 38.87 1.679 0.197
Residuals 50 1157.4 23.15
m3 <- aov(df3$Sellante ~ df3$Grupo)
m3
Call:
aov(formula = df3$Sellante ~ df3$Grupo)
Terms:
df3$Grupo Residuals
Sum of Squares 77.7382 1157.3629
Deg. of Freedom 2 50
Residual standard error: 4.81116
Estimated effects may be unbalanced
summary(m3)
Df Sum Sq Mean Sq F value Pr(>F)
df3$Grupo 2 77.7 38.87 1.679 0.197
Residuals 50 1157.4 23.15
m4 <- lm(Porcentaje.Penetracion~Grupo, data = df3)
m4
Call:
lm(formula = Porcentaje.Penetracion ~ Grupo, data = df3)
Coefficients:
(Intercept) GrupoH3PO4 + NaOCL GrupoNaOCL + H3PO4
33.318 1.238 -1.715
summary(m4)
Call:
lm(formula = Porcentaje.Penetracion ~ Grupo, data = df3)
Residuals:
Min 1Q Median 3Q Max
-26.284 -17.933 -7.921 14.128 74.310
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 33.318 5.915 5.632 8.11e-07 ***
GrupoH3PO4 + NaOCL 1.238 8.249 0.150 0.881
GrupoNaOCL + H3PO4 -1.715 8.249 -0.208 0.836
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 24.39 on 50 degrees of freedom
Multiple R-squared: 0.002654, Adjusted R-squared: -0.03724
F-statistic: 0.06652 on 2 and 50 DF, p-value: 0.9357
anova(m4)
Analysis of Variance Table
Response: Porcentaje.Penetracion
Df Sum Sq Mean Sq F value Pr(>F)
Grupo 2 79.1 39.57 0.0665 0.9357
Residuals 50 29743.7 594.87
Chequeo normalidad
shapiro.test(residuals(m4))
Shapiro-Wilk normality test
data: residuals(m4)
W = 0.86277, p-value = 2.168e-05
do.call("rbind", with(df3, tapply(Porcentaje.Penetracion, Grupo,
function(x) unlist(shapiro.test(x)[c("statistic", "p.value")]))))
statistic.W p.value
H3PO4 0.7127640 0.0001618666
H3PO4 + NaOCL 0.8650695 0.0147722784
NaOCL + H3PO4 0.9135844 0.0995283649
ggplot(df3, aes(Sellante, Lesion, color=Grupo, shape = Grupo)) +
geom_point(size = 3) +
xlab("Profundidad penetración sellante en um") + ylab("Profundidad lesión en um") +
labs(title = "Relación entre profundidad de la lesión y penetración del sellante") +
ylim(0, 60) + xlim(0, 35) +
geom_smooth(method="lm", fill=NA) +
theme_minimal()
df3 %>%
group_by(Grupo) %>%
summarise( n = n(),
"Promedio profundidad lesión en um" = mean(Lesion), "Desviación estándar lesión (um)" = sd(Lesion),
"Promedio penetración sellante en um" = mean(Sellante), "Desviación estándar sellante (um)" = sd(Sellante),
"Promedio % penetración sellante" = mean(Porcentaje.Penetracion), "Desviación estándar % penetración sellante" = sd(Porcentaje.Penetracion)) %>%
ungroup()
m4 <- lm(df3$Porcentaje.Penetracion~df3$Grupo)
m4
Call:
lm(formula = df3$Porcentaje.Penetracion ~ df3$Grupo)
Coefficients:
(Intercept) df3$GrupoH3PO4 + NaOCL df3$GrupoNaOCL + H3PO4
33.318 1.238 -1.715
summary(m4)
Call:
lm(formula = df3$Porcentaje.Penetracion ~ df3$Grupo)
Residuals:
Min 1Q Median 3Q Max
-26.284 -17.933 -7.921 14.128 74.310
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 33.318 5.915 5.632 8.11e-07 ***
df3$GrupoH3PO4 + NaOCL 1.238 8.249 0.150 0.881
df3$GrupoNaOCL + H3PO4 -1.715 8.249 -0.208 0.836
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 24.39 on 50 degrees of freedom
Multiple R-squared: 0.002654, Adjusted R-squared: -0.03724
F-statistic: 0.06652 on 2 and 50 DF, p-value: 0.9357
layout(matrix(c(1,2,3,4),2,2))
plot(m1)