plot_dist = function(df1,df2,features,nrows,ncols){
fig_list = list()
j=1
for (feature in features){
print(feature)
fig=ggplot()+
geom_density(data=df1,aes(feature),color="blue")+
geom_density(data=df2,aes(feature),color = "black")
fig_list[j] = list(fig)
j = j+1
}
multi_plot02 = marrangeGrob(grobs = fig_list,nrow = nrows,ncol = ncols)
return(multi_plot02)
}
where df1,df2 are two dataframes with features from var_0 to var_199 in both dataframes
I have tried noquotes method also, but no luck. If I am running it as single code then it is working but not in loop
Libraries used: ggplot2
[1]: https://i.stack.imgur.com/gfRDa.png
[getting this, in multiplot][1]
[2]: https://i.stack.imgur.com/Ozf2g.png
[expectd this from the code, though it should be in multiplot][2]