coo_split: Split shapes on speficied coordinates

Description Usage Arguments Details Value Note See Also Examples

View source: R/coo_modifyers.R

Description

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.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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

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.

Value

a coo_single, coo_list or mom_tbl

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

1
2
3
4
5
6
7
8
9
x <- bot %>% pick(1) %>% coo_sample(12)
x %>% coo_split(id=c(4, 8))
x %>% coo_split(id=c(4, 8), share=FALSE)

hearts %>%
  dplyr::slice(1:2) %>% # for the sake of speed
  coo_split(ldk=2:3)

# then dplyr::rename or Momocs2::coo_select if you want to rename/select columns

MomX/Momocs2 documentation built on May 13, 2020, 4:28 a.m.