Skip to contents

Flip a shape along a specified axis or line.

Usage

coo_flip_x(x, ..., .cols = NULL, .ldk_col = NULL)

coo_flip_xaxis(x, ..., .cols = NULL, .ldk_col = NULL)

coo_flip_y(x, ..., .cols = NULL, .ldk_col = NULL)

coo_flip_yaxis(x, ..., .cols = NULL, .ldk_col = NULL)

Arguments

x

A matrix (nx2), list of matrices, or tibble with coo columns.

...

Additional arguments (reserved for future use).

.cols

Column name(s) to process when x is a tibble. If NULL, automatically detects columns containing coo objects.

xintercept

Numeric. X intercept for flipping. Used in coo_flip_x().

yintercept

Numeric. Y intercept for flipping. Used in coo_flip_y().

Value

  • If x is a single matrix: returns the flipped matrix

  • If x is a list: returns a list of flipped matrices

  • If x is a tibble: returns the tibble with specified coo columns flipped

Details

  • coo_flip_x(): flip across vertical line at x intercept

  • coo_flip_xaxis(): flip across x-axis (y = 0)

  • coo_flip_y(): flip across horizontal line at y intercept

  • coo_flip_yaxis(): flip across y-axis (x = 0)

See also

coo_rotate() for rotation; coo_align() for alignment

Examples

# Flip across x-axis
coo_flip_xaxis(shapes$cat)
#> <xy [120 x 2]>
#>       [,1] [,2]
#>  [1,] 200  -62 
#>  [2,] 196  -56 
#>  [3,] 200  -56 
#>  [4,] 206  -54 
#>  [5,] 209  -48 
#>  [6,] ...  ... 
#>  [7,] 219  -45 
#>  [8,] 213  -47 
#>  [9,] 208  -53 
#> [10,] 204  -59 
#> [11,] 202  -65 

# Flip across y-axis
coo_flip_yaxis(bot$coo)
#> $brahma
#> <xy [138 x 2]>
#>       [,1] [,2]
#>  [1,] -37  561 
#>  [2,] -40  540 
#>  [3,] -40  529 
#>  [4,] -43  508 
#>  [5,] -46  487 
#>  [6,] ...  ... 
#>  [7,] -34  656 
#>  [8,] -33  645 
#>  [9,] -33  624 
#> [10,] -34  603 
#> [11,] -35  593 
#> 
#> $caney
#> <xy [168 x 2]>
#>       [,1] [,2]
#>  [1,] -53  535 
#>  [2,] -53  525 
#>  [3,] -54  505 
#>  [4,] -53  495 
#>  [5,] -54  485 
#>  [6,] ...  ... 
#>  [7,] -76  616 
#>  [8,] -67  596 
#>  [9,] -62  585 
#> [10,] -59  575 
#> [11,] -55  555 
#> 
#> $chimay
#> <xy [189 x 2]>
#>       [,1] [,2]
#>  [1,] -49  333 
#>  [2,] -49  325 
#>  [3,] -49  318 
#>  [4,] -50  310 
#>  [5,] -50  302 
#>  [6,] ...  ... 
#>  [7,] -59  379 
#>  [8,] -54  371 
#>  [9,] -51  364 
#> [10,] -49  356 
#> [11,] -48  348 
#> 
#> $corona
#> <xy [129 x 2]>
#>       [,1] [,2]
#>  [1,] -91  426 
#>  [2,] -91  416 
#>  [3,] -90  395 
#>  [4,] -91  385 
#>  [5,] -91  374 
#>  [6,] ...  ... 
#>  [7,] -118  506
#>  [8,] -110  486
#>  [9,] -105  477
#> [10,] -101  466
#> [11,]  -94  447
#> 
#> $deusventrue
#> <xy [152 x 2]>
#>       [,1] [,2]
#>  [1,] -74  481 
#>  [2,] -70  472 
#>  [3,] -62  454 
#>  [4,] -59  445 
#>  [5,] -52  425 
#>  [6,] ...  ... 
#>  [7,] -100  555
#>  [8,]  -97  545
#>  [9,]  -90  527
#> [10,]  -87  518
#> [11,]  -82  500
#> 
#> $duvel
#> <xy [161 x 2]>
#>       [,1] [,2]
#>  [1,] -61  315 
#>  [2,] -61  304 
#>  [3,] -61  293 
#>  [4,] -61  293 
#>  [5,] -61  282 
#>  [6,] ...  ... 
#>  [7,] -74  369 
#>  [8,] -69  358 
#>  [9,] -65  348 
#> [10,] -65  348 
#> [11,] -63  337 
#> 
#> $franziskaner
#> <xy [124 x 2]>
#>       [,1] [,2]
#>  [1,] -54  439 
#>  [2,] -54  418 
#>  [3,] -54  408 
#>  [4,] -54  389 
#>  [5,] -54  379 
#>  [6,] ...  ... 
#>  [7,] -60  532 
#>  [8,] -59  511 
#>  [9,] -57  501 
#> [10,] -54  480 
#> [11,] -54  470 
#> 
#> $grimbergen
#> <xy [126 x 2]>
#>       [,1] [,2]
#>  [1,] -42  404 
#>  [2,] -40  394 
#>  [3,] -40  373 
#>  [4,] -40  362 
#>  [5,] -40  352 
#>  [6,] ...  ... 
#>  [7,] -74  487 
#>  [8,] -60  467 
#>  [9,] -54  456 
#> [10,] -50  446 
#> [11,] -44  425 
#> 
#> $guiness
#> <xy [183 x 2]>
#>       [,1] [,2]
#>  [1,] -69  385 
#>  [2,] -69  377 
#>  [3,] -69  369 
#>  [4,] -69  360 
#>  [5,] -69  344 
#>  [6,] ...  ... 
#>  [7,] -73  442 
#>  [8,] -71  433 
#>  [9,] -67  418 
#> [10,] -68  410 
#> [11,] -69  401 
#> 
#> $hoegardeen
#> <xy [193 x 2]>
#>       [,1] [,2]
#>  [1,] -42  544 
#>  [2,] -40  531 
#>  [3,] -40  519 
#>  [4,] -40  506 
#>  [5,] -40  493 
#>  [6,] ...  ... 
#>  [7,] -58  619 
#>  [8,] -54  606 
#>  [9,] -51  594 
#> [10,] -47  581 
#> [11,] -46  568 
#> 
#> $jupiler
#> <xy [156 x 2]>
#>       [,1] [,2]
#>  [1,] -55  515 
#>  [2,] -54  501 
#>  [3,] -54  488 
#>  [4,] -54  474 
#>  [5,] -54  460 
#>  [6,] ...  ... 
#>  [7,] -74  597 
#>  [8,] -69  583 
#>  [9,] -66  570 
#> [10,] -62  556 
#> [11,] -59  542 
#> 
#> $kingfisher
#> <xy [182 x 2]>
#>       [,1] [,2]
#>  [1,] -71  384 
#>  [2,] -71  374 
#>  [3,] -71  365 
#>  [4,] -71  355 
#>  [5,] -71  345 
#>  [6,] ...  ... 
#>  [7,] -81  442 
#>  [8,] -78  433 
#>  [9,] -76  423 
#> [10,] -73  413 
#> [11,] -73  403 
#> 
#> $latrappe
#> <xy [136 x 2]>
#>       [,1] [,2]
#>  [1,] -26  389 
#>  [2,] -25  377 
#>  [3,] -25  364 
#>  [4,] -25  352 
#>  [5,] -25  339 
#>  [6,] ...  ... 
#>  [7,] -28  464 
#>  [8,] -25  451 
#>  [9,] -26  439 
#> [10,] -26  426 
#> [11,] -26  414 
#> 
#> $lindemanskriek
#> <xy [176 x 2]>
#>       [,1] [,2]
#>  [1,] -60  427 
#>  [2,] -60  419 
#>  [3,] -55  404 
#>  [4,] -54  395 
#>  [5,] -54  387 
#>  [6,] ...  ... 
#>  [7,] -77  486 
#>  [8,] -75  478 
#>  [9,] -72  469 
#> [10,] -70  461 
#> [11,] -65  444 
#> 
#> $nicechouffe
#> <xy [146 x 2]>
#>       [,1] [,2]
#>  [1,] -82  361 
#>  [2,] -81  353 
#>  [3,] -77  336 
#>  [4,] -77  327 
#>  [5,] -76  319 
#>  [6,] ...  ... 
#>  [7,] -96  418 
#>  [8,] -93  410 
#>  [9,] -91  401 
#> [10,] -89  394 
#> [11,] -85  378 
#> 
#> $pecheresse
#> <xy [129 x 2]>
#>       [,1] [,2]
#>  [1,] -63  495 
#>  [2,] -61  476 
#>  [3,] -61  467 
#>  [4,] -60  447 
#>  [5,] -58  428 
#>  [6,] ...  ... 
#>  [7,] -86  580 
#>  [8,] -83  570 
#>  [9,] -78  552 
#> [10,] -73  533 
#> [11,] -71  524 
#> 
#> $sierranevada
#> <xy [176 x 2]>
#>       [,1] [,2]
#>  [1,] -61  345 
#>  [2,] -61  333 
#>  [3,] -61  333 
#>  [4,] -61  320 
#>  [5,] -61  308 
#>  [6,] ...  ... 
#>  [7,] -63  407 
#>  [8,] -61  394 
#>  [9,] -59  382 
#> [10,] -61  370 
#> [11,] -61  370 
#> 
#> $tanglefoot
#> <xy [174 x 2]>
#>       [,1] [,2]
#>  [1,] -48  367 
#>  [2,] -48  359 
#>  [3,] -48  351 
#>  [4,] -48  335 
#>  [5,] -49  327 
#>  [6,] ...  ... 
#>  [7,] -52  423 
#>  [8,] -49  415 
#>  [9,] -48  407 
#> [10,] -47  391 
#> [11,] -47  383 
#> 
#> $tauro
#> <xy [174 x 2]>
#>       [,1] [,2]
#>  [1,] -56  515 
#>  [2,] -54  503 
#>  [3,] -54  491 
#>  [4,] -54  478 
#>  [5,] -54  466 
#>  [6,] ...  ... 
#>  [7,] -71  587 
#>  [8,] -68  575 
#>  [9,] -63  563 
#> [10,] -61  551 
#> [11,] -59  538 
#> 
#> $westmalle
#> <xy [141 x 2]>
#>       [,1] [,2]
#>  [1,] -70  394 
#>  [2,] -70  386 
#>  [3,] -67  369 
#>  [4,] -67  361 
#>  [5,] -66  344 
#>  [6,] ...  ... 
#>  [7,] -86  461 
#>  [8,] -83  452 
#>  [9,] -80  436 
#> [10,] -76  427 
#> [11,] -74  411 
#> 
#> $amrut
#> <xy [191 x 2]>
#>       [,1] [,2]
#>  [1,] -57  441 
#>  [2,] -57  431 
#>  [3,] -57  421 
#>  [4,] -57  411 
#>  [5,] -57  401 
#>  [6,] ...  ... 
#>  [7,] -55  501 
#>  [8,] -57  491 
#>  [9,] -57  481 
#> [10,] -57  471 
#> [11,] -57  461 
#> 
#> $ballantines
#> <xy [146 x 2]>
#>       [,1] [,2]
#>  [1,] -38  357 
#>  [2,] -38  341 
#>  [3,] -38  333 
#>  [4,] -38  318 
#>  [5,] -38  310 
#>  [6,] ...  ... 
#>  [7,] -38  428 
#>  [8,] -38  412 
#>  [9,] -38  404 
#> [10,] -38  388 
#> [11,] -38  381 
#> 
#> $bushmills
#> <xy [165 x 2]>
#>       [,1] [,2]
#>  [1,] -72  456 
#>  [2,] -72  441 
#>  [3,] -72  425 
#>  [4,] -72  425 
#>  [5,] -72  410 
#>  [6,] ...  ... 
#>  [7,] -70  533 
#>  [8,] -70  518 
#>  [9,] -70  502 
#> [10,] -70  502 
#> [11,] -70  487 
#> 
#> $chivas
#> <xy [164 x 2]>
#>       [,1] [,2]
#>  [1,] -33  437 
#>  [2,] -31  429 
#>  [3,] -29  412 
#>  [4,] -29  404 
#>  [5,] -29  388 
#>  [6,] ...  ... 
#>  [7,] -81  502 
#>  [8,] -73  495 
#>  [9,] -57  478 
#> [10,] -51  470 
#> [11,] -40  453 
#> 
#> $dalmore
#> <xy [155 x 2]>
#>       [,1] [,2]
#>  [1,] -52  371 
#>  [2,] -47  359 
#>  [3,] -44  346 
#>  [4,] -42  334 
#>  [5,] -42  322 
#>  [6,] ...  ... 
#>  [7,] -102  430
#>  [8,] -102  430
#>  [9,]  -89  419
#> [10,]  -77  408
#> [11,]  -67  396
#> 
#> $famousgrouse
#> <xy [169 x 2]>
#>       [,1] [,2]
#>  [1,] -99  313 
#>  [2,] -99  303 
#>  [3,] -99  294 
#>  [4,] -99  284 
#>  [5,] -99  284 
#>  [6,] ...  ... 
#>  [7,] -97  361 
#>  [8,] -97  351 
#>  [9,] -97  351 
#> [10,] -97  342 
#> [11,] -97  332 
#> 
#> $glendronach
#> <xy [197 x 2]>
#>       [,1] [,2]
#>  [1,] -73  435 
#>  [2,] -73  423 
#>  [3,] -74  411 
#>  [4,] -74  411 
#>  [5,] -74  399 
#>  [6,] ...  ... 
#>  [7,] -72  495 
#>  [8,] -72  483 
#>  [9,] -73  471 
#> [10,] -73  471 
#> [11,] -73  459 
#> 
#> $glenmorangie
#> <xy [179 x 2]>
#>       [,1] [,2]
#>  [1,] -53  518 
#>  [2,] -54  501 
#>  [3,] -54  501 
#>  [4,] -54  485 
#>  [5,] -55  468 
#>  [6,] ...  ... 
#>  [7,] -62  599 
#>  [8,] -58  584 
#>  [9,] -54  567 
#> [10,] -53  550 
#> [11,] -53  550 
#> 
#> $highlandpark
#> <xy [169 x 2]>
#>       [,1] [,2]
#>  [1,] -42  371 
#>  [2,] -42  357 
#>  [3,] -42  357 
#>  [4,] -42  343 
#>  [5,] -42  329 
#>  [6,] ...  ... 
#>  [7,] -41  441 
#>  [8,] -42  427 
#>  [9,] -42  413 
#> [10,] -42  399 
#> [11,] -42  399 
#> 
#> $jackdaniels
#> <xy [150 x 2]>
#>       [,1] [,2]
#>  [1,] -63  414 
#>  [2,] -63  401 
#>  [3,] -63  388 
#>  [4,] -63  375 
#>  [5,] -63  362 
#>  [6,] ...  ... 
#>  [7,] -70  493 
#>  [8,] -68  479 
#>  [9,] -65  466 
#> [10,] -64  453 
#> [11,] -65  440 
#> 
#> $jb
#> <xy [174 x 2]>
#>       [,1] [,2]
#>  [1,] -43  531 
#>  [2,] -43  520 
#>  [3,] -42  510 
#>  [4,] -42  488 
#>  [5,] -43  477 
#>  [6,] ...  ... 
#>  [7,] -42  606 
#>  [8,] -40  595 
#>  [9,] -42  585 
#> [10,] -43  563 
#> [11,] -43  552 
#> 
#> $johnniewalker
#> <xy [168 x 2]>
#>       [,1] [,2]
#>  [1,] -133  175
#>  [2,] -133  171
#>  [3,] -133  167
#>  [4,] -133  163
#>  [5,] -134  155
#>  [6,] ...  ... 
#>  [7,] -133  203
#>  [8,] -133  199
#>  [9,] -133  191
#> [10,] -133  187
#> [11,] -133  183
#> 
#> $magallan
#> <xy [141 x 2]>
#>       [,1] [,2]
#>  [1,] -78  397 
#>  [2,] -78  382 
#>  [3,] -80  375 
#>  [4,] -80  361 
#>  [5,] -81  346 
#>  [6,] ...  ... 
#>  [7,] -75  462 
#>  [8,] -75  455 
#>  [9,] -75  441 
#> [10,] -77  426 
#> [11,] -77  419 
#> 
#> $makersmark
#> <xy [177 x 2]>
#>       [,1] [,2]
#>  [1,] -31  432 
#>  [2,] -23  420 
#>  [3,] -16  408 
#>  [4,] -16  408 
#>  [5,] -13  394 
#>  [6,] ...  ... 
#>  [7,] -79  487 
#>  [8,] -74  473 
#>  [9,] -67  464 
#> [10,] -67  464 
#> [11,] -53  454 
#> 
#> $oban
#> <xy [179 x 2]>
#>       [,1] [,2]
#>  [1,] -74  457 
#>  [2,] -74  448 
#>  [3,] -74  431 
#>  [4,] -74  423 
#>  [5,] -74  414 
#>  [6,] ...  ... 
#>  [7,] -72  517 
#>  [8,] -73  508 
#>  [9,] -73  500 
#> [10,] -73  491 
#> [11,] -73  474 
#> 
#> $oldpotrero
#> <xy [131 x 2]>
#>       [,1] [,2]
#>  [1,] -83  307 
#>  [2,] -77  299 
#>  [3,] -71  291 
#>  [4,] -63  274 
#>  [5,] -60  265 
#>  [6,] ...  ... 
#>  [7,] -119  366
#>  [8,] -117  358
#>  [9,] -112  349
#> [10,] -101  333
#> [11,]  -95  324
#> 
#> $redbreast
#> <xy [177 x 2]>
#>       [,1] [,2]
#>  [1,] -105  233
#>  [2,] -103  228
#>  [3,] -101  224
#>  [4,]  -98  214
#>  [5,]  -98  210
#>  [6,] ...  ... 
#>  [7,] -137  261
#>  [8,] -132  257
#>  [9,] -127  253
#> [10,] -118  246
#> [11,] -113  242
#> 
#> $tamdhu
#> <xy [176 x 2]>
#>       [,1] [,2]
#>  [1,] -49  552 
#>  [2,] -49  540 
#>  [3,] -49  527 
#>  [4,] -49  515 
#>  [5,] -49  503 
#>  [6,] ...  ... 
#>  [7,] -46  625 
#>  [8,] -44  613 
#>  [9,] -45  601 
#> [10,] -46  589 
#> [11,] -47  577 
#> 
#> $wildturkey
#> <xy [185 x 2]>
#>       [,1] [,2]
#>  [1,] -18  569 
#>  [2,] -18  555 
#>  [3,] -18  541 
#>  [4,] -18  527 
#>  [5,] -18  513 
#>  [6,] ...  ... 
#>  [7,] -20  651 
#>  [8,] -18  638 
#>  [9,] -15  625 
#> [10,] -15  611 
#> [11,] -15  597 
#> 
#> $yoichi
#> <xy [123 x 2]>
#>       [,1] [,2]
#>  [1,] -69  384 
#>  [2,] -69  369 
#>  [3,] -69  355 
#>  [4,] -69  340 
#>  [5,] -69  325 
#>  [6,] ...  ... 
#>  [7,] -68  457 
#>  [8,] -68  450 
#>  [9,] -68  435 
#> [10,] -68  421 
#> [11,] -69  406 
#> 
#> attr(,"class")
#> [1] "out"  "coo"  "list"

# Flip across custom vertical line
coo_flip_x(shapes$cat, xintercept = 100)
#> <xy [120 x 2]>
#>       [,1] [,2]
#>  [1,]  0   62  
#>  [2,]  4   56  
#>  [3,]  0   56  
#>  [4,] -6   54  
#>  [5,] -9   48  
#>  [6,] ...  ... 
#>  [7,] -19   45 
#>  [8,] -13   47 
#>  [9,]  -8   53 
#> [10,]  -4   59 
#> [11,]  -2   65 

# Flip across custom horizontal line
coo_flip_y(bot, yintercept = 50)
#> # A tibble: 40 × 3
#>    coo       type   dummy
#>    <out>     <fct>  <fct>
#>  1 (138 x 2) whisky a    
#>  2 (168 x 2) whisky a    
#>  3 (189 x 2) whisky a    
#>  4 (129 x 2) whisky a    
#>  5 (152 x 2) whisky a    
#>  6 (161 x 2) whisky a    
#>  7 (124 x 2) whisky a    
#>  8 (126 x 2) whisky a    
#>  9 (183 x 2) whisky a    
#> 10 (193 x 2) whisky a    
#> # ℹ 30 more rows