r - Fetch the original name of vector variable passed to a custom function -
my problem best understood after reading r script: plothistogram <- function(data, x, binw=0.30, color=false, density=false, h=10, w=10) { require(ggplot2) # data$x <- as.numeric(x) plot <- ggplot(data, aes(x)) if(density & color) { plot <- plot + geom_density(fill="blue", aes(alpha=0.2)) } else if (density) { plot <- plot + geom_density() } else if (color) { plot <- plot + geom_histogram(binwidth=binw, aes(y=..density.., fill=..count..)) + scale_fill_gradient("count", low="purple", high="red") } else { plot <- plot + geom_histogram(binwidth=binw, aes(y=..density.., fill=..count..)) } ggsave(file="histo_plot.svg", plot=plot, height=h, width=w) return(plot) } notice commented line. have use ggplot recognize x belongs data . hack. intent plot name of whatever series input x . i'm not sure how because far can tell, ...