#View(LungCapData)
str(LungCapData)
## 'data.frame': 725 obs. of 6 variables:
## $ LungCap : num 6.47 10.12 9.55 11.12 4.8 ...
## $ Age : num 6 18 16 14 5 11 8 11 15 11 ...
## $ Height : num 62.1 74.7 69.7 71 56.9 58.7 63.3 70.4 70.5 59.2 ...
## $ Smoke : chr "no" "yes" "no" "no" ...
## $ Gender : chr "male" "female" "female" "male" ...
## $ Caesarean: chr "no" "no" "yes" "no" ...
glimpse(LungCapData)
## Rows: 725
## Columns: 6
## $ LungCap <dbl> 6.475, 10.125, 9.550, 11.125, 4.800, 6.225, 4.950, 7.325, 8.…
## $ Age <dbl> 6, 18, 16, 14, 5, 11, 8, 11, 15, 11, 19, 17, 12, 10, 10, 13,…
## $ Height <dbl> 62.1, 74.7, 69.7, 71.0, 56.9, 58.7, 63.3, 70.4, 70.5, 59.2, …
## $ Smoke <chr> "no", "yes", "no", "no", "no", "no", "no", "no", "no", "no",…
## $ Gender <chr> "male", "female", "female", "male", "male", "female", "male"…
## $ Caesarean <chr> "no", "no", "yes", "no", "no", "no", "yes", "no", "no", "no"…
skimr::skim(LungCapData)
| Name | LungCapData |
| Number of rows | 725 |
| Number of columns | 6 |
| _______________________ | |
| Column type frequency: | |
| character | 3 |
| numeric | 3 |
| ________________________ | |
| Group variables | None |
Variable type: character
| skim_variable | n_missing | complete_rate | min | max | empty | n_unique | whitespace |
|---|---|---|---|---|---|---|---|
| Smoke | 0 | 1 | 2 | 3 | 0 | 2 | 0 |
| Gender | 0 | 1 | 4 | 6 | 0 | 2 | 0 |
| Caesarean | 0 | 1 | 2 | 3 | 0 | 2 | 0 |
Variable type: numeric
| skim_variable | n_missing | complete_rate | mean | sd | p0 | p25 | p50 | p75 | p100 | hist |
|---|---|---|---|---|---|---|---|---|---|---|
| LungCap | 0 | 1 | 7.86 | 2.66 | 0.51 | 6.15 | 8.0 | 9.8 | 14.68 | ▁▃▇▆▁ |
| Age | 0 | 1 | 12.33 | 4.00 | 3.00 | 9.00 | 13.0 | 15.0 | 19.00 | ▃▅▇▇▇ |
| Height | 0 | 1 | 64.84 | 7.20 | 45.30 | 59.90 | 65.4 | 70.3 | 81.80 | ▁▅▇▇▂ |
#LUNG CAP
summary(LungCapData)
## LungCap Age Height Smoke
## Min. : 0.507 Min. : 3.00 Min. :45.30 Length:725
## 1st Qu.: 6.150 1st Qu.: 9.00 1st Qu.:59.90 Class :character
## Median : 8.000 Median :13.00 Median :65.40 Mode :character
## Mean : 7.863 Mean :12.33 Mean :64.84
## 3rd Qu.: 9.800 3rd Qu.:15.00 3rd Qu.:70.30
## Max. :14.675 Max. :19.00 Max. :81.80
## Gender Caesarean
## Length:725 Length:725
## Class :character Class :character
## Mode :character Mode :character
##
##
##
summary(LungCapData$LungCap)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.507 6.150 8.000 7.863 9.800 14.675
#ANALITICO
shapiro.test(LungCapData$LungCap)
##
## Shapiro-Wilk normality test
##
## data: LungCapData$LungCap
## W = 0.99305, p-value = 0.001886
#GRAFICO
hist(LungCapData$LungCap)
LungCapData %>%
ggplot(aes(x = LungCap)) +
geom_histogram(bins = 10, color = "#FF5733", alpha = 0.6) +
theme_ipsum() +
labs(x = "Capacidad pulmonar")
boxplot(LungCapData$LungCap , col = "blue")
qqnorm(LungCapData$LungCap)
qqline(LungCapData$LungCap, col = "blue", lwd = 3)
par(mfrow = c(1, 1))
LungCapData %>%
ggplot(aes(LungCap)) +
geom_density()
ggplot(LungCapData, aes(x=LungCap, fill = Gender)) +
geom_density(alpha=0.3) +
scale_x_continuous(limits = c(0, 15))
#AGE
#ANALITICO
shapiro.test(LungCapData$Age)
##
## Shapiro-Wilk normality test
##
## data: LungCapData$Age
## W = 0.97231, p-value = 0.0000000001763
#GRAFICO
hist(LungCapData$Age)
LungCapData %>%
ggplot(aes(x = Age)) +
geom_histogram(bins = 10, color = "#FF5733", alpha = 0.6) +
theme_ipsum() +
labs(x = "Edad")
boxplot(LungCapData$Age , col = "blue")
qqnorm(LungCapData$Age)
qqline(LungCapData$Age, col = "blue", lwd = 3)
par(mfrow = c(1, 1))
LungCapData %>%
ggplot(aes(Age)) +
geom_density()
ggplot(LungCapData, aes(x=Age, fill = Gender)) +
geom_density(alpha=0.3) +
scale_x_continuous(limits = c(0, 20))
#HEIGHT
#ANALITICO
shapiro.test(LungCapData$Height)
##
## Shapiro-Wilk normality test
##
## data: LungCapData$Height
## W = 0.99027, p-value = 0.0001006
#GRAFICO
hist(LungCapData$Height)
LungCapData %>%
ggplot(aes(x = Height)) +
geom_histogram(bins = 10, color = "#FF5733", alpha = 0.6) +
theme_ipsum() +
labs(x = "Altura")
boxplot(LungCapData$Height , col = "blue")
qqnorm(LungCapData$Height)
qqline(LungCapData$Height, col = "blue", lwd = 3)
par(mfrow = c(1, 1))
LungCapData %>%
ggplot(aes(Height)) +
geom_density()
ggplot(LungCapData, aes(x=Height, fill = Gender)) +
geom_density(alpha=0.3) +
scale_x_continuous(limits = c(40, 90))
# Análisis univariado de variables categóricas
# SMOKE
table(LungCapData$Smoke)
##
## no yes
## 648 77
prop.table(table(LungCapData$Smoke))
##
## no yes
## 0.8937931 0.1062069
chisq.test(table(LungCapData$Smoke))
##
## Chi-squared test for given probabilities
##
## data: table(LungCapData$Smoke)
## X-squared = 449.71, df = 1, p-value < 0.00000000000000022
# GRAFICO
table(LungCapData$Smoke)
##
## no yes
## 648 77
barplot(table(LungCapData$Smoke), col = rainbow(3))
ggplot(data = LungCapData, aes(x = Smoke)) +
geom_bar() +
xlab("Fumadores") +
ylab("Pacientes")
ggplot(data = LungCapData, aes(x = Smoke)) +
geom_bar(color = 'darkslategray', fill = 'steelblue') +
xlab("Fumadores") +
ylab("Pacientes") +
ggtitle("Gráfico de Barras")
LungCapData %>%
plot_frq(Smoke)
#GENDER
table(LungCapData$Gender)
##
## female male
## 358 367
prop.table(table(LungCapData$Gender))
##
## female male
## 0.4937931 0.5062069
chisq.test(table(LungCapData$Gender))
##
## Chi-squared test for given probabilities
##
## data: table(LungCapData$Gender)
## X-squared = 0.11172, df = 1, p-value = 0.7382
# GRAFICO
table(LungCapData$Gender)
##
## female male
## 358 367
barplot(table(LungCapData$Gender), col = rainbow(3))
ggplot(data = LungCapData, aes(x = Gender)) +
geom_bar() +
xlab("Género") +
ylab("Pacientes")
ggplot(data = LungCapData, aes(x = Gender)) +
geom_bar(color = 'darkslategray', fill = 'steelblue') +
xlab("Género") +
ylab("Pacientes") +
ggtitle("Gráfico de Barras")
LungCapData %>%
plot_frq(Gender)
#Caesarean
table(LungCapData$Caesarean)
##
## no yes
## 561 164
prop.table(table(LungCapData$Caesarean))
##
## no yes
## 0.7737931 0.2262069
chisq.test(table(LungCapData$Caesarean))
##
## Chi-squared test for given probabilities
##
## data: table(LungCapData$Caesarean)
## X-squared = 217.39, df = 1, p-value < 0.00000000000000022
# GRAFICO
table(LungCapData$Caesarean)
##
## no yes
## 561 164
barplot(table(LungCapData$Caesarean), col = rainbow(3))
ggplot(data = LungCapData, aes(x = Caesarean)) +
geom_bar() +
xlab("Nacidos por cesárea") +
ylab("Pacientes")
ggplot(data = LungCapData, aes(x = Caesarean)) +
geom_bar(color = 'darkslategray', fill = 'steelblue') +
xlab("Nacidos por cesárea") +
ylab("Pacientes") +
ggtitle("Gráfico de Barras")
LungCapData %>%
plot_frq(Caesarean)
# Análisis bivariado entre capacidad pulmonar y edad
cor.test(LungCapData$LungCap, LungCapData$Age, method = "pearson")
##
## Pearson's product-moment correlation
##
## data: LungCapData$LungCap and LungCapData$Age
## t = 38.476, df = 723, p-value < 0.00000000000000022
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.7942660 0.8422217
## sample estimates:
## cor
## 0.8196749
ggplot(LungCapData, aes(x = LungCap, y = Age, color = Gender)) +
geom_point() +
labs(title = "Relación entre capacidad pulmonar y edad",
x = "Capacidad pulmonar",
y = "Edad") +
theme_minimal()
library(GGally)
## Registered S3 method overwritten by 'GGally':
## method from
## +.gg ggplot2
ggpairs(LungCapData, columns = c("LungCap", "Age"),
aes(color = Gender, alpha = 0.5)) +
theme_minimal()
# Análisis bivariado entre capacidad pulmoanr y género
wilcox.test(LungCapData$LungCap ~ LungCapData$Gender)
##
## Wilcoxon rank sum test with continuity correction
##
## data: LungCapData$LungCap by LungCapData$Gender
## W = 53624, p-value = 0.00001864
## alternative hypothesis: true location shift is not equal to 0
ggplot(LungCapData, aes(x = LungCap, y = Gender, color = Smoke)) +
geom_point() +
labs(title = "Relación entre capacidad pulmonar y género",
x = "Capacidad pulmonar",
y = "Género") +
theme_minimal()
library(GGally)
ggpairs(LungCapData, columns = c("LungCap", "Gender"),
aes(color = Gender, alpha = 0.5)) +
theme_minimal()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# Análisis bivariado entre hábito tabáquico y género
chisq.test(LungCapData$Gender, LungCapData$Smoke)
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: LungCapData$Gender and LungCapData$Smoke
## X-squared = 1.7443, df = 1, p-value = 0.1866
ggplot(LungCapData, aes(x = Gender, fill = Smoke)) +
geom_bar () +
labs(title = "Relación entre género y hábito tabáquico",
x = "Género",
y = "Hábito tabáquico") +
theme_minimal()
library(gtsummary)
glimpse(LungCapData)
## Rows: 725
## Columns: 6
## $ LungCap <dbl> 6.475, 10.125, 9.550, 11.125, 4.800, 6.225, 4.950, 7.325, 8.…
## $ Age <dbl> 6, 18, 16, 14, 5, 11, 8, 11, 15, 11, 19, 17, 12, 10, 10, 13,…
## $ Height <dbl> 62.1, 74.7, 69.7, 71.0, 56.9, 58.7, 63.3, 70.4, 70.5, 59.2, …
## $ Smoke <chr> "no", "yes", "no", "no", "no", "no", "no", "no", "no", "no",…
## $ Gender <chr> "male", "female", "female", "male", "male", "female", "male"…
## $ Caesarean <chr> "no", "no", "yes", "no", "no", "no", "yes", "no", "no", "no"…
LungCapData %>%
tbl_summary()
| Characteristic | N = 7251 |
|---|---|
| LungCap | 8.00 (6.15, 9.80) |
| Age | 13.0 (9.0, 15.0) |
| Height | 65 (60, 70) |
| Smoke | 77 (11%) |
| Gender | |
| female | 358 (49%) |
| male | 367 (51%) |
| Caesarean | 164 (23%) |
| 1 Median (Q1, Q3); n (%) | |
LungCapData %>%
select(Age, Gender, LungCap, Height, Smoke, Caesarean) %>%
tbl_summary()
| Characteristic | N = 7251 |
|---|---|
| Age | 13.0 (9.0, 15.0) |
| Gender | |
| female | 358 (49%) |
| male | 367 (51%) |
| LungCap | 8.00 (6.15, 9.80) |
| Height | 65 (60, 70) |
| Smoke | 77 (11%) |
| Caesarean | 164 (23%) |
| 1 Median (Q1, Q3); n (%) | |