Commit 2803270b authored by Thomas Shatwell's avatar Thomas Shatwell
Browse files

Fixed issue when data is given as a data.table

parent 5f1f46fd
......@@ -66,7 +66,14 @@ profile2grid <- function(data, datetime, depth, value,
outdepths=NULL, rule=c(2,1),
dropNAs=FALSE) {
# require(data.table)
dat <- data.table::copy(data[,c(datetime,depth,value)])
select_cols <- c(datetime,depth,value)
if(data.table::is.data.table(data)) {
dat <- data.table::copy(data[,..select_cols])
} else if(is.data.frame(data)) {
dat <- data.table::copy(data[,select_cols])
} else {
stop("data must be a data.frame or data.table")
}
names(dat) <- c("dt", "dep", "val")
data.table::setDT(dat, key = "dt")
dates <- unique(dat[,dt])
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment