Not ellegant.. but...

MyDF<-data.frame(cbind(x=runif(10), y=rnorm(10)))
TrainingSize=5
TrainingSize_list<-sample(1:nrow(MyDF))[1:TrainingSize]
TrainingSize_list
MyDF.training<-MyDF[(1:nrow(MyDF) %in% TrainingSize_list),]
 MyDF.training

 MyDF.test<-MyDF[ ! (1:nrow(MyDF) %in% TrainingSize_list),]
 MyDF.test

bests

milton
On Mon, Dec 21, 2009 at 9:09 AM, bbslover <dlu...@yeah.net> wrote:

>
> I want to split my whole dateset to training set and test set, building
> model
> in training set, and validate model using test set. Now, How can I split my
> dataset to them reasonally. Please give me a hand, It is better to give me
> some R code.
>
> and I see some ways like using SOM to project whole independents to
> 2-dimensions and find some to be training set and others are test set.
>  like
> below. I also want to do this. and my date is in xls accessory. Please help
> me.  and excel file is 218*47 matrix, 47 are indepents. I want to project
> it
> to 2D and label the corresponding sample label like that picture below.
>
> thank you!
>
> http://n4.nabble.com/file/n976245/SOM%2Btraining%2Bset%2Band%2Btest%2Bset.jpg
> SOM+training+set+and+test+set.jpg
> http://n4.nabble.com/file/n976245/matlab218x47.xls matlab218x47.xls
> --
> View this message in context:
> http://n4.nabble.com/Help-Suggest-me-some-methods-to-identify-training-set-and-test-set-tp976245p976245.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

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

Reply via email to