-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
ggplot is giving error on Aesthetics, when ggplots are saved in list through loop for later use
error message:
"Aesthetics must be either length 1 or the same as the data (6): fill, width, x, y"
It is stopping to produce more ggplot graphs.
However, when it is run outside the loop, it is runnign very normally, without any such message.
problem arise in gps[[34]] dataframe.
When it was tructuanted to contain the same number of factor levels (2 b, 2g) in variable 1 (v1), no problem arised.
In dataframes 35 to 37 no problem arise!
lst = list()
for (i in 34:length(gps)) {
p<-ggplot(data = gps, aes(x = gps[,3], y=gps[,1]) ) +
geom_col( aes(fill = "", width=0.8 ))
lst[[i]]<-p
}
gps list of dataframes:
[[34]]
prc v1 v2
1 31.9 b cr
3 3.5 b fr
4 1.8 b im
5 15.9 b ir
2 28.3 g cr
6 18.6 g Ir
[[35]]
prc v1 v2
1 1.1 Boy No
3 4.4 Boy Yes
2 16.1 Girl No
4 12.4 Girl Yes
[[36]]
prc v1 v2
1 18.6 Boy No
3 23.8 Boy Yes
2 34.8 Girl No
4 12.9 Girl Yes
[[37]]
prc v1 v2
1 16.7 Boy No
3 34.4 Boy Yes
2 18.8 Girl No
4 30.2 Girl Yes
Sincerely,
Elias "Estatistics" Tsolis
Metadata
Metadata
Assignees
Labels
No labels