readFile: Read a file

Description Usage Arguments Details Value Author(s) Examples

View source: R/readFile.r View source: R/functions.r

Description

A wrapper function for read.table for easy reading files and ignoring a given number of header rows

Usage

1
2
readFile(dataFile, nSkip = 0, nSkipNames = 0, header = FALSE, reverse =
FALSE, sep = ",", na = "NaN")

Arguments

dataFile

A character with the name of the file to read. It can include a full length path.

nSkip

The number of rows to skip to read the data

nSkipNames

The number of rows to skip to read the column names

header

Logical, for indicating if the file has a header or not. Default is TRUE.

reverse

Logical. If true then first reads a header and then skips a number or rows to read the data. Works in conjunction with nSkip option

sep

The field separator. Default is comma delimited

na

The value used in the file to represent NAs (e.g., -9999). The default is NaN

Details

It read a file by skiping first a number of rows to read the data and then reads the file again skiping a second number of rows to read the row with the variable names.

Value

Returns a data frame

Author(s)

Georgios Xenakis

Examples

1
2
3
4
5
6
7
8
## Load the data
data(harwood)

## Write the data as csv
write.table(harwood,file="harwood.csv",sep=",",quote=FALSE,row.names=FALSE)

## Now read the file as a new data frame
harwood=readFile('harwood.csv',3,1,na='NaN')

FREddyPro documentation built on May 29, 2017, 7:22 p.m.