[R] svm models in a loop

Alexy Khrabrov deliverable at gmail.com
Sun Oct 12 08:32:36 CEST 2008


On Oct 12, 2008, at 2:26 AM, Prof Brian Ripley wrote:

> 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))
>       )

Thanks!

> 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.

Exactly -- I've mixed in an attempt to define N in sapply(...,  
function(i) { N <- 100*i, ...}), but now see I need to do it in  
substitute().

Cheers,
Alexy



More information about the R-help mailing list