I'm trying to create a function which will allow me to subset a data set
based on values of various specified variables.  I also want to then
apply some other function(s) (e.g., summary).

 

This is what I've tried so far....

 

> test.fx <- function(dta, expvar, expval) {

+ newdta <- subset(dta, eval(expvar)>expval)

+ summary(newdta$eval(expvar))

+ }

> 

> test.fx(fyc04s, quote(totexp04), 100)

Error in summary(newdta$eval(expvar)) : attempt to apply non-function

> 

 

The subset works fine, but the my attempt to access the specified
variable bombs.  

 

Is there a syntactical change I can make?

Is it better to attach newdta?

 

Thanks in advance for any guidance.

 

Marc

 

Marc W. Zodet, MS                           

Senior Health Statistician

Agency for Healthcare Research and Quality

Center for Financing, Access, and Cost Trends

301-427-1563 (Telephone)

301-427-1276 (Fax)

[EMAIL PROTECTED]

 


        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to