[R] partitioning data

stephenc at ics.mq.edu.au stephenc at ics.mq.edu.au
Mon Oct 15 21:30:17 CEST 2007


I am trying to train on part of my data and test on another part:

> glm.model = glm(as.factor(h_finished) ~ . , family=binomial,
data=form[1:150000,])
> pred =  predict(glm.model, data=form[150001:200000,-1], type="response")
> t = table(pred, form[150001:200000,1])
Error in table(pred, form[150001:2e+05, 1]) :
        all arguments must have the same length

but try as I might my pred has too many lines:

> length(pred)
[1] 150000
> length(form[150000:200000, 1])
[1] 50000

[150000:200000, 1] works in the table function and indeed immediately
above. How can I make the [150000:200000, 1] work the predict function?



More information about the R-help mailing list