Description Usage Arguments Details Value Examples
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.
1 | dc.ReadLines(csv.filename, cust.idx, date.idx, sales.idx = -1)
|
csv.filename |
filename of the comma-delimited file to be read. It must contain headers. |
cust.idx |
index of the customer ID column in the comma-delimited file. |
date.idx |
index of the date column in the comma-delimited file. |
sales.idx |
index of the sales column in the comma-delimited file. |
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 main package for more details.
Event log with columns labelled "cust" and "date". If sales data is included in the comma-delimited file, a "sales" column is included in the event log.
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.