@@ -38,7 +38,7 @@ setClass("DataFrame",
38
38
setMethod ("initialize ", "DataFrame", function(.Object, sdf, isCached) {
39
39
.Object @ env <- new.env()
40
40
.Object @ env $ isCached <- isCached
41
-
41
+
42
42
.Object @ sdf <- sdf
43
43
.Object
44
44
})
@@ -55,11 +55,11 @@ dataFrame <- function(sdf, isCached = FALSE) {
55
55
# ########################### DataFrame Methods ##############################################
56
56
57
57
# ' Print Schema of a DataFrame
58
- # '
58
+ # '
59
59
# ' Prints out the schema in tree format
60
- # '
60
+ # '
61
61
# ' @param x A SparkSQL DataFrame
62
- # '
62
+ # '
63
63
# ' @rdname printSchema
64
64
# ' @export
65
65
# ' @examples
@@ -78,11 +78,11 @@ setMethod("printSchema",
78
78
})
79
79
80
80
# ' Get schema object
81
- # '
81
+ # '
82
82
# ' Returns the schema of this DataFrame as a structType object.
83
- # '
83
+ # '
84
84
# ' @param x A SparkSQL DataFrame
85
- # '
85
+ # '
86
86
# ' @rdname schema
87
87
# ' @export
88
88
# ' @examples
@@ -100,9 +100,9 @@ setMethod("schema",
100
100
})
101
101
102
102
# ' Explain
103
- # '
103
+ # '
104
104
# ' Print the logical and physical Catalyst plans to the console for debugging.
105
- # '
105
+ # '
106
106
# ' @param x A SparkSQL DataFrame
107
107
# ' @param extended Logical. If extended is False, explain() only prints the physical plan.
108
108
# ' @rdname explain
@@ -200,11 +200,11 @@ setMethod("show", "DataFrame",
200
200
})
201
201
202
202
# ' DataTypes
203
- # '
203
+ # '
204
204
# ' Return all column names and their data types as a list
205
- # '
205
+ # '
206
206
# ' @param x A SparkSQL DataFrame
207
- # '
207
+ # '
208
208
# ' @rdname dtypes
209
209
# ' @export
210
210
# ' @examples
@@ -224,11 +224,11 @@ setMethod("dtypes",
224
224
})
225
225
226
226
# ' Column names
227
- # '
227
+ # '
228
228
# ' Return all column names as a list
229
- # '
229
+ # '
230
230
# ' @param x A SparkSQL DataFrame
231
- # '
231
+ # '
232
232
# ' @rdname columns
233
233
# ' @export
234
234
# ' @examples
@@ -256,12 +256,12 @@ setMethod("names",
256
256
})
257
257
258
258
# ' Register Temporary Table
259
- # '
259
+ # '
260
260
# ' Registers a DataFrame as a Temporary Table in the SQLContext
261
- # '
261
+ # '
262
262
# ' @param x A SparkSQL DataFrame
263
263
# ' @param tableName A character vector containing the name of the table
264
- # '
264
+ # '
265
265
# ' @rdname registerTempTable
266
266
# ' @export
267
267
# ' @examples
@@ -306,11 +306,11 @@ setMethod("insertInto",
306
306
})
307
307
308
308
# ' Cache
309
- # '
309
+ # '
310
310
# ' Persist with the default storage level (MEMORY_ONLY).
311
- # '
311
+ # '
312
312
# ' @param x A SparkSQL DataFrame
313
- # '
313
+ # '
314
314
# ' @rdname cache-methods
315
315
# ' @export
316
316
# ' @examples
@@ -400,7 +400,7 @@ setMethod("repartition",
400
400
signature(x = " DataFrame" , numPartitions = " numeric" ),
401
401
function (x , numPartitions ) {
402
402
sdf <- callJMethod(x @ sdf , " repartition" , numToInt(numPartitions ))
403
- dataFrame(sdf )
403
+ dataFrame(sdf )
404
404
})
405
405
406
406
# toJSON
@@ -489,7 +489,7 @@ setMethod("distinct",
489
489
# ' sqlContext <- sparkRSQL.init(sc)
490
490
# ' path <- "path/to/file.json"
491
491
# ' df <- jsonFile(sqlContext, path)
492
- # ' collect(sample(df, FALSE, 0.5))
492
+ # ' collect(sample(df, FALSE, 0.5))
493
493
# ' collect(sample(df, TRUE, 0.5))
494
494
# '}
495
495
setMethod ("sample ",
@@ -513,11 +513,11 @@ setMethod("sample_frac",
513
513
})
514
514
515
515
# ' Count
516
- # '
516
+ # '
517
517
# ' Returns the number of rows in a DataFrame
518
- # '
518
+ # '
519
519
# ' @param x A SparkSQL DataFrame
520
- # '
520
+ # '
521
521
# ' @rdname count
522
522
# ' @export
523
523
# ' @examples
@@ -568,13 +568,13 @@ setMethod("collect",
568
568
})
569
569
570
570
# ' Limit
571
- # '
571
+ # '
572
572
# ' Limit the resulting DataFrame to the number of rows specified.
573
- # '
573
+ # '
574
574
# ' @param x A SparkSQL DataFrame
575
575
# ' @param num The number of rows to return
576
576
# ' @return A new DataFrame containing the number of rows specified.
577
- # '
577
+ # '
578
578
# ' @rdname limit
579
579
# ' @export
580
580
# ' @examples
@@ -593,7 +593,7 @@ setMethod("limit",
593
593
})
594
594
595
595
# ' Take the first NUM rows of a DataFrame and return a the results as a data.frame
596
- # '
596
+ # '
597
597
# ' @rdname take
598
598
# ' @export
599
599
# ' @examples
@@ -613,8 +613,8 @@ setMethod("take",
613
613
614
614
# ' Head
615
615
# '
616
- # ' Return the first NUM rows of a DataFrame as a data.frame. If NUM is NULL,
617
- # ' then head() returns the first 6 rows in keeping with the current data.frame
616
+ # ' Return the first NUM rows of a DataFrame as a data.frame. If NUM is NULL,
617
+ # ' then head() returns the first 6 rows in keeping with the current data.frame
618
618
# ' convention in R.
619
619
# '
620
620
# ' @param x A SparkSQL DataFrame
@@ -659,11 +659,11 @@ setMethod("first",
659
659
})
660
660
661
661
# toRDD()
662
- #
662
+ #
663
663
# Converts a Spark DataFrame to an RDD while preserving column names.
664
- #
664
+ #
665
665
# @param x A Spark DataFrame
666
- #
666
+ #
667
667
# @rdname DataFrame
668
668
# @export
669
669
# @examples
@@ -1167,7 +1167,7 @@ setMethod("where",
1167
1167
# '
1168
1168
# ' @param x A Spark DataFrame
1169
1169
# ' @param y A Spark DataFrame
1170
- # ' @param joinExpr (Optional) The expression used to perform the join. joinExpr must be a
1170
+ # ' @param joinExpr (Optional) The expression used to perform the join. joinExpr must be a
1171
1171
# ' Column expression. If joinExpr is omitted, join() wil perform a Cartesian join
1172
1172
# ' @param joinType The type of join to perform. The following join types are available:
1173
1173
# ' 'inner', 'outer', 'left_outer', 'right_outer', 'semijoin'. The default joinType is "inner".
@@ -1303,7 +1303,7 @@ setMethod("except",
1303
1303
# ' @param source A name for external data source
1304
1304
# ' @param mode One of 'append', 'overwrite', 'error', 'ignore'
1305
1305
# '
1306
- # ' @rdname write.df
1306
+ # ' @rdname write.df
1307
1307
# ' @export
1308
1308
# ' @examples
1309
1309
# '\dontrun{
@@ -1401,7 +1401,7 @@ setMethod("saveAsTable",
1401
1401
# ' @param col A string of name
1402
1402
# ' @param ... Additional expressions
1403
1403
# ' @return A DataFrame
1404
- # ' @rdname describe
1404
+ # ' @rdname describe
1405
1405
# ' @export
1406
1406
# ' @examples
1407
1407
# '\dontrun{
@@ -1444,7 +1444,7 @@ setMethod("describe",
1444
1444
# ' This overwrites the how parameter.
1445
1445
# ' @param cols Optional list of column names to consider.
1446
1446
# ' @return A DataFrame
1447
- # '
1447
+ # '
1448
1448
# ' @rdname nafunctions
1449
1449
# ' @export
1450
1450
# ' @examples
@@ -1465,7 +1465,7 @@ setMethod("dropna",
1465
1465
if (is.null(minNonNulls )) {
1466
1466
minNonNulls <- if (how == " any" ) { length(cols ) } else { 1 }
1467
1467
}
1468
-
1468
+
1469
1469
naFunctions <- callJMethod(x @ sdf , " na" )
1470
1470
sdf <- callJMethod(naFunctions , " drop" ,
1471
1471
as.integer(minNonNulls ), listToSeq(as.list(cols )))
@@ -1488,16 +1488,16 @@ setMethod("na.omit",
1488
1488
# ' @param value Value to replace null values with.
1489
1489
# ' Should be an integer, numeric, character or named list.
1490
1490
# ' If the value is a named list, then cols is ignored and
1491
- # ' value must be a mapping from column name (character) to
1491
+ # ' value must be a mapping from column name (character) to
1492
1492
# ' replacement value. The replacement value must be an
1493
1493
# ' integer, numeric or character.
1494
1494
# ' @param cols optional list of column names to consider.
1495
1495
# ' Columns specified in cols that do not have matching data
1496
- # ' type are ignored. For example, if value is a character, and
1496
+ # ' type are ignored. For example, if value is a character, and
1497
1497
# ' subset contains a non-character column, then the non-character
1498
1498
# ' column is simply ignored.
1499
1499
# ' @return A DataFrame
1500
- # '
1500
+ # '
1501
1501
# ' @rdname nafunctions
1502
1502
# ' @export
1503
1503
# ' @examples
@@ -1515,14 +1515,14 @@ setMethod("fillna",
1515
1515
if (! (class(value ) %in% c(" integer" , " numeric" , " character" , " list" ))) {
1516
1516
stop(" value should be an integer, numeric, charactor or named list." )
1517
1517
}
1518
-
1518
+
1519
1519
if (class(value ) == " list" ) {
1520
1520
# Check column names in the named list
1521
1521
colNames <- names(value )
1522
1522
if (length(colNames ) == 0 || ! all(colNames != " " )) {
1523
1523
stop(" value should be an a named list with each name being a column name." )
1524
1524
}
1525
-
1525
+
1526
1526
# Convert to the named list to an environment to be passed to JVM
1527
1527
valueMap <- new.env()
1528
1528
for (col in colNames ) {
@@ -1533,19 +1533,19 @@ setMethod("fillna",
1533
1533
}
1534
1534
valueMap [[col ]] <- v
1535
1535
}
1536
-
1536
+
1537
1537
# When value is a named list, caller is expected not to pass in cols
1538
1538
if (! is.null(cols )) {
1539
1539
warning(" When value is a named list, cols is ignored!" )
1540
1540
cols <- NULL
1541
1541
}
1542
-
1542
+
1543
1543
value <- valueMap
1544
1544
} else if (is.integer(value )) {
1545
1545
# Cast an integer to a numeric
1546
1546
value <- as.numeric(value )
1547
1547
}
1548
-
1548
+
1549
1549
naFunctions <- callJMethod(x @ sdf , " na" )
1550
1550
sdf <- if (length(cols ) == 0 ) {
1551
1551
callJMethod(naFunctions , " fill" , value )
0 commit comments