@@ -150,7 +150,7 @@ setMethod("isLocal",
150150 callJMethod(x @ sdf , " isLocal" )
151151 })
152152
153- # ' ShowDF
153+ # ' showDF
154154# '
155155# ' Print the first numRows rows of a DataFrame
156156# '
@@ -170,7 +170,8 @@ setMethod("isLocal",
170170setMethod ("showDF ",
171171 signature(x = " DataFrame" ),
172172 function (x , numRows = 20 ) {
173- callJMethod(x @ sdf , " showString" , numToInt(numRows ))
173+ s <- callJMethod(x @ sdf , " showString" , numToInt(numRows ))
174+ cat(s )
174175 })
175176
176177# ' show
@@ -187,7 +188,7 @@ setMethod("showDF",
187188# ' sqlCtx <- sparkRSQL.init(sc)
188189# ' path <- "path/to/file.json"
189190# ' df <- jsonFile(sqlCtx, path)
190- # ' show(df)
191+ # ' df
191192# '}
192193setMethod ("show ", "DataFrame",
193194 function (object ) {
@@ -293,8 +294,8 @@ setMethod("registerTempTable",
293294# '\dontrun{
294295# ' sc <- sparkR.init()
295296# ' sqlCtx <- sparkRSQL.init(sc)
296- # ' df <- loadDF (sqlCtx, path, "parquet")
297- # ' df2 <- loadDF (sqlCtx, path2, "parquet")
297+ # ' df <- read.df (sqlCtx, path, "parquet")
298+ # ' df2 <- read.df (sqlCtx, path2, "parquet")
298299# ' registerTempTable(df, "table1")
299300# ' insertInto(df2, "table1", overwrite = TRUE)
300301# '}
@@ -472,14 +473,14 @@ setMethod("distinct",
472473 dataFrame(sdf )
473474 })
474475
475- # ' SampleDF
476+ # ' Sample
476477# '
477478# ' Return a sampled subset of this DataFrame using a random seed.
478479# '
479480# ' @param x A SparkSQL DataFrame
480481# ' @param withReplacement Sampling with replacement or not
481482# ' @param fraction The (rough) sample target fraction
482- # ' @rdname sampleDF
483+ # ' @rdname sample
483484# ' @aliases sample_frac
484485# ' @export
485486# ' @examples
@@ -488,10 +489,10 @@ setMethod("distinct",
488489# ' sqlCtx <- sparkRSQL.init(sc)
489490# ' path <- "path/to/file.json"
490491# ' df <- jsonFile(sqlCtx, path)
491- # ' collect(sampleDF (df, FALSE, 0.5))
492- # ' collect(sampleDF (df, TRUE, 0.5))
492+ # ' collect(sample (df, FALSE, 0.5))
493+ # ' collect(sample (df, TRUE, 0.5))
493494# '}
494- setMethod ("sampleDF ",
495+ setMethod ("sample ",
495496 # TODO : Figure out how to send integer as java.lang.Long to JVM so
496497 # we can send seed as an argument through callJMethod
497498 signature(x = " DataFrame" , withReplacement = " logical" ,
@@ -502,13 +503,13 @@ setMethod("sampleDF",
502503 dataFrame(sdf )
503504 })
504505
505- # ' @rdname sampleDF
506- # ' @aliases sampleDF
506+ # ' @rdname sample
507+ # ' @aliases sample
507508setMethod ("sample_frac ",
508509 signature(x = " DataFrame" , withReplacement = " logical" ,
509510 fraction = " numeric" ),
510511 function (x , withReplacement , fraction ) {
511- sampleDF (x , withReplacement , fraction )
512+ sample (x , withReplacement , fraction )
512513 })
513514
514515# ' Count
@@ -1302,17 +1303,17 @@ setMethod("except",
13021303# ' @param source A name for external data source
13031304# ' @param mode One of 'append', 'overwrite', 'error', 'ignore'
13041305# '
1305- # ' @rdname saveAsTable
1306+ # ' @rdname write.df
13061307# ' @export
13071308# ' @examples
13081309# '\dontrun{
13091310# ' sc <- sparkR.init()
13101311# ' sqlCtx <- sparkRSQL.init(sc)
13111312# ' path <- "path/to/file.json"
13121313# ' df <- jsonFile(sqlCtx, path)
1313- # ' saveAsTable (df, "myfile")
1314+ # ' write.df (df, "myfile", "parquet", "overwrite ")
13141315# ' }
1315- setMethod ("saveDF ",
1316+ setMethod ("write.df ",
13161317 signature(df = " DataFrame" , path = ' character' , source = ' character' ,
13171318 mode = ' character' ),
13181319 function (df , path = NULL , source = NULL , mode = " append" , ... ){
@@ -1333,6 +1334,15 @@ setMethod("saveDF",
13331334 callJMethod(df @ sdf , " save" , source , jmode , options )
13341335 })
13351336
1337+ # ' @rdname write.df
1338+ # ' @aliases saveDF
1339+ # ' @export
1340+ setMethod ("saveDF ",
1341+ signature(df = " DataFrame" , path = ' character' , source = ' character' ,
1342+ mode = ' character' ),
1343+ function (df , path = NULL , source = NULL , mode = " append" , ... ){
1344+ write.df(df , path , source , mode , ... )
1345+ })
13361346
13371347# ' saveAsTable
13381348# '
0 commit comments