Free Access Week - Data Engineering + BI
Data Engineering and BI courses are free this week!
Free Access Week - Jun 2-8

FREddyPro (version 1.0)

readFile: Read a file

Description

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

Usage

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

Value

Returns a data frame

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.

Examples

Run this code
## 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')

Run the code above in your browser using DataLab