Description Usage Arguments Value Examples
View source: R/segmentation_helper_functions.R
Identify changes within a discrete variable. These values can be used to
pre-specify breakpoints within the segmentation model using
segment_behavior
.
1 | find_breaks(dat, ind)
|
dat |
A data frame containing the data for each animal ID. |
ind |
character. The name of the column storing the discrete variable of interest. |
A vector of breakpoints is returned based on the data provided. If
wishing to identify separate breakpoints per animal ID, this function
should be mapped onto a list generated by df_to_list
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #simuluate data
var<- sample(1:3, size = 50, replace = TRUE)
var<- rep(var, each = 20)
id<- rep(1:10, each = 100)
#create data frame
dat<- data.frame(id, var)
#create list
dat.list<- df_to_list(dat = dat, ind = "id")
#run function using purrr::map()
breaks<- purrr::map(dat.list, ~find_breaks(dat = ., ind = "var"))
#or with lapply()
breaks1<- lapply(dat.list, find_breaks, ind = "var")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.