#'Find closest long region upstream
#'
#'Helper function for \code{mergeRegions}
#'
#'
#'@param ind index of regions data frame
#'@param regions the $states data frame, as returned by \code{getRegions}
#'@return index of closest large region upstream of a region that needs to be
#'merged
#'@note Not generally used alone - internal function for \code{mergeRegions}
#'@author Alyssa Frazee
#'@export
#'@seealso \code{\link{mergeRegions}}
findclosest.behind = function(ind,regions){
if(ind==1){
if(regions$length[ind]>5){return(ind)}
if(regions$length[ind]<6){
warning("no regions behind with length > 5")
return(ind)
}
}
length.of.next = regions$length[ind-1]
if(length.of.next>5) return(ind-1)
if(length.of.next<6) findclosest.behind(ind-1,regions)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.