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
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
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
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
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
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
6 matches
Mail list logo