Try this:

newTable <- function(data, criteria) {
    do.call(subset, list(data, substitute(criteria)))
}

On Wed, Dec 1, 2010 at 3:56 PM, <cmccar...@bmcc.cuny.edu> wrote:

> Hi,
> Suppose I have the following data
>
> name     score
> Abel        88
> Baker      54
> Charlie    77
>
> stored a  table called myData.
>
>
> I want to write a function that will create a table which is a subset of
> myData containing those have a score > 75.
>
> I know I can do this with the following command:
> subset(myData, score > 75)
>
> But I would like to do this via a function, something like:
>
> newTable <- function( data,  criteria){
>                     subset( data, criteria) }
>
> and then calling:     newTable(myData, score > 75)
>
> But this doesn't work. I am sure there is a simple way to do this,
> but I am stuck! Please help. Thanks!
>
>
> Chris McCarthy, PhD
> Department of Mathematics BMCC
> Office: N522   Extension: 5235
> cmccar...@bmcc.cuny.edu
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help@r-project.org 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.
>
>


-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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