[R] dropping variables from a data frame inside a function

David Winsemius dwinsemius at comcast.net
Fri Jun 22 23:22:33 CEST 2012


On Jun 22, 2012, at 5:09 PM, Joseph Boyer wrote:

> DropLikeSAS <- function(x,df) {
>
>                                df[[x]] <- NULL
>
>                                0
>
>                                }
>
> DropLikeSAS("VarName", DataFrameName)

Sorry for the blank message>

 > DropLikeSAS <- function(x,df) {
+                                df[[x]] <- NULL
+                               return(df) }
 >
 > DropLikeSAS("b", df)
     a
1   1
2   2
3   3
4   4
5   5
6   6
7   7
8   8
9   9
10 10
 >


David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list