Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion R/MultiCell.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ MultiCellMarketSelection <- function(data,
}

# Check Sampling Method
if(!(tolower(sampling_method) %in% c("systematic"))){
if(!(tolower(sampling_method) %in% c("systematic", "stratified"))){
stop("\nEnter a valid sampling_method (check the function documentation for more details).")
}

Expand Down Expand Up @@ -202,6 +202,14 @@ MultiCellMarketSelection <- function(data,
rank_by_loc$cell[seq(r[i], locs_N, k)] <- i
}
}
# Stratified or 'Block' Randomization
else if(tolower(sampling_method) == "stratified"){
rank_by_loc$strata <- ceiling(1:locs_N/k)

for (i in 1:max(rank_by_loc$strata)){
suppressWarnings(rank_by_loc$cell[rank_by_loc$strata==i] <- sample(1:k,k))
}
}

# Initializing output objects
GeoLift_Markets <- list()
Expand Down