## ----CAP394_CabSpotting_libs, message=FALSE, warning=FALSE--------------- library(lubridate) ## ----CAP394_CabSpotting_Read01, message=FALSE, warning=FALSE------------- file = "Data/cabspottingdata/new_obceoo.txt" data <- read.table(file, sep = "", header = FALSE, na.strings ="NA", stringsAsFactors = FALSE) colnames(data) <- c("latitude","longitude","occupied","timestamp") str(data) ## ----CAP394_CabSpotting_convert, message=FALSE, warning=FALSE------------ data$time <- as_datetime(data$timestamp) data$occupied <- factor(data$occupied) str(data) ## ----CAP394_CabSpotting_Read02, message=FALSE, warning=FALSE------------- files <- list.files(path="Data/cabspottingdata/",pattern="^new_.*\\.txt",full.names=TRUE) files <- files[0:3] allData <- lapply(files,read.table,sep = "",header = FALSE,na.strings ="NA", stringsAsFactors = FALSE) lapply(allData,nrow) allData2 <- do.call(rbind, allData) nrow(allData2)