random sample - R Take Non-sampled Rows from a Data Frame -


A random sample of half lines of dataframe can take in this way:

  Data (iris); Model_data & lt; - Iris data & lt; - Model_data half & lt; - (Nero (model_data))% /% 2 train & lt; - Model_data [sample (nero (model_data), half),]   

However, I also have an easy way of taking those rows that were not sampled and for verification Has been added to another object named val .

You enter train and val together, Maybe you can write functions to keep something like <

  foo & lt; - Function (Data) {Num & amp; Lt; - Sample (nero (data), nero (data) / 2) list (train = data [moist,], val = data [-samp,]) foo (mtcars) foo (iris)    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -