@@ -678,41 +678,28 @@ setMethod("unique",
678678# '}
679679setMethod ("sample ",
680680 signature(x = " DataFrame" , withReplacement = " logical" ,
681- fraction = " numeric" , seed = " missing " ),
681+ fraction = " numeric" ),
682682 function (x , withReplacement , fraction , seed ) {
683683 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+ }
697689 dataFrame(sdf )
698690 })
699691
700692# ' @rdname sample
701693# ' @name sample_frac
702694setMethod ("sample_frac ",
703695 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" ),
714697 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+ }
716703 })
717704
718705# ' nrow
0 commit comments