Skip to content

Commit

Permalink
Added documentation for dna_connection and print method
Browse files Browse the repository at this point in the history
  • Loading branch information
leifeld committed Mar 16, 2017
1 parent fb1740c commit 3eff15d
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rDNA/DESCRIPTION
Expand Up @@ -12,4 +12,4 @@ Depends:
rJava (>= 0.5-0)
SystemRequirements: Java (>= 1.8)
License: GPL-3
RoxygenNote: 5.0.1
RoxygenNote: 6.0.1
2 changes: 2 additions & 0 deletions rDNA/NAMESPACE
@@ -1,4 +1,6 @@
# Generated by roxygen2: do not edit by hand

S3method(print,dna_connection)
export(dna_connection)
export(dna_gui)
export(dna_init)
52 changes: 50 additions & 2 deletions rDNA/R/rDNA.R
Expand Up @@ -70,7 +70,35 @@ dna_gui <- function(infile = NULL, javapath = NULL, memory = 1024) {
}
}

# function for establishing a database connection

#' Establish a database connection
#'
#' Connect to a local .dna file or remote mySQL DNA database.
#'
#' Before any data can be loaded from a database, a connection with
#' the database must be established. The \code{dna_connection}
#' function establishes a database connection and loads the documents
#' and statements into memory for further processing.
#'
#' @param infile The file name of the .dna database or the URL of the mySQL
#' database to load
#' @param login The user name for accessing the database (only applicable
#' to remote mySQL databases; can be \code{NULL} if a local .dna file
#' is used).
#' @param password The password for accessing the database (only applicable
#' to remote mySQL databases; can be \code{NULL} if a local .dna file
#' is used).
#' @param verbose Print details the number of documents and statements after
#' loading the database?
#'
#' @examples
#' download.file("https://github.com/leifeld/dna/releases/download/v2.0-beta.19/dna-2.0-beta19.jar",
#' destfile = "dna-2.0-beta19.jar", mode = "wb")
#' download.file("https://github.com/leifeld/dna/releases/download/v2.0-beta.19/sample.dna",
#' destfile = "sample.dna", mode = "wb")
#' dna_init("dna-2.0-beta19.jar")
#' dna_connection("sample.dna")
#' @export
dna_connection <- function(infile, login = NULL, password = NULL, verbose = TRUE) {
if (is.null(login) || is.null(password)) {
export <- .jnew("dna.export/Exporter", "sqlite", infile, "", "", verbose)
Expand All @@ -85,11 +113,30 @@ dna_connection <- function(infile, login = NULL, password = NULL, verbose = TRUE
return(obj)
}

# print a summary of a dna_connection object

#' Print the summary of a \code{dna_connection} object
#'
#' Show details of a \code{dna_connection} object.
#'
#' Print the number of documents and statements to the console after
#' establishing a DNA connection.
#'
#' @param x A \code{dna_connection} object.
#'
#' @examples
#' download.file("https://github.com/leifeld/dna/releases/download/v2.0-beta.19/dna-2.0-beta19.jar",
#' destfile = "dna-2.0-beta19.jar", mode = "wb")
#' download.file("https://github.com/leifeld/dna/releases/download/v2.0-beta.19/sample.dna",
#' destfile = "sample.dna", mode = "wb")
#' dna_init("dna-2.0-beta19.jar")
#' conn <- dna_connection("sample.dna", verbose = FALSE)
#' conn
#' @export
print.dna_connection <- function(x) {
.jcall(x$dna_connection, "V", "rShow")
}


# retrieve attribute data.frame
dna_attributes <- function(dna_connection,
statementType = "DNA Statement",
Expand All @@ -114,6 +161,7 @@ dna_attributes <- function(dna_connection,
return(dat)
}


# compute a one-mode or two-mode network matrix
dna_network <- function(dna_connection,
networkType = "twomode",
Expand Down
40 changes: 40 additions & 0 deletions rDNA/man/dna_connection.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion rDNA/man/dna_gui.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion rDNA/man/dna_init.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions rDNA/man/print.dna_connection.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3eff15d

Please sign in to comment.