Add2DB {DECIPHER} | R Documentation

## Add Data to a Database

### Description

Adds a `data.frame` to a database table by its `row.names`.

### Usage

    Add2DB(myData,
           dbFile,
           tblName = "Seqs",
           clause = "",
           verbose = TRUE)

### Arguments

`myData` | Data frame containing information to be added to the `dbFile`.
`dbFile` | A SQLite connection object or a character string specifying the path to the database file.
`tblName` | Character string specifying the table in which to add the data.
`clause` | An optional character string to append to the query as part of a “where clause”.
`verbose` | Logical indicating whether to display each query as it is sent to the database.

### Details

Data contained in `myData` will be added to the `tblName` by its respective `row.names`.

### Value

Returns `TRUE` if the data was added successfully, or `FALSE` otherwise.

### Author(s)

Erik Wright eswright@pitt.edu

### References

ES Wright (2016) "Using DECIPHER v2.0 to Analyze Big Biological Sequence Data in R". The R Journal, 8(1), 352-359.

### See Also

`Seqs2DB`, `SearchDB`, `BrowseDB`

### Examples

    # Create a sequence database
    gen <- system.file("extdata", "Bacteria_175seqs.gen", package="DECIPHER")
    dbConn <- dbConnect(SQLite(), ":memory:")
    Seqs2DB(gen, "GenBank", dbConn, "Bacteria")

    # Identify the sequence lengths
    l <- IdLengths(dbConn)

    # Add lengths to the database
    Add2DB(l, dbConn)

    # View the added lengths
    BrowseDB(dbConn)

    # Change the value of existing columns
    ids <- data.frame(identifier=rep("Bacteroidetes", 18), stringsAsFactors=FALSE)
    rownames(ids) <- 10:27
    Add2DB(ids, dbConn)
    BrowseDB(dbConn)

    # Add data to a subset of rows using a clause
    ids[[1]][] <- "Changed"
    nrow(ids) # 18 rows
    Add2DB(ids, dbConn, clause="accession like 'EU808318%'")
    BrowseDB(dbConn) # only 1 row effected

    dbDisconnect(dbConn)

[Package DECIPHER version 2.8.1 Index]