Hi,
On Jul 27, 2009, at 3:47 PM, Noah Silverman wrote:
Hi,
I'm not sure that would work for the "formula" format of an SVM
function.
the idea is normally
svm(label ~ c1 + c2 +c3, data=mydata);
It doesn't work to say
svm(label ~ -c(22,23,24), data=mydata)
You're quite right. Sorry, I misunderstood the question ... I'm
actually not sure if/how you could do that as I don't use the formula
"formulation" too much.
Is it possible to build up your formula as a string, and then convert
to formula w/ as.formula?
ie.
f <- as.formula(sprintf('label ~ %s', paste(colnames(my.data)[-
c(22,23,24), collapse=" + "))
Then use `f` in your call to svm? Maybe?
-steve
On 7/27/09 12:17 PM, Steve Lianoglou wrote:
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
--
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
______________________________________________
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.