Skip to content

Commit

Permalink
handling of potential error
Browse files Browse the repository at this point in the history
  • Loading branch information
HannaMeyer committed Jan 22, 2024
1 parent e2d1a57 commit d83a6aa
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions R/CreateSpacetimeFolds.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ CreateSpacetimeFolds <- function(x,spacevar=NA,timevar=NA,
x <- data.frame(x)
### if classification is used, make sure that classes are equally distributed across folds
if(!is.na(class)){
if(is.numeric(x[,class])){
stop("argument class only works for categorical data")
}
unit <- unique(x[,c(spacevar,class)])
unit$CAST_fold <- createFolds(unit[,which(names(unit)==class)],k = k,list=FALSE)
#x <- merge(x,unit,by.x=c(spacevar,class),by.y=c(spacevar,class),all.x=TRUE,sort=FALSE)
Expand Down

0 comments on commit d83a6aa

Please sign in to comment.