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:
library(ggplot2)
library(ggmap)
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
library(readxl)
library(tidyverse)
## -- Attaching packages -------------------------------------------------------------------- tidyverse 1.3.0 --
## v tibble 2.1.3 v dplyr 0.8.3
## v tidyr 1.0.2 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.4.0
## v purrr 0.3.3
## -- Conflicts ----------------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(sp)
library(maptools)
## Checking rgeos availability: FALSE
## Note: when rgeos is not available, polygon geometry computations in maptools depend on gpclib,
## which has a restricted licence. It is disabled by default;
## to enable gpclib, type gpclibPermit()
X2007sep <- read_excel("2007sep.xlsx")
View(X2007sep)
Huatabampo <- (X2007sep)
##Datos disponibles de pozos
library(DT)
datatable(X2007sep)
str(Huatabampo)
## Classes 'tbl_df', 'tbl' and 'data.frame': 293 obs. of 10 variables:
## $ MODULO: num 1 1 1 1 1 1 1 1 1 1 ...
## $ POZO : chr "1" "2" "3" "4" ...
## $ X : num 620903 620915 620943 620879 620888 ...
## $ Y : num 2962392 2963671 2964903 2965667 2966604 ...
## $ SNM : num 3.91 4.53 2.8 3.64 3.49 ...
## $ NF : num 2.68 2.61 1.3 2.14 2.01 2 1.63 2.82 3 3 ...
## $ CE : num 2.83 8.35 8.66 8.34 9.18 7.9 9.64 7.17 1.88 1.93 ...
## $ PPM : num 1811 5344 5542 5338 5875 ...
## $ PH : num 6.8 6.9 6.8 7.1 6.6 6.8 6.5 6.9 7 7 ...
## $ TEMP : num 28.5 29.2 28.9 29.4 28.3 28.4 28 27.5 28.7 28.6 ...
PPM <- Huatabampo$PPM
PH <- Huatabampo$PH
NF <- Huatabampo$NF
SNM <- Huatabampo$SNM
datos <- data.frame(PPM, PH, NF, SNM)
#Primer græfico de correlacion
pairs(datos)
cor(NF, SNM, method = c("pearson", "kendall", "spearman"))
## [1] 0.67311
cor.test(NF, SNM, method=c("pearson", "kendall", "spearman"))
##
## Pearson's product-moment correlation
##
## data: NF and SNM
## t = 15.526, df = 291, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.6052017 0.7312929
## sample estimates:
## cor
## 0.67311
ggplot(Huatabampo, aes(x = SNM, y = NF)) +
geom_point()
cor(SNM, NF, method = c("pearson", "kendall", "spearman"))
## [1] 0.67311
cor.test(SNM, NF, method=c("pearson", "kendall", "spearman"))
##
## Pearson's product-moment correlation
##
## data: SNM and NF
## t = 15.526, df = 291, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.6052017 0.7312929
## sample estimates:
## cor
## 0.67311
cor.test(PPM, PH, method=c("pearson", "kendall", "spearman"))
##
## Pearson's product-moment correlation
##
## data: PPM and PH
## t = -11.07, df = 291, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.6202473 -0.4583503
## sample estimates:
## cor
## -0.544348
# Boxplot of SNM VS NF
# Boxplot of weight vs. weeks
ggplot(data = Huatabampo,
aes(x = cut(SNM, breaks = 4), y = NF)) +
geom_boxplot()
ggplot(data = Huatabampo,
aes(x = cut(SNM, breaks = 4), y = PPM)) +
geom_boxplot()
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggmap':
##
## wind
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
Huat <- ggplot(Huatabampo, aes(x = NF, y = PPM, color = factor(MODULO))) +
geom_point()
ggplotly(Huat)
library(dplyr)
library(tidyr)
library(ggplot2)
library(broom)
library(dplyr)
Huatabampo %>%
filter(NF <=2.9 ) %>%
ggplot(aes(x = NF, y = SNM)) +
geom_point()
# Compute correlation
Huatabampo %>%
summarize(N = n(), r = cor(SNM, NF))
## # A tibble: 1 x 2
## N r
## <int> <dbl>
## 1 293 0.673
#Grafico de las variables PH y TEMP coloreadas
with(Huatabampo, plot(PH, TEMP, col=blues9))
abline(h = 12, lwd = 2, lty = 2)
#Histograma simultaneo
par(mfrow = c(2, 1), mar = c(4, 4, 2, 1))
hist(Huatabampo$X, col = "green")
hist(Huatabampo$Y, col = "red")
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.