Take a shape with n coordinates. For each id or ldk passed, the shape will be splitted on the corresponding coordinates and (length(id/ldk)+1) fragments returned.

coo_split(
  x,
  id,
  ldk,
  share,
  from_col = coo,
  ldk_col = ldk,
  to_col = {     {         from_col     } },
  ...
)

Arguments

x

coo_single, coo_list or mom_tbl

id

integer which is (column row) should be used as the first point

ldk

integer which landkmark should be used as the first point

share

logical whether to share the slicing coordinate between successive fragments.

from_col

colnames from where to get the coo_list

ldk_col

colnames from where to get the coo_list

to_col

colname where to set the result (default to from_col) and how to name the resulting one (only for mom_tbl method)

...

useless here

Value

a coo_single, coo_list or mom_tbl

Details

If share=TRUE, then each slicing coordinates will be shared between consecutive fragments, that is the last coordinates of the n-th fragment will also be the first of the n+1-th fragment. That is usually what you want, and thus default to TRUE.

ldk handling is only supported on mom_tbl objects.

Note

ldk happens to be present for coo_single and coo_list methods (unlike coo_slide for instance), only to please R CMD CHECK S3 consistency and maintain a sensible order for arguments, with share after coo and ldk. For these classes, it is ignored with a message.

See also

Have a look to coo_slidegap (todo link when ready) if you have problems with gaps after slicing around landmarks and/or starting points.

Other coo_modifyers: coo_align(), coo_baseline(), coo_center(), coo_reflect, coo_rev(), coo_rotatecenter(), coo_rotate(), coo_sample_rr(), coo_sample(), coo_scale(), coo_shear(), coo_slide(), coo_template(), coo_trans(), coo_trim(), coo_up()

Examples

x <- bot %>% pick(1) %>% coo_sample(12) x %>% coo_split(id=c(4, 8))
#> $`1` #> # A tibble: 4 x 2 #> x y #> <dbl> <dbl> #> 1 37 561 #> 2 63 361 #> 3 42 150 #> 4 143 15 #> ❯coo_single with 4 coordinates #> #> $`2` #> # A tibble: 5 x 2 #> x y #> <dbl> <dbl> #> 1 143 15 #> 2 316 113 #> 3 305 302 #> 4 295 523 #> 5 296 713 #> ❯coo_single with 5 coordinates #> #> $`3` #> # A tibble: 5 x 2 #> x y #> <dbl> <dbl> #> 1 296 713 #> 2 240 912 #> 3 205 1101 #> 4 110 1002 #> 5 82 781 #> ❯coo_single with 5 coordinates #>
x %>% coo_split(id=c(4, 8), share=FALSE)
#> $`1` #> # A tibble: 4 x 2 #> x y #> <dbl> <dbl> #> 1 37 561 #> 2 63 361 #> 3 42 150 #> 4 143 15 #> ❯coo_single with 4 coordinates #> #> $`2` #> # A tibble: 4 x 2 #> x y #> <dbl> <dbl> #> 1 316 113 #> 2 305 302 #> 3 295 523 #> 4 296 713 #> ❯coo_single with 4 coordinates #> #> $`3` #> # A tibble: 4 x 2 #> x y #> <dbl> <dbl> #> 1 240 912 #> 2 205 1101 #> 3 110 1002 #> 4 82 781 #> ❯coo_single with 4 coordinates #>
hearts %>% dplyr::slice(1:2) %>% # for the sake of speed coo_split(ldk=2:3)
#> coo_split: id not provided, working on ldk
#> # A tibble: 2 x 6 #> coo ldk aut coo_1 coo_2 coo_3 #> <list<coo_singl> <list> <fct> <list<coo_sing> <list<coo_sing> <list<coo_sing> #> 1 <tibble [80 × 2<dbl [… ced <tibble [5 × 2<tibble [75 × <tibble [2 × 2… #> 2 <tibble [80 × 2<dbl [… ced <tibble [7 × 2<tibble [73 × <tibble [2 × 2… #> ❯mom_tbl
# then dplyr::rename or Momocs2::coo_select if you want to rename/select columns