install.packages("readxl")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
install.packages("ggplot2")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
library(readxl)
library(ggplot2)
datos <- read_excel("Bases_Datos_Oceanografia_Hidrogeologia.xlsx", sheet = "Oceanografia_Fondo_Marino")
t.test(datos$Profundidad_m, mu = 2000, alternative = "two.sided", conf.level = 0.95)
##
## One Sample t-test
##
## data: datos$Profundidad_m
## t = 5.9715, df = 99, p-value = 3.691e-08
## alternative hypothesis: true mean is not equal to 2000
## 95 percent confidence interval:
## 2687.260 3371.275
## sample estimates:
## mean of x
## 3029.267
ggplot(datos, aes(x = Profundidad_m)) +
geom_histogram(color = "black", fill = "skyblue", bins = 30) +
geom_vline(xintercept = mean(datos$Profundidad_m), color = "red", linetype = "dashed") +
geom_vline(xintercept = 2000, color = "blue", linetype = "dotted") +
labs(title = "Distribución de Profundidad (m)",
x = "Profundidad (m)", y = "Frecuencia") +
theme_minimal()
x <- sum(datos$Presencia_Hidrocarburos == 1)
n <- length(datos$Presencia_Hidrocarburos)
prop.test(x, n, p = 0.5, alternative = "two.sided", conf.level = 0.95)
##
## 1-sample proportions test with continuity correction
##
## data: x out of n, null probability 0.5
## X-squared = 3.61, df = 1, p-value = 0.05743
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
## 0.4970036 0.6952199
## sample estimates:
## p
## 0.6
datos$Presencia_Hidrocarburos <- factor(datos$Presencia_Hidrocarburos,
levels = c(0, 1),
labels = c("Ausente", "Presente"))
ggplot(datos, aes(x = Presencia_Hidrocarburos)) +
geom_bar(fill = "orange", color = "black") +
labs(title = "Presencia de Hidrocarburos",
x = "Hidrocarburos", y = "Frecuencia") +
theme_minimal()
var_obs <- var(datos$Densidad_Sedimento_gcm3)
n_var <- length(datos$Densidad_Sedimento_gcm3)
var_hip <- 0.01 # 0.1^2
chi_sq <- (n_var - 1) * var_obs / var_hip
p_value <- 2 * min(pchisq(chi_sq, df = n_var - 1), 1 - pchisq(chi_sq, df = n_var - 1))
cat("Estadístico Chi-cuadrado:", chi_sq, "\n")
## Estadístico Chi-cuadrado: 1396.91
cat("Valor p:", p_value, "\n")
## Valor p: 0
ggplot(datos, aes(y = Densidad_Sedimento_gcm3)) +
geom_boxplot(fill = "lightgreen", color = "black") +
labs(title = "Boxplot de Densidad del Sedimento",
y = "Densidad (g/cm³)") +
theme_minimal()
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.