dc.ReadLines: Read Lines

Description Usage Arguments Details Examples

View source: R/dc.R

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

1
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

1
2
3
4
5
6
7
# 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")

BTYD documentation built on Nov. 18, 2021, 1:10 a.m.