library(ggplot2) library(tidyverse) library(data.table) ######################################################################## # TASK: barplots to colour nssnps by chosen aa_property ######################################################################## aa_prop_bp <- function(plotdf , position_colname , fill_colname , fill_colours , leg_name = "LEGEND"){ mp = ggplot(df, aes(x = as.factor(eval(parse(text = pos_colname))) #, y = ..count.. , fill = eval(parse(text = fill_colname)) )) + geom_bar(position = 'identity') + scale_fill_manual(values = fill_colours , name = leg_name) return(mp) }