importRDB: Import Files

View source: R/importRDB.R

importRDBR Documentation

Import Files

Description

Imports a formatted, tab-delimited file to a data frame.

Usage

importRDB(file.name = "", date.format = NULL, tz = "",
  convert.type = TRUE)

Arguments

file.name

a character string specifying the name of the relational database (RDB) file containing the data to be imported.

date.format

a character string specifying the format of all date columns. Required for columns that contain date and time. The default value, NULL, will read any valid date (not date and time) format. The special formats "none," which suppresses date conversion; and "varies," which can be used when the date data included time data sometimes and sometimes not. For the latter special format, the date and time data must be in POSIX format (YYYY-mm-dd HH:MM) with optional seconds. For dates that are missing time data, the time will be set to midnight in the specified or local time zone.

tz

the time zone information of the data.

convert.type

logical TRUE or FALSE, convert data according to the format line? Setting convert.type to FALSE forces all data to be imported as character.

Details

All of the dates in a date column must have the same format as the first non-blank date in the column. Any date with a format different from that of the first non-blank date in the column will be imported as NA (missing value). By default, dates are imported as class "Date" using a 4-digit year, 2-digit month, and 2-digit day with the period (.), hyphen (-), slash (/), or no separator.

If a valid date.format is supplied, then the data are imported using as.POSIXct, and time information can be included in the data. If date.format is "none," then conversion of the date information is suppressed and the data are retained as character strings.

The value for tz should be a valid "Olson" format consisting typically of a continent and city. See timezone for a description of time zones. For the United States, use these time-zone specifications where daylight savings time is used:

Eastern "America/New_York"
Central "America/Chicago"
Mountain "America/Denver"
Pacific "America/Los_Angeles"
Alaska "America/Anchorage"
Hawii "America/Honolulu"

Use these time specifications where daylight savings time is not used: #'

Eastern "America/Jamaica"
Central "America/Managua"
Mountain "America/Phoenix"
Pacific "America/Metlakatla"

Value

A data frame with one column for each data column in the RDB file.

Note

A NULL data frame is created if there are no data in the file.

The header information contained in the RDB file is retained in the output dataset as comment.

If convert.type is TRUE, then non-numeric values, other than blanks, are converted to NaN (not a number) rather than NA (missing value) in numeric columns. NaN values are treated like NA values but can be identified using the is.nan function.

See Also

read.table, as.Date, as.POSIXct, comment

Examples

## Not run: 
## This dataset is available in smwrData as a text file
TestDir <- system.file("misc", package="smwrData")
TestFull <- importRDB(file.path(TestDir, "TestFull.rdb"))

## End(Not run)

USGS-R/smwrBase documentation built on Oct. 18, 2022, 9:55 a.m.