df<-read.csv("mario.csv", h = T) head(df) str(df) df$data_coleta<-as.Date(df$data_coleta,"%m/%d/%Y") str(df) df <-df %>% rename("od" = "oxigenio_dissolvido", "N_nitrato" = "nitrogenio_nitrato", "data" = "data_coleta") str(df) summary(df) g_od<-ggplot(df, aes(od)) + geom_histogram(color = "black",fill= "gold",alpha=0.5, bins = 20) + scale_x_continuous(name = "OD (mg/L") + scale_y_continuous(name = "Contagem") + theme(axis.line.x = element_line(size = 0.5, colour = "black"), axis.line.y = element_line(size = 0.5, colour = "black"), axis.line = element_line(size=1, colour = "black"), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.border = element_blank(), panel.background = element_blank(), axis.text.x=element_text(size=16, face="bold"), axis.text.y=element_text(size=14, face="bold"), axis.title.y=element_text(size=16, face = "bold"), axis.title.x = element_text (size = 16, face = "bold"), legend.title = element_blank(), legend.text = element_text(size=11)) g_od g_od_cum<-ggplot(df, aes(od)) + #geom_histogram(color = "black",fill= "gold",alpha=0.5, bins = 8, binwidth = 1) + stat_ecdf(geom = "step", color="purple", size = 1.5) + scale_x_continuous(name = "OD (mg/L)", breaks=seq(0,8,1), limits=c(0,8))+ scale_y_continuous(name = "Proporção") + theme(axis.line.x = element_line(size = 0.5, colour = "black"), axis.line.y = element_line(size = 0.5, colour = "black"), axis.line = element_line(size=1, colour = "black"), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.border = element_blank(), panel.background = element_blank(), axis.text.x=element_text(size=16, face="bold"), axis.text.y=element_text(size=14, face="bold"), axis.title.y=element_text(size=16, face = "bold"), axis.title.x = element_text (size = 16, face = "bold"), legend.title = element_blank(), legend.text = element_text(size=11)) g_od_cum g_dbo_cum<-ggplot(df, aes(dbo)) + #geom_histogram(color = "black",fill= "gold",alpha=0.5, bins = 8, binwidth = 1) + stat_ecdf(geom = "step", color="purple", size = 1.5) + scale_x_continuous(name = "DBO (mg/L)", breaks=seq(0,8,1), limits=c(0,8))+ scale_y_continuous(name = "Proporção") + theme(axis.line.x = element_line(size = 0.5, colour = "black"), axis.line.y = element_line(size = 0.5, colour = "black"), axis.line = element_line(size=1, colour = "black"), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.border = element_blank(), panel.background = element_blank(), axis.text.x=element_text(size=16, face="bold"), axis.text.y=element_text(size=14, face="bold"), axis.title.y=element_text(size=16, face = "bold"), axis.title.x = element_text (size = 16, face = "bold"), legend.title = element_blank(), legend.text = element_text(size=11)) g_dbo_cum df$col = ifelse(df$od < 5,'fora', 'dentro') df$col od_nitrato<-ggplot(df, aes(od,N_nitrato)) + geom_point(aes(color = col, fill = col), size = 3, alpha = 0.4) + scale_x_continuous("OD (mg/L") + scale_y_continuous("N-nitrato (mg/L)")+ scale_color_manual(values = c("green4", "red")) + scale_fill_manual(values = c("green4", "red")) + theme(axis.line.x = element_line(size = 0.5, colour = "black"), axis.line.y = element_line(size = 0.5, colour = "black"), axis.line = element_line(size=1, colour = "black"), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.border = element_blank(), panel.background = element_blank(), axis.text.x=element_text(size=16, face="bold"), axis.text.y=element_text(size=14, face="bold"), axis.title.y=element_text(size=16, face = "bold"), axis.title.x = element_text (size = 16, face = "bold"), legend.title = element_blank(), legend.text = element_text(size=11)) od_nitrato install.packages("tidyquant") library(tidyquant) od_time<-ggplot() + #geom_line(df,mapping = aes(data,od), color = "red", size = 1.0) + #geom_line(df, mapping = aes(data, dbo), color = "blue", size = 1.0)+ geom_point(df, mapping = aes(data, od), color = "red", fill = "red")+ #geom_point(df, mapping = aes(data, dbo), color = "blue", fill = "blue")+ #geom_line(df, mapping = aes(data,dbo), color = "blue", size = 1.0) + #geom_smooth(df,mapping = aes(data,od), color = "blue", size = 1.0) + geom_ma(df, mapping = aes(data, od), ma_fun = SMA, n = 5, color = "blue", linetype = "solid")+ geom_hline(yintercept=5, linetype = "dashed") + scale_x_date(date_breaks = "4 month", date_minor_breaks = "1 month", date_labels = "%b/%Y") + scale_y_continuous("OD (mg/L)", breaks = seq(0,9.5,1), limits = c(0,9.5)) + theme(axis.line.x = element_line(size = 0.5, colour = "black"), axis.line.y = element_line(size = 0.5, colour = "black"), axis.line = element_line(size=1, colour = "black"), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.border = element_blank(), panel.background = element_blank(), axis.text.x=element_text(size=6, face="bold", color = "black", angle = 45, hjust=1), axis.text.y=element_text(size=12, face="bold"), axis.title.y=element_text(size=14, face = "bold"), axis.title.x = element_text (size = 16, face = "bold"), legend.title = element_blank(), legend.text = element_text(size=11)) od_time ggsave("temporal_od.jpeg", units="cm", width=16, height=18, dpi=600) dbo_time<-ggplot() + #geom_line(df,mapping = aes(data,od), color = "red", size = 1.0) + geom_line(df, mapping = aes(data, dbo), color = "blue", size = 1.0)+ #geom_point(df, mapping = aes(data, od), color = "red", fill = "red")+ geom_point(df, mapping = aes(data, dbo), color = "blue", fill = "blue")+ #geom_line(df, mapping = aes(data,dbo), color = "blue", size = 1.0) + geom_hline(yintercept=5, linetype = "dashed") + scale_x_date(date_breaks = "4 month", date_minor_breaks = "1 month", date_labels = "%b/%Y") + scale_y_continuous("DBO (mg/L)") + theme(axis.line.x = element_line(size = 0.5, colour = "black"), axis.line.y = element_line(size = 0.5, colour = "black"), axis.line = element_line(size=1, colour = "black"), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.border = element_blank(), panel.background = element_blank(), axis.text.x=element_text(size=6, face="bold", color = "black", angle = 45, hjust=1), axis.text.y=element_text(size=12, face="bold"), axis.title.y=element_text(size=14, face = "bold"), axis.title.x = element_text (size = 16, face = "bold"), legend.title = element_blank(), legend.text = element_text(size=11)) dbo_time cond_time<-ggplot() + #geom_line(df,mapping = aes(data,condutividade), color = "red", size = 1.0) + geom_point(df, mapping = aes(data, condutividade), color = "red", fill = "red")+ #geom_smooth(df,mapping = aes(data,condutividade), color = "blue", size = 1.0) + geom_ma(df, mapping = aes(data, condutividade), ma_fun = SMA, n = 5, color = "blue", linetype = "solid")+ #geom_hline(yintercept=5, linetype = "dashed") + scale_x_date(date_breaks = "4 month", date_minor_breaks = "1 month", date_labels = "%b/%Y") + scale_y_continuous("condutividade (mS/L)") + theme(axis.line.x = element_line(size = 0.5, colour = "black"), axis.line.y = element_line(size = 0.5, colour = "black"), axis.line = element_line(size=1, colour = "black"), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.border = element_blank(), panel.background = element_blank(), axis.text.x=element_text(size=6, face="bold", color = "black", angle = 45, hjust=1), axis.text.y=element_text(size=12, face="bold"), axis.title.y=element_text(size=14, face = "bold"), axis.title.x = element_text (size = 16, face = "bold"), legend.title = element_blank(), legend.text = element_text(size=11)) cond_time ggsave("temporal_od.jpeg", units="cm", width=16, height=18, dpi=600) turbidez_time<-ggplot() + #geom_line(df,mapping = aes(data,turbidez), color = "red", size = 1.0) + geom_point(df, mapping = aes(data, turbidez), color = "red", fill = "red")+ #geom_smooth(df,mapping = aes(data,turbidez), color = "blue", size = 1.0) + geom_ma(df, mapping = aes(data, turbidez), ma_fun = SMA, n = 5, color = "blue", linetype = "solid")+ #geom_hline(yintercept=5, linetype = "dashed") + scale_x_date(date_breaks = "4 month", date_minor_breaks = "1 month", date_labels = "%b/%Y") + scale_y_continuous("condutividade (mS/L)") + theme(axis.line.x = element_line(size = 0.5, colour = "black"), axis.line.y = element_line(size = 0.5, colour = "black"), axis.line = element_line(size=1, colour = "black"), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.border = element_blank(), panel.background = element_blank(), axis.text.x=element_text(size=6, face="bold", color = "black", angle = 45, hjust=1), axis.text.y=element_text(size=12, face="bold"), axis.title.y=element_text(size=14, face = "bold"), axis.title.x = element_text (size = 16, face = "bold"), legend.title = element_blank(), legend.text = element_text(size=11)) turbidez_time ggsave("temporal_od.jpeg", units="cm", width=16, height=18, dpi=600) ggplot() + geom_point(df, mapping = aes(turbidez, condutividade)) df_dbo<-filter(df, dbo<15) df %>% gather(-data, -al_dissolvido, -al_total, -alcalinidade_total, -ba_total, -cd_total, -cod, -col,-dureza,-hg_total, -zn_total, -sulfato_total, -cr_total, -cu_total, -cu_dissolvido, -dqo, -fe_dissolvido, -fe_total, -feofitina_a, -fluoreto_total, -mg_total, -mn_total, -ni_total, -pb_total, -clorofila_a,-coliformes_termotolerantes, -cot, -escherichia_coli, -n_total, -nitrogenio_nitrito, -temperatura_ar, -subst_tensoat_reagem_com_azul_metileno, -solido_dissolvido_total, -solido_total, key = "var", value = "value") %>% ggplot(aes(x = data, y = value )) + geom_point() + geom_smooth(method=lm) + facet_wrap(~ var, scales = "free") + theme_bw() df_dbo %>% gather(-data, -al_dissolvido, -al_total, -alcalinidade_total, -ba_total, -cd_total, -cod, -col,-dureza,-hg_total, -zn_total, -sulfato_total, -cr_total, -cu_total, -cu_dissolvido, -dqo, -fe_dissolvido, -fe_total, -feofitina_a, -fluoreto_total, -mg_total, -mn_total, -ni_total, -pb_total, -clorofila_a,-coliformes_termotolerantes, -cot, -escherichia_coli, -n_total, -nitrogenio_nitrito, -temperatura_ar, -subst_tensoat_reagem_com_azul_metileno, -solido_dissolvido_total, -solido_total, key = "var", value = "value") %>% ggplot(aes(x = data, y = value )) + geom_point() + geom_smooth(method=lm) + facet_wrap(~ var, scales = "free") + theme_bw() m<-lm(nitrogenio_amoniacal~od,df) summary(m) df_select<-select(df, ca_total, cloreto_total, condutividade, dbo, N_nitrato, fosforo_total, k, nitrogenio_amoniacal, od, sodio, turbidez) head(df_select) install.packages("ggcorrplot") library(ggcorrplot) corr <- round(cor(df_select), 1) corr ggcorrplot(corr, lab = TRUE) ggcorrplot(corr, method = "circle", lab = TRUE) install.packages("wql") library(wql) help(wql) sfb <- wqData(df, site.order = TRUE, type = "wide", time.format = "%Y/%m/%d") head(sfb) plot(df, vars = c('od', 'dbo')) library(dplyr) df10<-df %>% as_tibble %>% mutate(month = lubridate::month(data)) %>% group_by(month) #summarise(od_month = mean(od), cond_month = mean(condutividade), turbidez_month = mean(turbidez)) df10 plot(df10$month, df10$od) df10$month<-as.factor(df10$month) ggplot(mapping = aes(month,condutividade), df10) + geom_boxplot() + geom_jitter()