grab<- function(file)
{
fin<- fread(file=file,
sep=NULL,
dec=".",
quote="", nrows=Inf, header=FALSE,
stringsAsFactors=FALSE, verbose=FALSE,
col.names=c("record"),
check.names=FALSE, fill=FALSE, blank.lines.skip=FALSE,
showProgress=TRUE,
data.table=FALSE, skip=0,
nThread=2, logical01=FALSE, keepLeadingZeros=FALSE)
cat(sprintf("Read '%s'.\n", file))
#
substance<- apply(X=fin, MARGIN=1, FUN=function(r) chartr(",", "\t", r[1]))
cat(sprintf("Translated '%s'.\n", file))
D<- fread(text=substance,
sep="\t",
dec=".",
quote="", nrows=Inf, header=FALSE,
stringsAsFactors=FALSE, verbose=FALSE,
col.names=c("ip", "valid.hits", "err.hits", "megabytes"),
check.names=FALSE, fill=FALSE, blank.lines.skip=FALSE,
showProgress=TRUE,
data.table=FALSE, skip=0,
nThread=2, logical01=FALSE, keepLeadingZeros=FALSE)
cat(sprintf("Parsed '%s'.\n", file))
ip<- D$ip
withinBlock<- sapply(X=ip, FUN=function(s) as.integer((strsplit(x=s, split=".", fixed=TRUE)[[1]])[4]))
D$within.block<- withinBlock
return(D)
}