dc.ReadLines {BTYD}R Documentation

Read Lines

Description

Given a .csv file that throws errors when read in by the usual read.csv and read.table methods, loops through the file line-by-line and picks out the customer, date, and sales (optional) transaction data to return an event log.

Usage

dc.ReadLines(csv.filename, cust.idx, date.idx, sales.idx = -1)

Arguments

csv.filename

The name of the comma-delimited file to be read. This file must contain headers.

cust.idx

The index of the customer ID column in the comma-delimited file.

date.idx

The index of the date column in the comma-delimited file.

sales.idx

The index of the sales column in the comma-delimited file.

Details

Once this function has been run, you may need to convert the date column to Date objects for the event log to work with other functions in this library. See the as.Date function in the base R package for more details.

Examples

# Create event log from file "cdnowElog.csv", which has
# customer IDs in the second column, dates in the third column, and
# sales numbers in the fifth column.
elog <- dc.ReadLines(system.file("data/cdnowElog.csv", package="BTYD"),2,3,5)

# convert date column to date objects, as required by some other functions
elog$date <- as.Date(elog$date, "$Y%m%d")

[Package BTYD version 2.4.3 Index]