[R] Forumla format?

Steve Lianoglou mailinglist.honeypot at gmail.com
Mon Jul 27 21:17:12 CEST 2009


Hi,

On Jul 27, 2009, at 3:01 PM, Noah Silverman wrote:

> Hi,
>
> Quick question.
>
> I'm working on training an SVM.
>
> I have a dataframe with about 50 columns.  I want to train on 46 of  
> them.
>
> Is there a way to say "All except columns 22,23,25 and 31"?

Assume your dataframe is called "my.data":

my.data[,-c(22,23,25,31)]

Returns the data.frame w/o columns 22,23,25 and 31.

-steve

> It would be nice to not have to do +c1 +c2 +c3 +c4, etc for all 48  
> columns.

Yes, it is nice, isn't it? :-)

-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
   |  Memorial Sloan-Kettering Cancer Center
   |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact




More information about the R-help mailing list