statistics - How to find if the numbers are continuous in R? -


i have range of values

c(1,2,3,4,5,8,9,10,13,14,15) 

and want find ranges numbers become discontinuous. want output:

(1,5) (8,10) (13,15) 

i need find break points.

i need in r.

x <- c(1:5, 8:10, 13:15)     rr <- rle(x - seq_along(x)) rr$values <- seq_along(rr$values) s <- split(x, inverse.rle(rr)) s # $`1` # [1] 1 2 3 4 5 #  # $`2` # [1]  8  9 10 #  # $`3` # [1] 13 14 15  ## , *literally* asked for: cat(paste0("(", gsub(":", ",", sapply(s, deparse)), ")"), sep="\n") # (1,5) # (8,10) # (13,15) 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -