Last data update: 2014.03.03

R: Import data into a BuxcoDB database
dbImportR Documentation

Import data into a BuxcoDB database

Description

The main purpose of this function is to add data originally retrieved from the retrieveData method into a new or existing BuxcoDB database. This will most frequently be useful in the context of a merging procedure, however it also can facilitate data sharing and/or communication between seperate DBMS systems.

Usage

dbImport(bux.db = NULL, bux.dta, db.name = "merge_test_1.db", debug = FALSE)

Arguments

bux.db

Either NULL or a BuxcoDB object

bux.dta

A data.frame consistent with the database structure of the BuxcoDB database, most easily created from a call to retrieveData.

db.name

Path to the new SQLite database to create.

debug

Logical value indicating whether the function should be more verbose.

Details

If only bux.dta is supplied and not bux.db, then a new database will be created and populated at db.name from its contents. If both db.name and bux.dta are supplied then the data.frame will be loaded into the existing database.

Value

A BuxcoDB object pointing to the newly created database.

Author(s)

Daniel Bottomly

See Also

BuxcoDB, retrieveData

Examples

bux.db <- makeBuxcoDB(sample.db.path())

samp.1 <- retrieveData(bux.db, samples="8034x13140_5")
	
test.db <- "test_db.db"
	
if (file.exists(test.db))
{
	file.remove(test.db)
}
	
#create a new database from the output
db.1 <- dbImport(bux.db=NULL, bux.dta=samp.1, db.name=test.db)
	
samples(db.1)
	
test.db.2 <- "test_db_2.db"
	
if (file.exists(test.db.2))
{
	file.remove(test.db.2)
}

samp.2 <- retrieveData(bux.db, samples="8034x13140_11")
	
db.2 <- dbImport(bux.db=db.1, bux.dta=samp.2, db.name=test.db.2)
	
samples(db.2)
	
file.remove(test.db.2)
file.remove(test.db)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(plethy)
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

Loading required package: S4Vectors
Loading required package: stats4

Attaching package: 'S4Vectors'

The following objects are masked from 'package:base':

    colMeans, colSums, expand.grid, rowMeans, rowSums

> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/plethy/dbImport.Rd_%03d_medium.png", width=480, height=480)
> ### Name: dbImport
> ### Title: Import data into a BuxcoDB database
> ### Aliases: dbImport
> ### Keywords: utilities
> 
> ### ** Examples
> 
> bux.db <- makeBuxcoDB(sample.db.path())
> 
> samp.1 <- retrieveData(bux.db, samples="8034x13140_5")
> 	
> test.db <- "test_db.db"
> 	
> if (file.exists(test.db))
+ {
+ 	file.remove(test.db)
+ }
> 	
> #create a new database from the output
> db.1 <- dbImport(bux.db=NULL, bux.dta=samp.1, db.name=test.db)
> 	
> samples(db.1)
[1] "8034x13140_5"
> 	
> test.db.2 <- "test_db_2.db"
> 	
> if (file.exists(test.db.2))
+ {
+ 	file.remove(test.db.2)
+ }
> 
> samp.2 <- retrieveData(bux.db, samples="8034x13140_11")
> 	
> db.2 <- dbImport(bux.db=db.1, bux.dta=samp.2, db.name=test.db.2)
> 	
> samples(db.2)
[1] "8034x13140_5"  "8034x13140_11"
> 	
> file.remove(test.db.2)
[1] TRUE
> file.remove(test.db)
[1] TRUE
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>