Re: [R] passing function parameters into a 'with' statement to dynamically pick out columns

2012-06-20 Thread William Dunlap
> perc.mktshare(df, "GoatChow") # error: "Undefined columns selected" Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of peter dalgaard >

Re: [R] passing function parameters into a 'with' statement to dynamically pick out columns

2012-06-20 Thread peter dalgaard
On Jun 20, 2012, at 16:45 , David Marx wrote: > 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

Re: [R] passing function parameters into a 'with' statement to dynamically pick out columns

2012-06-20 Thread Jeff Newmiller
"With" is designed for interactive use, so you are right that it is not the answer. You can use list indexing with column names within functions, though, like df[[scaling.column]] or df[["all"]]. --- Jeff Newmiller

[R] passing function parameters into a 'with' statement to dynamically pick out columns

2012-06-20 Thread David Marx
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