The ggplot function doesn't graph anything, but it doesn't throw errors either

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 !!!

Hi, and welcome!

library(ggplot2)
library(dplyr)
example_df <- mtcars %>% dplyr::select(mpg) %>% mutate(mpg = mpg/100)
ggplot(example_df, aes(x = mpg)) + geom_density()

illustrates what ggplot + geom_density() is supposed to do with a vector of decimals. Without a reproducible example, called a reprex, it's hard to tell why your lista_total[[24]] object doesn't (it derives from archivos).

Can you post an extract from lista_total[[24]]?

Created on 2019-11-04 by the reprex package (v0.3.0)

Mmm, how can I upload the file that I use from my code?

1 Like

If you have a github account, a public gist is a convenient way. For this problem, however, just a few lines from lista_total[[24]] is all that's needed and it can be cut and pasted as a codeblock.

NombreCentral POTENCIA_BRUTA_MWH COMBUSTIBLE CONCENTRACION_CO2_TON_MWH CONCENTRACION_CO2_TON
1 RENCA - NUEVA RENCA 21 PETROLEO_2 1.1157326 23.43038
2 RENCA - NUEVA RENCA 30 PETROLEO_2 2.1904168 65.71250
3 RENCA - NUEVA RENCA 56 PETROLEO_2 1.5076340 84.42751
4 RENCA - NUEVA RENCA 173 PETROLEO_2 0.8375269 144.89216
5 RENCA - NUEVA RENCA 209 PETROLEO_2 0.6890679 144.01519
6 RENCA - NUEVA RENCA 209 PETROLEO_2 0.6831061 142.76917
7 RENCA - NUEVA RENCA 208 PETROLEO_2 0.6863985 142.77089
8 RENCA - NUEVA RENCA 211 PETROLEO_2 0.6803673 143.55750
9 RENCA - NUEVA RENCA 75 PETROLEO_2 0.4759319 35.69489
10 RENCA - NUEVA RENCA 2 GAS_NATURAL 6.0766478 12.15330
11 RENCA - NUEVA RENCA 44 PETROLEO_2 0.8694428 38.25548
12 RENCA - NUEVA RENCA 74 PETROLEO_2 1.2964160 95.93479
13 RENCA - NUEVA RENCA 215 PETROLEO_2 0.6565497 141.15818
14 RENCA - NUEVA RENCA 309 PETROLEO_2 0.6310110 194.98240
15 RENCA - NUEVA RENCA 311 PETROLEO_2 0.6197081 192.72923
16 RENCA - NUEVA RENCA 309 PETROLEO_2 0.6318466 195.24060
17 RENCA - NUEVA RENCA 309 PETROLEO_2 0.6348926 196.18181
18 RENCA - NUEVA RENCA 308 PETROLEO_2 0.6245366 192.35726
19 RENCA - NUEVA RENCA 307 PETROLEO_2 0.6292979 193.19446
20 RENCA - NUEVA RENCA 308 PETROLEO_2 0.5877057 181.01335
21 RENCA - NUEVA RENCA 312 PETROLEO_2 0.6321756 197.23878
22 RENCA - NUEVA RENCA 311 PETROLEO_2 0.6254237 194.50678
23 RENCA - NUEVA RENCA 316 PETROLEO_2 0.6247882 197.43306
24 RENCA - NUEVA RENCA 316 PETROLEO_2 0.6289559 198.75006
25 RENCA - NUEVA RENCA 320 PETROLEO_2 0.6229243 199.33578
26 RENCA - NUEVA RENCA 223 PETROLEO_2 0.3305682 73.71671
27 RENCA - NUEVA RENCA 202 PETROLEO_2 0.3071121 62.03665
28 RENCA - NUEVA RENCA 201 PETROLEO_2 0.6953201 139.75933
29 RENCA - NUEVA RENCA 202 PETROLEO_2 0.6842239 138.21324
30 RENCA - NUEVA RENCA 201 PETROLEO_2 0.6928074 139.25428
31 RENCA - NUEVA RENCA 199 PETROLEO_2 0.6982466 138.95107
32 RENCA - NUEVA RENCA 204 PETROLEO_2 0.6910909 140.98254
33 RENCA - NUEVA RENCA 201 PETROLEO_2 0.6997512 140.64999
34 RENCA - NUEVA RENCA 231 PETROLEO_2 0.6687790 154.48794
35 RENCA - NUEVA RENCA 319 PETROLEO_2 0.4702201 150.00023
36 RENCA - NUEVA RENCA 317 PETROLEO_2 0.6257685 198.36861
37 RENCA - NUEVA RENCA 313 PETROLEO_2 0.6292527 196.95609
38 RENCA - NUEVA RENCA 308 PETROLEO_2 0.6262469 192.88405
39 RENCA - NUEVA RENCA 307 PETROLEO_2 0.6306525 193.61033
40 RENCA - NUEVA RENCA 305 PETROLEO_2 0.6353282 193.77511
41 RENCA - NUEVA RENCA 307 PETROLEO_2 0.6301387 193.45258
42 RENCA - NUEVA RENCA 307 PETROLEO_2 0.6287637 193.03045
43 RENCA - NUEVA RENCA 306 PETROLEO_2 0.6318523 193.34681
44 RENCA - NUEVA RENCA 307 PETROLEO_2 0.6335782 194.50850
45 RENCA - NUEVA RENCA 308 PETROLEO_2 0.6259710 192.79906
46 RENCA - NUEVA RENCA 305 PETROLEO_2 0.6369104 194.25768
47 RENCA - NUEVA RENCA 313 PETROLEO_2 0.6277916 196.49877
48 RENCA - NUEVA RENCA 314 PETROLEO_2 0.6306734 198.03145
49 RENCA - NUEVA RENCA 317 PETROLEO_2 0.6303972 199.83591
50 RENCA - NUEVA RENCA 223 PETROLEO_2 0.7521785 167.73582
51 RENCA - NUEVA RENCA 203 PETROLEO_2 0.6858752 139.23267
52 RENCA - NUEVA RENCA 203 PETROLEO_2 0.6886260 139.79108
53 RENCA - NUEVA RENCA 201 PETROLEO_2 0.6932319 139.33961
54 RENCA - NUEVA RENCA 203 PETROLEO_2 0.6867333 139.40686
55 RENCA - NUEVA RENCA 202 PETROLEO_2 0.6908299 139.54765
56 RENCA - NUEVA RENCA 203 PETROLEO_2 0.6855794 139.17262
57 RENCA - NUEVA RENCA 202 PETROLEO_2 0.6888091 139.13944
58 RENCA - NUEVA RENCA 219 PETROLEO_2 0.6899165 151.09171
59 RENCA - NUEVA RENCA 310 PETROLEO_2 0.6024588 186.76222
60 RENCA - NUEVA RENCA 314 PETROLEO_2 0.6236657 195.83103
61 RENCA - NUEVA RENCA 314 PETROLEO_2 0.4990229 156.69320
62 RENCA - NUEVA RENCA 315 PETROLEO_2 0.6266846 197.40565
63 RENCA - NUEVA RENCA 315 PETROLEO_2 0.0995374 31.35428
64 RENCA - NUEVA RENCA 311 PETROLEO_2 0.1232671 38.33608
65 RENCA - NUEVA RENCA 314 PETROLEO_2 0.6279833 197.18675
66 RENCA - NUEVA RENCA 315 PETROLEO_2 0.6309708 198.75581
67 RENCA - NUEVA RENCA 314 PETROLEO_2 0.4247476 133.37075
68 RENCA - NUEVA RENCA 319 PETROLEO_2 0.4028037 128.49439
69 RENCA - NUEVA RENCA 320 PETROLEO_2 0.2323176 74.34162
70 RENCA - NUEVA RENCA 322 PETROLEO_2 0.2303736 74.18031
71 RENCA - NUEVA RENCA 325 PETROLEO_2 0.2283607 74.21721
72 RENCA - NUEVA RENCA 323 PETROLEO_2 0.2293545 74.08151
73 RENCA - NUEVA RENCA 218 PETROLEO_2 0.3389101 73.88241
74 RENCA - NUEVA RENCA 276 PETROLEO_2 0.2676209 73.86337
75 RENCA - NUEVA RENCA 321 PETROLEO_2 0.2257468 72.46471
76 RENCA - NUEVA RENCA 262 PETROLEO_2 0.1582338 41.45725
77 RENCA - NUEVA RENCA 209 PETROLEO_2 0.3506015 73.27571
78 RENCA - NUEVA RENCA 209 PETROLEO_2 0.3264643 68.23104
79 RENCA - NUEVA RENCA 208 PETROLEO_2 0.3276018 68.14118
80 RENCA - NUEVA RENCA 203 PETROLEO_2 0.3386725 68.75053
81 RENCA - NUEVA RENCA 96 PETROLEO_2 0.7051091 67.69047
82 RENCA - NUEVA RENCA 113 PETROLEO_2 0.5862424 66.24539
83 RENCA - NUEVA RENCA 262 PETROLEO_2 0.2461513 64.49164
84 RENCA - NUEVA RENCA 326 PETROLEO_2 0.2216283 72.25083
85 RENCA - NUEVA RENCA 325 PETROLEO_2 0.2161700 70.25524
86 RENCA - NUEVA RENCA 320 PETROLEO_2 0.2313787 74.04117
87 RENCA - NUEVA RENCA 317 PETROLEO_2 0.1673304 53.04375
88 RENCA - NUEVA RENCA 313 PETROLEO_2 0.1055127 33.02548
89 RENCA - NUEVA RENCA 310 PETROLEO_2 0.2376755 73.67939
90 RENCA - NUEVA RENCA 312 PETROLEO_2 0.2362563 73.71197
91 RENCA - NUEVA RENCA 311 PETROLEO_2 0.2352695 73.16881
92 RENCA - NUEVA RENCA 311 PETROLEO_2 0.2350857 73.11165
93 RENCA - NUEVA RENCA 316 PETROLEO_2 0.2336952 73.84768
94 RENCA - NUEVA RENCA 316 PETROLEO_2 0.2327296 73.54254
95 RENCA - NUEVA RENCA 316 PETROLEO_2 0.2333045 73.72421
96 RENCA - NUEVA RENCA 320 PETROLEO_2 0.2304791 73.75331
97 RENCA - NUEVA RENCA 320 PETROLEO_2 0.2312714 74.00686
98 RENCA - NUEVA RENCA 226 PETROLEO_2 0.3278340 74.09049
99 RENCA - NUEVA RENCA 204 PETROLEO_2 0.3412161 69.60809
100 RENCA - NUEVA RENCA 200 PETROLEO_2 0.3408957 68.17913
101 RENCA - NUEVA RENCA 204 PETROLEO_2 0.3336936 68.07349
102 RENCA - NUEVA RENCA 206 PETROLEO_2 0.3303207 68.04607
103 RENCA - NUEVA RENCA 208 PETROLEO_2 0.3284305 68.31354
104 RENCA - NUEVA RENCA 211 PETROLEO_2 0.3235909 68.27767
105 RENCA - NUEVA RENCA 209 PETROLEO_2 0.3269220 68.32669
106 RENCA - NUEVA RENCA 288 PETROLEO_2 0.1975165 56.88474
107 RENCA - NUEVA RENCA 324 PETROLEO_2 0.2269753 73.54000
108 RENCA - NUEVA RENCA 319 PETROLEO_2 0.2319213 73.98290
109 RENCA - NUEVA RENCA 315 PETROLEO_2 0.2343567 73.82237
110 RENCA - NUEVA RENCA 313 PETROLEO_2 0.2350812 73.58041
111 RENCA - NUEVA RENCA 312 PETROLEO_2 0.2353772 73.43769
112 RENCA - NUEVA RENCA 310 PETROLEO_2 0.2375634 73.64465
113 RENCA - NUEVA RENCA 307 PETROLEO_2 0.2389007 73.34253
114 RENCA - NUEVA RENCA 307 PETROLEO_2 0.2200948 67.56909
115 RENCA - NUEVA RENCA 307 PETROLEO_2 0.2365272 72.61386
116 RENCA - NUEVA RENCA 310 PETROLEO_2 0.2361146 73.19553
117 RENCA - NUEVA RENCA 311 PETROLEO_2 0.2358820 73.35932
118 RENCA - NUEVA RENCA 310 PETROLEO_2 0.2363161 73.25799
119 RENCA - NUEVA RENCA 318 PETROLEO_2 0.2314254 73.59326
120 RENCA - NUEVA RENCA 316 PETROLEO_2 0.2332868 73.71861
121 RENCA - NUEVA RENCA 294 PETROLEO_2 0.2509426 73.77712
122 RENCA - NUEVA RENCA 204 PETROLEO_2 0.3406629 69.49524
123 RENCA - NUEVA RENCA 204 PETROLEO_2 0.3019415 61.59607
124 RENCA - NUEVA RENCA 204 PETROLEO_2 0.3335149 68.03703
125 RENCA - NUEVA RENCA 202 PETROLEO_2 0.3363983 67.95246
126 RENCA - NUEVA RENCA 203 PETROLEO_2 0.3349821 68.00137
127 RENCA - NUEVA RENCA 203 PETROLEO_2 0.3359065 68.18901
128 RENCA - NUEVA RENCA 200 PETROLEO_2 0.2829413 56.58826
129 RENCA - NUEVA RENCA 321 PETROLEO_2 0.2233127 71.68338
130 RENCA - NUEVA RENCA 318 PETROLEO_2 0.2328247 74.03824
131 RENCA - NUEVA RENCA 313 PETROLEO_2 0.2359506 73.85255
132 RENCA - NUEVA RENCA 311 PETROLEO_2 0.2367097 73.61671
133 RENCA - NUEVA RENCA 303 PETROLEO_2 0.2420191 73.33180
134 RENCA - NUEVA RENCA 307 PETROLEO_2 0.2382593 73.14560
135 RENCA - NUEVA RENCA 304 PETROLEO_2 0.2404891 73.10868
136 RENCA - NUEVA RENCA 307 PETROLEO_2 0.2385461 73.23365
137 RENCA - NUEVA RENCA 307 PETROLEO_2 0.2380433 73.07929
138 RENCA - NUEVA RENCA 308 PETROLEO_2 0.2377916 73.23980
139 RENCA - NUEVA RENCA 313 PETROLEO_2 0.2338917 73.20811
140 RENCA - NUEVA RENCA 313 PETROLEO_2 0.2347064 73.46309
141 RENCA - NUEVA RENCA 319 PETROLEO_2 0.2308725 73.64833
142 RENCA - NUEVA RENCA 319 PETROLEO_2 0.2320844 74.03492
143 RENCA - NUEVA RENCA 225 PETROLEO_2 0.3289690 74.01803
144 RENCA - NUEVA RENCA 204 PETROLEO_2 0.3536035 72.13512
145 RENCA - NUEVA RENCA 205 PETROLEO_2 0.3323633 68.13448
146 RENCA - NUEVA RENCA 201 PETROLEO_2 0.3388497 68.10879
147 RENCA - NUEVA RENCA 204 PETROLEO_2 0.3339142 68.11849
148 RENCA - NUEVA RENCA 203 PETROLEO_2 0.3355763 68.12198
149 RENCA - NUEVA RENCA 202 PETROLEO_2 0.3364060 67.95402
150 RENCA - NUEVA RENCA 204 PETROLEO_2 0.2799222 57.10414
151 RENCA - NUEVA RENCA 204 PETROLEO_2 0.3340104 68.13812
152 RENCA - NUEVA RENCA 203 PETROLEO_2 0.3392198 68.86162
153 RENCA - NUEVA RENCA 205 PETROLEO_2 0.3321161 68.08380
154 RENCA - NUEVA RENCA 214 PETROLEO_2 0.3182701 68.10980
155 RENCA - NUEVA RENCA 284 PETROLEO_2 0.2423389 68.82426
156 RENCA - NUEVA RENCA 307 PETROLEO_2 0.2370381 72.77070
157 RENCA - NUEVA RENCA 272 PETROLEO_2 0.2698147 73.38960
158 RENCA - NUEVA RENCA 209 PETROLEO_2 0.3269235 68.32702
159 RENCA - NUEVA RENCA 206 PETROLEO_2 0.3309401 68.17367
160 RENCA - NUEVA RENCA 230 PETROLEO_2 0.2967546 68.25356
161 RENCA - NUEVA RENCA 318 PETROLEO_2 0.2146849 68.26979
162 RENCA - NUEVA RENCA 324 PETROLEO_2 0.2278905 73.83651
163 RENCA - NUEVA RENCA 320 PETROLEO_2 0.2318644 74.19662
164 RENCA - NUEVA RENCA 237 PETROLEO_2 0.3125941 74.08481
165 RENCA - NUEVA RENCA 206 PETROLEO_2 0.3427072 70.59767
166 RENCA - NUEVA RENCA 209 PETROLEO_2 0.3271196 68.36799
167 RENCA - NUEVA RENCA 209 PETROLEO_2 0.3277982 68.50983
168 RENCA - NUEVA RENCA 208 PETROLEO_2 0.3291003 68.45286
169 RENCA - NUEVA RENCA 208 PETROLEO_2 0.3288801 68.40707
170 RENCA - NUEVA RENCA 208 PETROLEO_2 0.3290415 68.44063
171 RENCA - NUEVA RENCA 290 PETROLEO_2 0.1960242 56.84701
172 RENCA - NUEVA RENCA 325 PETROLEO_2 0.2279092 74.07049
173 RENCA - NUEVA RENCA 324 PETROLEO_2 0.2293234 74.30078
174 RENCA - NUEVA RENCA 322 PETROLEO_2 0.2308014 74.31806
175 RENCA - NUEVA RENCA 321 PETROLEO_2 0.2311053 74.18481
176 RENCA - NUEVA RENCA 316 PETROLEO_2 0.2336241 73.82520
177 RENCA - NUEVA RENCA 312 PETROLEO_2 0.2367465 73.86490
178 RENCA - NUEVA RENCA 311 PETROLEO_2 0.2215335 68.89692
179 RENCA - NUEVA RENCA 313 PETROLEO_2 0.2367843 74.11349
180 RENCA - NUEVA RENCA 311 PETROLEO_2 0.2365643 73.57150
181 RENCA - NUEVA RENCA 313 PETROLEO_2 0.2350845 73.58146
182 RENCA - NUEVA RENCA 315 PETROLEO_2 0.2340564 73.72777
183 RENCA - NUEVA RENCA 318 PETROLEO_2 0.2321271 73.81641
184 RENCA - NUEVA RENCA 322 PETROLEO_2 0.2294839 73.89383
185 RENCA - NUEVA RENCA 321 PETROLEO_2 0.2305435 74.00448
186 RENCA - NUEVA RENCA 239 PETROLEO_2 0.3095790 73.98937
187 RENCA - NUEVA RENCA 205 PETROLEO_2 0.3446050 70.64403
188 RENCA - NUEVA RENCA 211 PETROLEO_2 0.3241651 68.39884
189 RENCA - NUEVA RENCA 208 PETROLEO_2 0.3285662 68.34177
190 RENCA - NUEVA RENCA 209 PETROLEO_2 0.3276284 68.47433
191 RENCA - NUEVA RENCA 206 PETROLEO_2 0.3313021 68.24824
192 RENCA - NUEVA RENCA 209 PETROLEO_2 0.3277272 68.49499
193 RENCA - NUEVA RENCA 208 PETROLEO_2 0.2983312 62.05288
194 RENCA - NUEVA RENCA 325 PETROLEO_2 0.2280355 74.11155
195 RENCA - NUEVA RENCA 324 PETROLEO_2 0.2276458 73.75723
196 RENCA - NUEVA RENCA 326 PETROLEO_2 0.2258854 73.63863
197 RENCA - NUEVA RENCA 324 PETROLEO_2 0.2268548 73.50096
198 RENCA - NUEVA RENCA 327 PETROLEO_2 0.2248368 73.52162
199 RENCA - NUEVA RENCA 326 PETROLEO_2 0.2252218 73.42229
200 RENCA - NUEVA RENCA 329 PETROLEO_2 0.2223629 73.15740

This serve?, it´s part of the lista[[24]]

That is not copy/paste friendly, please follow this guide about how to make a proper reprex

Ok, I see it now, thanks by the guide

bla1<-tibble::tribble(
                 ~NombreCentral, ~POTENCIA_BRUTA_MWH,  ~COMBUSTIBLE, ~CONCENTRACION_CO2_TON_MWH, ~CONCENTRACION_CO2_TON,
          "RENCA - NUEVA RENCA",                  21,  "PETROLEO_2",           1.11573255062103,       23.4303835630416,
          "RENCA - NUEVA RENCA",                  30,  "PETROLEO_2",           2.19041681289673,       65.7125043869019,
          "RENCA - NUEVA RENCA",                  56,  "PETROLEO_2",           1.50763404369354,       84.4275064468382,
          "RENCA - NUEVA RENCA",                 173,  "PETROLEO_2",          0.837526917457581,       144.892156720162,
          "RENCA - NUEVA RENCA",                 209,  "PETROLEO_2",          0.689067900180817,       144.015191137791,
          "RENCA - NUEVA RENCA",                 209,  "PETROLEO_2",          0.683106064796448,       142.769167542458,
          "RENCA - NUEVA RENCA",                 208,  "PETROLEO_2",          0.686398506164551,       142.770889282227,
          "RENCA - NUEVA RENCA",                 211,  "PETROLEO_2",          0.680367290973663,       143.557498395443,
          "RENCA - NUEVA RENCA",                  75,  "PETROLEO_2",          0.475931912660599,       35.6948934495449,
          "RENCA - NUEVA RENCA",                   2, "GAS_NATURAL",           6.07664775848389,       12.1532955169678,
          "RENCA - NUEVA RENCA",                  44,  "PETROLEO_2",          0.869442760944366,       38.2554814815521,
          "RENCA - NUEVA RENCA",                  74,  "PETROLEO_2",           1.29641604423523,        95.934787273407,
          "RENCA - NUEVA RENCA",                 215,  "PETROLEO_2",          0.656549692153931,       141.158183813095,
          "RENCA - NUEVA RENCA",                 309,  "PETROLEO_2",          0.631011009216309,       194.982401847839,
          "RENCA - NUEVA RENCA",                 311,  "PETROLEO_2",          0.619708120822906,       192.729225575924,
          "RENCA - NUEVA RENCA",                 309,  "PETROLEO_2",          0.631846606731415,       195.240601480007,
          "RENCA - NUEVA RENCA",                 309,  "PETROLEO_2",          0.634892582893372,       196.181808114052,
          "RENCA - NUEVA RENCA",                 308,  "PETROLEO_2",          0.624536573886871,       192.357264757156,
          "RENCA - NUEVA RENCA",                 307,  "PETROLEO_2",          0.629297912120819,       193.194459021091,
          "RENCA - NUEVA RENCA",                 308,  "PETROLEO_2",          0.587705671787262,       181.013346910477,
          "RENCA - NUEVA RENCA",                 312,  "PETROLEO_2",           0.63217556476593,        197.23877620697,
          "RENCA - NUEVA RENCA",                 311,  "PETROLEO_2",          0.625423729419708,       194.506779849529,
          "RENCA - NUEVA RENCA",                 316,  "PETROLEO_2",          0.624788165092468,        197.43306016922,
          "RENCA - NUEVA RENCA",                 316,  "PETROLEO_2",          0.628955900669098,       198.750064611435,
          "RENCA - NUEVA RENCA",                 320,  "PETROLEO_2",          0.622924327850342,       199.335784912109,
          "RENCA - NUEVA RENCA",                 223,  "PETROLEO_2",          0.330568194389343,       73.7167073488235,
          "RENCA - NUEVA RENCA",                 202,  "PETROLEO_2",          0.307112127542496,       62.0366497635842,
          "RENCA - NUEVA RENCA",                 201,  "PETROLEO_2",          0.695320069789886,       139.759334027767,
          "RENCA - NUEVA RENCA",                 202,  "PETROLEO_2",           0.68422394990921,        138.21323788166,
          "RENCA - NUEVA RENCA",                 201,  "PETROLEO_2",          0.692807376384735,       139.254282653332,
          "RENCA - NUEVA RENCA",                 199,  "PETROLEO_2",          0.698246598243713,       138.951073050499,
          "RENCA - NUEVA RENCA",                 204,  "PETROLEO_2",          0.691090881824493,       140.982539892197,
          "RENCA - NUEVA RENCA",                 201,  "PETROLEO_2",          0.699751198291779,       140.649990856648,
          "RENCA - NUEVA RENCA",                 231,  "PETROLEO_2",          0.668778955936432,       154.487938821316,
          "RENCA - NUEVA RENCA",                 319,  "PETROLEO_2",          0.470220148563385,        150.00022739172,
          "RENCA - NUEVA RENCA",                 317,  "PETROLEO_2",          0.625768482685089,       198.368609011173,
          "RENCA - NUEVA RENCA",                 313,  "PETROLEO_2",          0.629252672195435,       196.956086397171,
          "RENCA - NUEVA RENCA",                 308,  "PETROLEO_2",          0.626246929168701,        192.88405418396,
          "RENCA - NUEVA RENCA",                 307,  "PETROLEO_2",          0.630652546882629,       193.610331892967,
          "RENCA - NUEVA RENCA",                 305,  "PETROLEO_2",          0.635328233242035,       193.775111138821,
          "RENCA - NUEVA RENCA",                 307,  "PETROLEO_2",          0.630138695240021,       193.452579438686,
          "RENCA - NUEVA RENCA",                 307,  "PETROLEO_2",          0.628763675689697,       193.030448436737,
          "RENCA - NUEVA RENCA",                 306,  "PETROLEO_2",          0.631852328777313,       193.346812605858,
          "RENCA - NUEVA RENCA",                 307,  "PETROLEO_2",          0.633578181266785,       194.508501648903,
          "RENCA - NUEVA RENCA",                 308,  "PETROLEO_2",          0.625970959663391,       192.799055576324
          )
head(bla1)
#> # A tibble: 6 x 5
#>   NombreCentral POTENCIA_BRUTA_… COMBUSTIBLE CONCENTRACION_C…
#>   <chr>                    <dbl> <chr>                  <dbl>
#> 1 RENCA - NUEV…               21 PETROLEO_2             1.12 
#> 2 RENCA - NUEV…               30 PETROLEO_2             2.19 
#> 3 RENCA - NUEV…               56 PETROLEO_2             1.51 
#> 4 RENCA - NUEV…              173 PETROLEO_2             0.838
#> 5 RENCA - NUEV…              209 PETROLEO_2             0.689
#> 6 RENCA - NUEV…              209 PETROLEO_2             0.683
#> # … with 1 more variable: CONCENTRACION_CO2_TON <dbl>

Created on 2019-11-05 by the reprex package (v0.3.0)

1 Like

That's better?, I still don´t understand very well how to upload data

That is better as sample data but could you narrow down your code to just the relevant part and integrate it with your sample data so we can actually reproduce your problem? just follow along with the guide (in case you prefer there is also the Spanish version Pregunta Frecuente: ÂżCĂłmo hacer un ejemplo mĂ­nimo reproducible (reprex)? - para principiantes)

1 Like

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))

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"))

dput(bla1)

library(tidyverse) # usually enter only specific libraries if non-interactive
my_df <- read.csv("https://gist.githubusercontent.com/technocrat/3c729e5195142989eeb1d3cef1bc14f6/raw/c64b7637010266648f22fcdb617bfbb79a61b3a9/renco.csv")
my_df
class(my_df)

If this data frame is equivalent to lista_total, it only has 3 columns, so lista_total[[24]] refers to a non-existant column, and it's not clear why

ggplot(lista_total[[24]], aes(x = CONCENTRACION_PORCENTAJE_CO2)) + geom_density()

doesn't yield

Error in .subset2(x, i, exact = exact) : subscript out of bounds

and we're back to what should work, which is

ggplot(my_df, aes(x = COMBUSTIBLE)) + geom_density()

So, what is your result from

lista_total[[24]]

That is not reproducible at all, please read the guide more carefully and try to make a proper reprex, that would increase your chances of getting help and would avoid unnecessary back and forths.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.