Browse code

update mutate function documentation. Should support mutate(xx=NULL) to remove columns later..

Liu authored on 16/04/2020 03:44:01
Showing 9 changed files

... ...
@@ -1,6 +1,6 @@
1 1
 Package: SQLDataFrame
2 2
 Title: Representation of SQL database in DataFrame metaphor
3
-Version: 1.1.0
3
+Version: 1.1.1
4 4
 Authors@R: c(
5 5
     person("Qian", "Liu", email = "qliu7@buffalo.edu", role = c("aut", "cre"),
6 6
     comment = c(ORCID = "0000-0003-1456-5099")),
... ...
@@ -32,7 +32,7 @@ Imports:
32 32
     tibble
33 33
 License: GPL-3
34 34
 Encoding: UTF-8
35
-RoxygenNote: 6.1.1
35
+RoxygenNote: 7.1.0
36 36
 Suggests:
37 37
     RMySQL,
38 38
     bigrquery,
... ...
@@ -335,9 +335,13 @@ setMethod("$", "SQLDataFrame", function(x, name) x[[name]] )
335 335
 #'     length 1 or the same length as the number of rows in the group
336 336
 #'     (if using ‘group_by()’) or in the entire input (if not using
337 337
 #'     groups). The name of each argument will be the name of a new
338
-#'     variable, and the value will be its corresponding value. Use a
339
-#'     ‘NULL’ value in ‘mutate’ to drop a variable.  New variables
340
-#'     overwrite existing variables of the same name.
338
+#'     variable, and the value will be its corresponding value.
339
+#'      New variables
340
+#'     overwrite existing variables of the same name. NOTE that the new
341
+#'     value could only be of length 1 or the operation of existing columns.
342
+#'     If a new vector of values are given, error will return. This is due
343
+#'     to the internal method of 'mutate.tbl_lazy' not being able to take
344
+#'     new arbitrary values. 
341 345
 #' }
342 346
 #' @export
343 347
 #' @examples
... ...
@@ -427,7 +431,8 @@ mutate.SQLDataFrame <- function(.data, ...)
427 431
         tbl <- tbl(con, auxSchema)
428 432
         }
429 433
     }
430
-    tbl_out <- dplyr::mutate(tbl, ...)
434
+    tbl_out <- dplyr::mutate(tbl, ...) ## FIXME: use mutate(xx = NULL) to remove column?
435
+    ## once done, add to @param ...: Use ‘NULL’ value in ‘mutate’ to drop a variable.
431 436
     out <- BiocGenerics:::replaceSlots(.data, tblData = tbl_out)
432 437
 
433 438
     ## check if not-null for the existing @indexes, and update for mutate.
... ...
@@ -1,6 +1,5 @@
1 1
 % Generated by roxygen2: do not edit by hand
2 2
 % Please edit documentation in R/SQLDataFrame-class.R
3
-\docType{methods}
4 3
 \name{SQLDataFrame}
5 4
 \alias{SQLDataFrame}
6 5
 \alias{class:SQLDataFrame}
... ...
@@ -30,9 +29,18 @@
30 29
 \alias{coerce,ANY,SQLDataFrame-method}
31 30
 \title{SQLDataFrame class}
32 31
 \usage{
33
-SQLDataFrame(conn, host, user, dbname, password = NULL,
34
-  billing = character(0), type = c("SQLite", "MySQL", "BigQuery"),
35
-  dbtable = character(0), dbkey = character(0), col.names = NULL)
32
+SQLDataFrame(
33
+  conn,
34
+  host,
35
+  user,
36
+  dbname,
37
+  password = NULL,
38
+  billing = character(0),
39
+  type = c("SQLite", "MySQL", "BigQuery"),
40
+  dbtable = character(0),
41
+  dbkey = character(0),
42
+  col.names = NULL
43
+)
36 44
 
37 45
 \S4method{tblData}{SQLDataFrame}(x)
38 46
 
... ...
@@ -50,8 +58,7 @@ SQLDataFrame(conn, host, user, dbname, password = NULL,
50 58
 
51 59
 \S4method{show}{SQLDataFrame}(object)
52 60
 
53
-\S4method{as.data.frame}{SQLDataFrame}(x, row.names = NULL,
54
-  optional = NULL, ...)
61
+\S4method{as.data.frame}{SQLDataFrame}(x, row.names = NULL, optional = NULL, ...)
55 62
 }
56 63
 \arguments{
57 64
 \item{conn}{a valid \code{DBIConnection} from \code{SQLite},
... ...
@@ -1,6 +1,5 @@
1 1
 % Generated by roxygen2: do not edit by hand
2 2
 % Please edit documentation in R/SQLDataFrame-methods.R
3
-\docType{methods}
4 3
 \name{SQLDataFrame-methods}
5 4
 \alias{SQLDataFrame-methods}
6 5
 \alias{head}
... ...
@@ -15,11 +14,8 @@
15 14
 \alias{length}
16 15
 \alias{names,SQLDataFrame-method}
17 16
 \alias{names}
18
-\alias{[,SQLDataFrame,ANY,ANY,ANY-method}
19 17
 \alias{[,SQLDataFrame,ANY-method}
20
-\alias{[,SQLDataFrame,SQLDataFrame,ANY,ANY-method}
21 18
 \alias{[,SQLDataFrame,SQLDataFrame-method}
22
-\alias{[,SQLDataFrame,list,ANY,ANY-method}
23 19
 \alias{[,SQLDataFrame,list-method}
24 20
 \alias{[[,SQLDataFrame-method}
25 21
 \alias{$,SQLDataFrame-method}
... ...
@@ -47,12 +43,11 @@
47 43
 
48 44
 \S4method{names}{SQLDataFrame}(x)
49 45
 
50
-\S4method{[}{SQLDataFrame,ANY,ANY,ANY}(x, i, j, ..., drop = TRUE)
46
+\S4method{[}{SQLDataFrame,ANY}(x, i, j, ..., drop = TRUE)
51 47
 
52
-\S4method{[}{SQLDataFrame,SQLDataFrame,ANY,ANY}(x, i, j, ...,
53
-  drop = TRUE)
48
+\S4method{[}{SQLDataFrame,SQLDataFrame}(x, i, j, ..., drop = TRUE)
54 49
 
55
-\S4method{[}{SQLDataFrame,list,ANY,ANY}(x, i, j, ..., drop = TRUE)
50
+\S4method{[}{SQLDataFrame,list}(x, i, j, ..., drop = TRUE)
56 51
 
57 52
 \S4method{[[}{SQLDataFrame}(x, i, j, ...)
58 53
 
... ...
@@ -93,9 +88,13 @@ values, a named list of key values, and \code{SQLDataFrame},
93 88
     length 1 or the same length as the number of rows in the group
94 89
     (if using ‘group_by()’) or in the entire input (if not using
95 90
     groups). The name of each argument will be the name of a new
96
-    variable, and the value will be its corresponding value. Use a
97
-    ‘NULL’ value in ‘mutate’ to drop a variable.  New variables
98
-    overwrite existing variables of the same name.
91
+    variable, and the value will be its corresponding value.
92
+     New variables
93
+    overwrite existing variables of the same name. NOTE that the new
94
+    value could only be of length 1 or the operation of existing columns.
95
+    If a new vector of values are given, error will return. This is due
96
+    to the internal method of 'mutate.tbl_lazy' not being able to take
97
+    new arbitrary values. 
99 98
 }}
100 99
 
101 100
 \item{drop}{Whether to drop with reduced dimension. Default is
... ...
@@ -15,17 +15,13 @@
15 15
 \alias{anti_join,SQLDataFrame-method}
16 16
 \title{join \code{SQLDataFrame} together}
17 17
 \usage{
18
-\method{left_join}{SQLDataFrame}(x, y, by = NULL, copy = FALSE,
19
-  suffix = c(".x", ".y"), ...)
18
+\method{left_join}{SQLDataFrame}(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ...)
20 19
 
21
-\method{inner_join}{SQLDataFrame}(x, y, by = NULL, copy = FALSE,
22
-  suffix = c(".x", ".y"), ...)
20
+\method{inner_join}{SQLDataFrame}(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ...)
23 21
 
24
-\method{semi_join}{SQLDataFrame}(x, y, by = NULL, copy = FALSE,
25
-  suffix = c(".x", ".y"), ...)
22
+\method{semi_join}{SQLDataFrame}(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ...)
26 23
 
27
-\method{anti_join}{SQLDataFrame}(x, y, by = NULL, copy = FALSE,
28
-  suffix = c(".x", ".y"), ...)
24
+\method{anti_join}{SQLDataFrame}(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ...)
29 25
 }
30 26
 \arguments{
31 27
 \item{x}{\code{SQLDataFrame} objects to join.}
... ...
@@ -4,9 +4,21 @@
4 4
 \alias{makeSQLDataFrame}
5 5
 \title{Construct SQLDataFrame from file.}
6 6
 \usage{
7
-makeSQLDataFrame(filename, dbtable = NULL, dbkey = character(), conn,
8
-  host, user, dbname = NULL, password = NULL, type = c("SQLite",
9
-  "MySQL"), overwrite = FALSE, sep = ",", index = FALSE, ...)
7
+makeSQLDataFrame(
8
+  filename,
9
+  dbtable = NULL,
10
+  dbkey = character(),
11
+  conn,
12
+  host,
13
+  user,
14
+  dbname = NULL,
15
+  password = NULL,
16
+  type = c("SQLite", "MySQL"),
17
+  overwrite = FALSE,
18
+  sep = ",",
19
+  index = FALSE,
20
+  ...
21
+)
10 22
 }
11 23
 \arguments{
12 24
 \item{filename}{A \code{data.frame} or \code{DataFrame} object, or
... ...
@@ -1,6 +1,5 @@
1 1
 % Generated by roxygen2: do not edit by hand
2 2
 % Please edit documentation in R/rbindSQLDataFrame.R
3
-\docType{methods}
4 3
 \name{rbind}
5 4
 \alias{rbind}
6 5
 \alias{rbind,SQLDataFrame-method}
... ...
@@ -4,9 +4,15 @@
4 4
 \alias{saveSQLDataFrame}
5 5
 \title{Save SQLDataFrame object as a new database table.}
6 6
 \usage{
7
-saveSQLDataFrame(x, dbname = tempfile(fileext = ".db"),
8
-  dbtable = deparse(substitute(x)), localConn = connSQLDataFrame(x),
9
-  overwrite = FALSE, index = TRUE, ...)
7
+saveSQLDataFrame(
8
+  x,
9
+  dbname = tempfile(fileext = ".db"),
10
+  dbtable = deparse(substitute(x)),
11
+  localConn = connSQLDataFrame(x),
12
+  overwrite = FALSE,
13
+  index = TRUE,
14
+  ...
15
+)
10 16
 }
11 17
 \arguments{
12 18
 \item{x}{The \code{SQLDataFrame} object to be saved.}
... ...
@@ -1,6 +1,5 @@
1 1
 % Generated by roxygen2: do not edit by hand
2 2
 % Please edit documentation in R/unionSQLDataFrame.R
3
-\docType{methods}
4 3
 \name{union}
5 4
 \alias{union}
6 5
 \alias{union,SQLDataFrame,SQLDataFrame-method}