Skip to content

Commit

Permalink
desarrollo
Browse files Browse the repository at this point in the history
  • Loading branch information
vninamore committed Aug 10, 2021
0 parents commit a839dc3
Show file tree
Hide file tree
Showing 111 changed files with 1,817 additions and 0 deletions.
Binary file added .RData
Binary file not shown.
512 changes: 512 additions & 0 deletions .Rhistory

Large diffs are not rendered by default.

Binary file added gganim_plot0001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0008.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0009.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0011.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0012.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0013.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0014.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0015.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0016.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0017.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0018.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0019.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0020.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0021.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0022.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0023.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0025.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gganim_plot0026.png
Binary file added gganim_plot0027.png
Binary file added gganim_plot0028.png
Binary file added gganim_plot0029.png
Binary file added gganim_plot0030.png
Binary file added gganim_plot0031.png
Binary file added gganim_plot0032.png
Binary file added gganim_plot0033.png
Binary file added gganim_plot0034.png
Binary file added gganim_plot0035.png
Binary file added gganim_plot0036.png
Binary file added gganim_plot0037.png
Binary file added gganim_plot0038.png
Binary file added gganim_plot0039.png
Binary file added gganim_plot0040.png
Binary file added gganim_plot0041.png
Binary file added gganim_plot0042.png
Binary file added gganim_plot0043.png
Binary file added gganim_plot0044.png
Binary file added gganim_plot0045.png
Binary file added gganim_plot0046.png
Binary file added gganim_plot0047.png
Binary file added gganim_plot0048.png
Binary file added gganim_plot0049.png
Binary file added gganim_plot0050.png
Binary file added gganim_plot0051.png
Binary file added gganim_plot0052.png
Binary file added gganim_plot0053.png
Binary file added gganim_plot0054.png
Binary file added gganim_plot0055.png
Binary file added gganim_plot0056.png
Binary file added gganim_plot0057.png
Binary file added gganim_plot0058.png
Binary file added gganim_plot0059.png
Binary file added gganim_plot0060.png
Binary file added gganim_plot0061.png
Binary file added gganim_plot0062.png
Binary file added gganim_plot0063.png
Binary file added gganim_plot0064.png
Binary file added gganim_plot0065.png
Binary file added gganim_plot0066.png
Binary file added gganim_plot0067.png
Binary file added gganim_plot0068.png
Binary file added gganim_plot0069.png
Binary file added gganim_plot0070.png
Binary file added gganim_plot0071.png
Binary file added gganim_plot0072.png
Binary file added gganim_plot0073.png
Binary file added gganim_plot0074.png
Binary file added gganim_plot0075.png
Binary file added gganim_plot0076.png
Binary file added gganim_plot0077.png
Binary file added gganim_plot0078.png
Binary file added gganim_plot0079.png
Binary file added gganim_plot0080.png
Binary file added gganim_plot0081.png
Binary file added gganim_plot0082.png
Binary file added gganim_plot0083.png
Binary file added gganim_plot0084.png
Binary file added gganim_plot0085.png
Binary file added gganim_plot0086.png
Binary file added gganim_plot0087.png
Binary file added gganim_plot0088.png
Binary file added gganim_plot0089.png
Binary file added gganim_plot0090.png
Binary file added gganim_plot0091.png
Binary file added gganim_plot0092.png
Binary file added gganim_plot0093.png
Binary file added gganim_plot0094.png
Binary file added gganim_plot0095.png
Binary file added gganim_plot0096.png
Binary file added gganim_plot0097.png
Binary file added gganim_plot0098.png
Binary file added gganim_plot0099.png
Binary file added gganim_plot0100.png
180 changes: 180 additions & 0 deletions parcial.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
install.packages("tidyverse")
library(tidyverse)
install.packages("ggplot2")
library(ggplot2)
install.packages("sf")
library(sf)
install.packages("raster")
library(raster)
library(rgdal)
library(dplyr)



#1
tangente_hiperbolica<-seq(-10,10,0.5)
tangente_hiperbolica
tanh<-function(a){
r<-(exp(2*a)-1)/(exp(2*a)+1)
return(r)
}
solucion<-tanh(tangente_hiperbolica)
plot(tangente_hiperbolica,solucion,type="l")

#2

ecua_regresion<-function(v1,v2){
X1<-c()
Y2<-c()
for(i in 1:length(v1)){
x<-log10(v1[i])
y<-log10(v2[i])
X1<-c(X1,x)
Y2<-c(Y2,y)
}
multip<-X1*Y2
X1_alcuadrado<-X1^2
n<-length(v1)
B<-((n*sum(multip))-(sum(X1)*sum(Y2)))/((n*sum(X1_alcuadrado))-(sum(X1))^2)
A<-10^(mean(Y2)-B*mean(X1))
return(c(A,B))
}
x<-c(2.5,3,4,5,5.5,6,7)
y<-c(12.5,10,7,4.5,4,3,3.5)
ecua_regresion(x,y)

# 3
AyP <- function (l1, l2, l3 ) {
p <- sum(l1, l2, l3)
area <- sqrt(p/2*(p/2-l1)*(p/2-l2)*(p/2-l3))
return(c(area, p))

}
AyP(4,11,8)



# 4
TiemCo <- function ( L , CN , S ) {
resultado <- ( 0.0136*( L ^ 0.8 )*((( 1000 / CN ) - 9)^0.7))/S^0.5
return(resultado)
}
TiemCo(6,15,8)

#5
CSSE<-function(v,r){
m<-matrix(v,ncol = 3)
ds<-det(m)
for (n in 1:length(r)) {
if(n==1){
m<-matrix(v,ncol = 3)
m[,n]<-r
dx<-det(m)
}else if(n==2){
m<-matrix(v,ncol = 3)
m[,n]<-r
dy<-det(m)
}else{
m<-matrix(v,ncol = 3)
m[,n]<-r
dz<-det(m)
}
}
x<-dx/ds
y<-dy/ds
z<-dz/ds
r<-c(x,y,z)
return(r)
}
variables_xyz<-c(2,5,1,1,-4,-1,3,1,-4)
resul_de_SE<-c(7,-19,4)
CSSE(variables_xyz,resul_de_SE)

#PARTE2

#1)

setwd("D:/R/progra1/parcial")
cuenca<- sf::st_read("uh_datos.shp")
#a)
datos <- readOGR(dsn = ".", layer= "uh_datos")
data_nueva<-datos@data
head(data_nueva)
pp_prom<-data_nueva %>%
group_by(AAA) %>%
summarise(promedio_AAA=mean(pcp))
View(pp_prom)

ggplot(pp_prom, aes(AAA, promedio_AAA)) +
geom_point(color = "purple")+
labs(y="promedio_AAA", x = "AAA")+
ggtitle("Precipitacion promedio por Autoridad AAA")

#b)

View(pp_prom)
View(data_nueva)
indic_ar<- data_nueva %>%
group_by(NOMBRE) %>%
summarise(ia=(pcp/pet))
View(indic_ar)

#c)
indic_ar<- data_nueva %>%
group_by(NOMBRE) %>%
summarise(ia=(pcp/pet))
View(indic_ar)
ia<- indic_ar$ia

clasificacionIA<-c()
for(a in ia){
if(1<=a){
f<- print("Húmedo")
}else if(0.7<=a){
f<- print("Subhúmedo húmedo")
}else if(0.5<=a){
f<- print("Subhúmedo seco")
}else if(0.2<=a){
f<- print("semiarido")
}else if(10.05<=a){
f<- print("arido")
}else if(0<=a){
f<- print("Hiperarido")
}
clasificacionIA<-c(f,clasificacionIA)
}
length(clasificacionIA)
clasif<-tibble(indic_ar, clasificacionIA)
view(clasif)

#d)
ggplot(data = data_nueva, mapping = aes(x = AAA, y = pcp)) +
geom_boxplot()

data_nueva %>%
filter(AAA== "X")

ggplot(data = data_nueva, mapping = aes(x = AAA, y = pet)) +
geom_boxplot()+scale_fill_brewer(palette="Dark2")

#2)
codigo <- c("A","B","C","D","E","F","A")
ESTE <- c(272841.7, 272893.6, 272892.5, 272913.8, 272911.2, 272837.5, 272841.7)
NORTE <- c(8666459.9, 8666456.9, 8666446.1, 8666441.5, 8666399.9, 8666407.9, 8666459.9)
df1<-data.frame(codigo,ESTE,NORTE)
head(df1)
poligono<-function(codigo, ESTE, NORTE){
objeto_sf<- st_as_sf(df1, coords = c("ESTE", "NORTE"),crs = st_crs(32718))
return(plot(objeto_sf, type= "l"))
}
poligono(df1)









#------------------------------
194 changes: 194 additions & 0 deletions parcial_res.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
install.packages("tidyverse")
library(tidyverse)
install.packages("ggplot2")
library(ggplot2)
install.packages("sp")
library(sp)
install.packages("sf")
library(sf)
install.packages("raster")
library(raster)
library(rgdal)
library(dplyr)
install.packages("gganimate")
library(gganimate)
install.packages("gganimate")
library(gganimate)
#1
tangente_hiperbolica<-seq(-10,10,0.5)
tangente_hiperbolica
tanh<-function(a){
r<-(exp(2*a)-1)/(exp(2*a)+1)
return(r)
}
solucion<-tanh(tangente_hiperbolica)
plot(tangente_hiperbolica,solucion,type="l")

#2

ecua_regresion<-function(v1,v2){
X1<-c()
Y2<-c()
for(i in 1:length(v1)){
x<-log10(v1[i])
y<-log10(v2[i])
X1<-c(X1,x)
Y2<-c(Y2,y)
}
multip<-X1*Y2
X1_alcuadrado<-X1^2
n<-length(v1)
B<-((n*sum(multip))-(sum(X1)*sum(Y2)))/((n*sum(X1_alcuadrado))-(sum(X1))^2)
A<-10^(mean(Y2)-B*mean(X1))
return(c(A,B))
}
x<-c(2.5,3,4,5,5.5,6,7)
y<-c(12.5,10,7,4.5,4,3,3.5)
ecua_regresion(x,y)

# 3
AyP <- function (l1, l2, l3 ) {
p <- sum(l1, l2, l3)
area <- sqrt(p/2*(p/2-l1)*(p/2-l2)*(p/2-l3))
return(c(area, p))

}
AyP(4,11,8)



# 4
TiemCo <- function ( L , CN , S ) {
resultado <- ( 0.0136*( L ^ 0.8 )*((( 1000 / CN ) - 9)^0.7))/S^0.5
return(resultado)
}
TiemCo(6,15,8)

#5
CSSE<-function(v,r){
m<-matrix(v,ncol = 3)
ds<-det(m)
for (n in 1:length(r)) {
if(n==1){
m<-matrix(v,ncol = 3)
m[,n]<-r
dx<-det(m)
}else if(n==2){
m<-matrix(v,ncol = 3)
m[,n]<-r
dy<-det(m)
}else{
m<-matrix(v,ncol = 3)
m[,n]<-r
dz<-det(m)
}
}
x<-dx/ds
y<-dy/ds
z<-dz/ds
r<-c(x,y,z)
return(r)
}
variables_xyz<-c(2,5,1,1,-4,-1,3,1,-4)
resul_de_SE<-c(7,-19,4)
CSSE(variables_xyz,resul_de_SE)

#PARTE2

#1)

setwd("D:/R/progra1/parcial")
cuenca<- sf::st_read("uh_datos.shp")
#a)
datos <- readOGR(dsn = ".", layer= "uh_datos")
data_nueva<-datos@data
head(data_nueva)
pp_prom<-data_nueva %>%
group_by(AAA) %>%
summarise(promedio_AAA=mean(pcp))
View(pp_prom)

ggplot(pp_prom, aes(AAA, promedio_AAA, color= promedio_AAA)) +
geom_point()+
labs(y="promedio_AAA", x = "AAA")+
ggtitle("Precipitacion promedio por Autoridad AAA")+
scale_color_gradient(low="blue", high="red")+
transition_reveal(promedio_AAA)

#b)

View(pp_prom)
View(data_nueva)
indic_ar<- data_nueva %>%
group_by(NOMBRE) %>%
summarise(ia=(pcp/pet))
View(indic_ar)

#c)
indic_ar<- data_nueva %>%
group_by(NOMBRE) %>%
summarise(ia=(pcp/pet))
View(indic_ar)
ia<- indic_ar$ia

clasificacionIA<-c()
for(a in ia){
if(1<=a){
f<- print("Húmedo")
}else if(0.7<=a){
f<- print("Subhúmedo húmedo")
}else if(0.5<=a){
f<- print("Subhúmedo seco")
}else if(0.2<=a){
f<- print("semiarido")
}else if(10.05<=a){
f<- print("arido")
}else if(0<=a){
f<- print("Hiperarido")
}
clasificacionIA<-c(f,clasificacionIA)
}
length(clasificacionIA)
clasif<-tibble(indic_ar, clasificacionIA)
clasificacionIA %>%

#d)
g1<-ggplot(data = data_nueva, mapping = aes(x = AAA, y = pcp, color= AAA)) +
geom_boxplot()


data_nueva %>%
filter(AAA== "X")


g2<-ggplot(data = data_nueva, mapping = aes(x = AAA, y = pet, fill= AAA)) +
geom_boxplot()+scale_fill_brewer(palette="Paired")





#2)
codigo <- c("A","B","C","D","E","F","A")
ESTE <- c(272841.7, 272893.6, 272892.5, 272913.8, 272911.2, 272837.5, 272841.7)
NORTE <- c(8666459.9, 8666456.9, 8666446.1, 8666441.5, 8666399.9, 8666407.9, 8666459.9)
df1<-data.frame(codigo,ESTE,NORTE)
head(df1)
poligono<-function(codigo, ESTE, NORTE){
objeto_sf<- st_as_sf(df1, coords = c("ESTE", "NORTE"),crs = st_crs(32718))
graf<-ggplot(objeto_sf, mapping = aes(ESTE, NORTE))+
geom_polygon()+geom_label(aes(label=codigo))+
scale_color_gradient(low="green", high="orange")
return(graf)
}
poligono(df1)









#------------------------------
Loading

0 comments on commit a839dc3

Please sign in to comment.