I have this code that works in its entirety, and I already imported the ggplot2 package:
library(fitdistrplus)
library(MASS)
library(survival)
library(tidyverse)
library(ggplot2)
library(actuar)
library(e1071)
library(FAdist)
library(gld)
library(MonteCarlo)
library(snow)
lista_df <- lapply(archivos, function (x) read.table(x, sep=";",header=T))
df_unido <- reduce(rbind, lista_df)
df_unido_n <- df_unido %>%
dplyr::select(NombreCentral,POTENCIA_BRUTA_MWH,CONCENTRACION_PORCENTAJE_CO2) %>%
filter(POTENCIA_BRUTA_MWH >0,!is.na(POTENCIA_BRUTA_MWH) , CONCENTRACION_PORCENTAJE_CO2 >0, !is.na(CONCENTRACION_PORCENTAJE_CO2))
nombres= df_unido_n$NombreCentral
nombres.factor=factor(nombres)
nmb=levels(nombres.factor)
lista_total= list()
for (i in 1:44){
dfn=df_unido_n %>%
filter(NombreCentral == nmb[i])
lista_total[[i]]<-dfn
}
But when you get here, when you want to execute the following lines, it's like reading them but not caring, and trying to restart Rstudio and nothing.
ggplot(lista_total[[24]], aes(x = CONCENTRACION_PORCENTAJE_CO2)) + geom_density()
ggplot(lista_total[[24]], aes(lista_total[[24]]$CONCENTRACION_PORCENTAJE_CO2)) + geom_histogram(binwidth = 1.2)
ggplot(lista_total[[24]], aes(lista_total[[24]]$CONCENTRACION_PORCENTAJE_CO2)) + stat_ecdf(geom = "point", size=1) + ggtitle("CDF GRAPHIC")
ggplot(lista_total[[24]], aes(x = CONCENTRACION_PORCENTAJE_CO2)) + geom_histogram(aes(y=..density..), binwidth=1, colour="black", fill="white") + geom_density(alpha=0.2, size=0.4) + ggtitle("DENSITY AND HISTOGRAM GRAPHIC")
quan <- quantile(lista_total[[24]]$CONCENTRACION_PORCENTAJE_CO2, probs = c(0.25, 0.5, 0.75, 1))
I also tried deleting almost the entire environment and reloading all variables 1 to 1 and it worked the first time, but from there no more.
col_prueba=lista_total[[24]]$CONCENTRACION_PORCENTAJE_CO2
col_prueba_aux=(lista_total[[24]]$CONCENTRACION_PORCENTAJE_CO2)/10^4
str(col_prueba)
summary(col_prueba)
plotdist(col_prueba, histo=TRUE, demp=TRUE)
descdist(col_prueba)
fw2_p <- fitdist(col_prueba, "weibull")
fw3_p <- fitdist(col_prueba, "weibull3", start = list(shape = 1, scale = 1))
fg_p <- fitdist(col_prueba, "gamma")
fln_p <- fitdist(col_prueba, "lnorm")
fex_p <- fitdist(col_prueba, "exp")
fgm_p <- fitdist(col_prueba, "gumbel", start=list(scale=50, location=50))
fn_p <- fitdist(col_prueba, "norm")
fll_p <- fitdist(col_prueba, "llogis", start = list(shape = 1, scale = 1))
fl_p <- fitdist(col_prueba, "logis")
fitGLD <- fit.fkml(col_prueba, method = "ML")
optGLD <- fitGLD$optim.results$par
opt <- round(optGLD ,1)
fgl_p<- fitdist(col_prueba, "gl", start=list(lambda1 = opt[1], lambda2 = opt[2], lambda3 = opt[3], lambda4 = opt[4]), method="mle", control=list(trace=0, REPORT=1))
par(mfrow=c(2,2))
plot.legend<-c("Weibull","Weibull3","lnorm","gamma","exp","gumbel","norm","llogis","logis","g-lambda")
The same happens here:
denscomp(list(fw2_p,fw3_p,fg_p,fln_p,fex_p,fgm_p,fn_p,fll_p,fl_p,fgl_p), plotstyle = "ggplot",legendtext = c("weibull-2P", "weibull-3P", "gamma", "lognormal", "exponential", "gumbel", "normal", "loglogistic", "logistic","g-lambda"))
cdfcomp(list(fw2_p,fw3_p,fg_p,fln_p,fex_p,fgm_p,fn_p,fll_p,fl_p,fgl_p), plotstyle = "ggplot",legendtext = c("weibull-2P", "weibull-3P", "gamma", "lognormal", "exponential", "gumbel", "normal", "loglogistic", "logistic","g-lambda"))
qqcomp(list(fw2_p,fw3_p,fg_p,fln_p,fex_p,fgm_p,fn_p,fll_p,fl_p,fgl_p), plotstyle = "ggplot",legendtext = c("weibull-2P", "weibull-3P", "gamma", "lognormal", "exponential", "gumbel", "normal", "loglogistic", "logistic","g-lambda"))
ppcomp(list(fw2_p,fw3_p,fg_p,fln_p,fex_p,fgm_p,fn_p,fll_p,fl_p,fgl_p), plotstyle = "ggplot",legendtext = c("weibull-2P", "weibull-3P", "gamma", "lognormal", "exponential", "gumbel", "normal", "loglogistic", "logistic","g-lambda"))
test_func<-function(n,loc,scale){
sample<-rnorm(n, loc, scale)
stat<-sqrt(n)*mean(sample)/sd(sample)
decision<-abs(stat)>1.96
return(list("decision"=decision, "stat"=stat))
}
n_grid<-c(50,100,250,500)
loc_grid<-c(0,1)
scale_grid<-c(1,2)
param_list=list("n"=n_grid, "loc"=loc_grid, "scale"=scale_grid)
erg<-MonteCarlo(func=test_func, nrep=250, param_list=param_list, ncpus=1)
df<-MakeFrame(erg)
head(df)
And I had done this function in another work tab and I didn't graph anything
tbl <- tbl_df(df)
ggplot(filter(tbl, loc==0)) + geom_density(aes(x=stat, col=factor(n)))
As a detail, the functionality of this code is getting slower, it takes longer and longer in each process, so I don't know if it will be my computer, the code or a mixture of both. Please help guys !!!