## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ## ----setup-------------------------------------------------------------------- library(discretes) ## ----------------------------------------------------------------------------- x <- integers() next_discrete(x, from = 10) next_discrete(x, from = 10, n = 5, include_from = TRUE) prev_discrete(x, from = 1.3, n = 5) ## ----------------------------------------------------------------------------- get_discretes_at(integers(), values = c(-10, 4, 3.5, 10, NA)) get_discretes_at(integers(), values = 5.5) ## ----------------------------------------------------------------------------- get_discretes_in(integers(), from = 6.6, to = 10.1) get_discretes_in(1 / integers(0, 5)) ## ----------------------------------------------------------------------------- natural1()[2] natural1()[c(1, 3, 5)] ## ----------------------------------------------------------------------------- x <- as_discretes(1:4) x[-1] x[c(0, NA, 1, 4, 1, 5)] x[] ## ----------------------------------------------------------------------------- num_discretes(integers(), from = -2, to = 5) num_discretes(1 / 2^integers(), from = 0, to = 1) ## ----------------------------------------------------------------------------- has_discretes(natural1(), c(0, 1, 2, 2.5)) has_discretes(integers(), c(-10, 0, 10, NA)) ## ----------------------------------------------------------------------------- sinks(integers()) sinks(0.5^natural0()) reciprocals <- 1 / integers() sinks(reciprocals) ## ----------------------------------------------------------------------------- has_sink_in(integers()) has_sink_at(integers(), Inf) has_sink_at(integers(), -Inf, dir = "right")