[R] svm models in a loop

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Oct 12 08:26:43 CEST 2008


You need to use substitute() on the call.  Something like

sapply(1:5,function(i)
        eval(substitute(svm(person_oid ~ ., data=zrr[1:N,]), list(N=100*i))
        )
On Sun, 12 Oct 2008, Alexy Khrabrov wrote:

> I want to train svm models on increasingly large training data subsets of 
> some zrr as follows:
>
>> m <- sapply(1:5,function(i) svm(person_oid~.,data=zrr[1:100*i,]))    # (*)
>
> However, when I inspect m[1], it literally shows
>
>> m[1]
> [[1]]
> svm(formula = person_oid ~ ., data = zrr[1:N, ])

I suspect it shows '100*i' not 'N', but in the absence of a reproducible 
example, I cannot check.

> -- as opposed to
>
>> m1 <- svm(person_oid~.,data=zrr[1:100,])
>> m1
>> m1
>
> Call:
> svm(formula = person_oid ~ ., data = zrr[1:100, ])
> ... -- actual parameters
>
> How do I force actual model evaluation in (*) ?

I don't think that is the issue, just the recorded call.

> Cheers,
> Alexy

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list