@@ -678,41 +678,28 @@ setMethod("unique",
678
678
# '}
679
679
setMethod ("sample ",
680
680
signature(x = " DataFrame" , withReplacement = " logical" ,
681
- fraction = " numeric" , seed = " missing " ),
681
+ fraction = " numeric" ),
682
682
function (x , withReplacement , fraction , seed ) {
683
683
if (fraction < 0.0 ) stop(cat(" Negative fraction value:" , fraction ))
684
- sdf <- callJMethod(x @ sdf , " sample" , withReplacement , fraction )
685
- dataFrame(sdf )
686
- })
687
-
688
- # ' @rdname sample
689
- # ' @name sample
690
- setMethod ("sample ",
691
- # we can send seed as an argument through callJMethod
692
- signature(x = " DataFrame" , withReplacement = " logical" ,
693
- fraction = " numeric" , seed = " numeric" ),
694
- function (x , withReplacement , fraction , seed ) {
695
- if (fraction < 0.0 ) stop(cat(" Negative fraction value:" , fraction ))
696
- sdf <- callJMethod(x @ sdf , " sample" , withReplacement , fraction , as.integer(seed ))
684
+ if (! missing(seed )) {
685
+ sdf <- callJMethod(x @ sdf , " sample" , withReplacement , fraction , as.integer(seed ))
686
+ } else {
687
+ sdf <- callJMethod(x @ sdf , " sample" , withReplacement , fraction )
688
+ }
697
689
dataFrame(sdf )
698
690
})
699
691
700
692
# ' @rdname sample
701
693
# ' @name sample_frac
702
694
setMethod ("sample_frac ",
703
695
signature(x = " DataFrame" , withReplacement = " logical" ,
704
- fraction = " numeric" , seed = " missing" ),
705
- function (x , withReplacement , fraction , seed ) {
706
- sample(x , withReplacement , fraction )
707
- })
708
-
709
- # ' @rdname sample
710
- # ' @name sample_frac
711
- setMethod ("sample_frac ",
712
- signature(x = " DataFrame" , withReplacement = " logical" ,
713
- fraction = " numeric" , seed = " numeric" ),
696
+ fraction = " numeric" ),
714
697
function (x , withReplacement , fraction , seed ) {
715
- sample(x , withReplacement , fraction , as.integer(seed ))
698
+ if (! missing(seed )) {
699
+ sample(x , withReplacement , fraction , as.integer(seed ))
700
+ } else {
701
+ sample(x , withReplacement , fraction )
702
+ }
716
703
})
717
704
718
705
# ' nrow
0 commit comments