import: Import Data From External Databases

Description Usage Arguments Value See Also Examples

View source: R/import.r

Description

This function imports data from tables located in external databases. It is a wrapper for functions odbcConnect and sqlQuery from the package RODBC. Three database formats are managed only on Windows platform : MS Access, MS Excel and Dbase. Note that The 2007 versions *.xlsx and *.accdb work with the drivers which are installed with Microsoft Office 2007. Dbase file name can only have a maximum length of 8 characters.

Usage

1
2
  import(tab = NULL, db = NULL, query = "all", as.Date = FALSE)
  

Arguments

tab

A character chain giving the name of the table in the external database.

db

A character chain giving the name of the external data base. If left empty, file.choose is called resulting in a pop-up window allowing to choose the desired file with the mouse.

query

A character chain giving any valid SQL statement. The default ("all") results in the selection of all the records in the target table. It is equivalent to "select * from target_table", where target_table is the table given in tab.

as.Date

Logical (default = FALSE). If TRUE, all variables of classes POSIXct and POSIXlt are transformed into variables of class Date with the as.Date function using a UTC timezone.

Value

A data frame.

See Also

odbcConnect, sqlQuery, file.choose

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 

tmp <- import()
tmp

tmp <- import(tab = "Tab1", db = "D:/Users/Data/tmp.accdb")
tmp
tmp <- import(tab = "Tab1", db = "D:/Users/Data/tmp.mdb")
tmp

tmp <- import(tab = "Sheet1", db = "D:/Users/Data/tmp.xlsx")
tmp
tmp <- import(tab = "Sheet1", db = "D:/Users/Data/tmp.xls")
tmp

  
## End(Not run)

tdisplay documentation built on May 2, 2019, 4:46 p.m.