Displaying 1 result from an estimated 1 matches for "pmts".
Did you mean:
pmds
2012 Jun 20
2
passing function parameters into a 'with' statement to dynamically pick out columns
Hi,
I've built a function to generate plots and would like to be able pass in column names as a parameter. Here's a boiled down version of what I have right now:
pmts <- data.frame(date=c(1,2,3), all=c(5,6,7),maj=c(4,5,6),ind=c(3,4,5))
perc.mktshare <- function(df){
range1 <- floor(min(with(df, 100*ind/all)))
range2 <- ceiling(max(with(df, 100*ind/all)))
with(df,plot(date,100*ind/all,ylim=c(range1,range2),ylab="% Marketshare"))
}...