readFile {RSurvey} | R Documentation

## Data Input

### Description

Reads a file in table format.

### Usage

    readFile(file, fields = TRUE, units = TRUE)

### Arguments

`file` | either a character string naming a file or a connection.
`fields` | a logical value indicating whether the file contains the names of the variables as its first line.
`units` | a logical value indicating whether the file contains the units of the variables as its second line.

### Format

A tab delineated file, ‘*.txt’, containing the following variables:

`[,1]` | character | date/time (optional)
`[,2]` | numeric | x values
`[,3]` | numeric | y values
`[,4:]` | numeric | z values, state variable(s)

The first `[1,]` and second `[2,]` rows are reserved for column descriptors and units, respectively. Units associated with date/time values are based on format character strings described in `strptime`, for example `"%d/%m/%Y %H:%M:%OS"`. You can embed comments in the data file by using the “`#`” character. Anything after a “`#`” on a line will be ignored.

### Value

A list with the following components: `cols`, a character array of column names. `vars`, a character array of column names associated with the date/time `[1]`, x `[2]`, y `[3]`, and z `[4]` variables. `data.raw`, a data frame of raw survey data.

### Author(s)

Fisher, J. C.

### See Also

`read.table`

### Examples

    ## A sample file including a header and two rows of data.

    ## Date / Time  Easting Northing        Depth
    ## %d/%m/%Y %H:%M:%OS     m       m       m
    ## 06/01/2001 01:01:59.000      727972.52       4138308.65      3.12
    ## 06/01/2001 01:01:59.200      727972.51       4138308.68      3.12

    f <- system.file("RSurvey-ex/lake.txt", package = "RSurvey")
    con <- file(f, open = "r", encoding = "latin1")
    d <- readFile(con)
    srvy.dat("cols", d$cols)
    srvy.dat("vars", d$vars)
    srvy.dat("data.raw", d$dat)

[Package RSurvey version 0.4.5 Index]