Re: [R] sample train and test data using dplyr

2016-12-09 Thread Jim Lemon
Sample without replacement and then split that sample into train and test components. Jim On Fri, Dec 9, 2016 at 4:55 PM, Partha Sinha wrote: > How to get two sets of non overlapping data? > Regards > Parth __ R-help@r-project.org mailing list -- To U

Re: [R] sample train and test data using dplyr

2016-12-08 Thread Ulrik Stervbo
df <- data.frame(x = 1:12, y = rnorm(12)) If you use sample: RowIndex <- sample(1:nrow(df), 5) TrainSet <- df[RowIndex, ] TestSet <- df[-RowIndex, ] Or with dplyr: TrainSet <- sample_n(df, 5) TestSet <- anti_join(TestSet, df) HTH Ulrik On Fri, 9 Dec 2016, 06:56 Partha Sinha, wrote: > How to

Re: [R] sample train and test data using dplyr

2016-12-08 Thread Partha Sinha
How to get two sets of non overlapping data? Regards Parth On 8 December 2016 at 23:23, Ulrik Stervbo wrote: > In addition to 'sample', and if you insist on dplyr, you can use > 'sample_n'. > > Best, > Ulrik > > On Thu, 8 Dec 2016 at 18:47 Bert Gunter wrote: > >> Usually we expect posters to do

Re: [R] sample train and test data using dplyr

2016-12-08 Thread Ulrik Stervbo
In addition to 'sample', and if you insist on dplyr, you can use 'sample_n'. Best, Ulrik On Thu, 8 Dec 2016 at 18:47 Bert Gunter wrote: > Usually we expect posters to do their homework by reading necessary R > documentation and relevant subject matter resources (e.g. on > clustering) and making

Re: [R] sample train and test data using dplyr

2016-12-08 Thread Bert Gunter
Usually we expect posters to do their homework by reading necessary R documentation and relevant subject matter resources (e.g. on clustering) and making a serious attempt to solve the problem by offering their code to us along as part of a reproducible example of how it failed. You have done none

[R] sample train and test data using dplyr

2016-12-08 Thread Partha Sinha
I want to create two files train and test using dplyr (by random sampling method). How to do the same same using lets say iris data. Regards Parth [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and mo