Skip to contents

Multiply shape coordinates by a scaling factor.

Usage

coo_rescale(x, scale, ..., .cols = NULL, .ldk_col = NULL)

Arguments

x

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

scale

Numeric. Scaling factor to multiply coordinates by. If x is a tibble, can also be a column name (quoted or unquoted) containing scaling factors.

...

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.

.ldk_col

Character. Name of landmark column. If NULL, uses colname_ldk.

Value

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

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

  • If x is a tibble: returns the tibble with rescaled coo column(s)

Details

Multiplies all coordinates by a scaling factor. For tibbles, the scale factor can come from a column (useful for rescaling based on stored measurements).

This is pure multiplication - no centering or normalization.

Landmarks are synced.

See also

coo_scale() for normalizing to unit centroid size

Examples

# Double the size
coo_rescale(shapes$cat, scale = 2)
#> <xy [120 x 2]>
#>       [,1] [,2]
#>  [1,] 400  124 
#>  [2,] 392  112 
#>  [3,] 400  112 
#>  [4,] 412  108 
#>  [5,] 418   96 
#>  [6,] ...  ... 
#>  [7,] 438   90 
#>  [8,] 426   94 
#>  [9,] 416  106 
#> [10,] 408  118 
#> [11,] 404  130 

# Halve the size
coo_rescale(bot$coo, scale = 0.5)
#> $brahma
#> <xy [138 x 2]>
#>       [,1]  [,2] 
#>  [1,]  18.5 280.5
#>  [2,]  20.0 270.0
#>  [3,]  20.0 264.5
#>  [4,]  21.5 254.0
#>  [5,]  23.0 243.5
#>  [6,] ...   ...  
#>  [7,]  17.0 328.0
#>  [8,]  16.5 322.5
#>  [9,]  16.5 312.0
#> [10,]  17.0 301.5
#> [11,]  17.5 296.5
#> 
#> $caney
#> <xy [168 x 2]>
#>       [,1]  [,2] 
#>  [1,]  26.5 267.5
#>  [2,]  26.5 262.5
#>  [3,]  27.0 252.5
#>  [4,]  26.5 247.5
#>  [5,]  27.0 242.5
#>  [6,] ...   ...  
#>  [7,]  38.0 308.0
#>  [8,]  33.5 298.0
#>  [9,]  31.0 292.5
#> [10,]  29.5 287.5
#> [11,]  27.5 277.5
#> 
#> $chimay
#> <xy [189 x 2]>
#>       [,1]  [,2] 
#>  [1,]  24.5 166.5
#>  [2,]  24.5 162.5
#>  [3,]  24.5 159.0
#>  [4,]  25.0 155.0
#>  [5,]  25.0 151.0
#>  [6,] ...   ...  
#>  [7,]  29.5 189.5
#>  [8,]  27.0 185.5
#>  [9,]  25.5 182.0
#> [10,]  24.5 178.0
#> [11,]  24.0 174.0
#> 
#> $corona
#> <xy [129 x 2]>
#>       [,1]  [,2] 
#>  [1,]  45.5 213.0
#>  [2,]  45.5 208.0
#>  [3,]  45.0 197.5
#>  [4,]  45.5 192.5
#>  [5,]  45.5 187.0
#>  [6,] ...   ...  
#>  [7,]  59.0 253.0
#>  [8,]  55.0 243.0
#>  [9,]  52.5 238.5
#> [10,]  50.5 233.0
#> [11,]  47.0 223.5
#> 
#> $deusventrue
#> <xy [152 x 2]>
#>       [,1]  [,2] 
#>  [1,]  37.0 240.5
#>  [2,]  35.0 236.0
#>  [3,]  31.0 227.0
#>  [4,]  29.5 222.5
#>  [5,]  26.0 212.5
#>  [6,] ...   ...  
#>  [7,]  50.0 277.5
#>  [8,]  48.5 272.5
#>  [9,]  45.0 263.5
#> [10,]  43.5 259.0
#> [11,]  41.0 250.0
#> 
#> $duvel
#> <xy [161 x 2]>
#>       [,1]  [,2] 
#>  [1,]  30.5 157.5
#>  [2,]  30.5 152.0
#>  [3,]  30.5 146.5
#>  [4,]  30.5 146.5
#>  [5,]  30.5 141.0
#>  [6,] ...   ...  
#>  [7,]  37.0 184.5
#>  [8,]  34.5 179.0
#>  [9,]  32.5 174.0
#> [10,]  32.5 174.0
#> [11,]  31.5 168.5
#> 
#> $franziskaner
#> <xy [124 x 2]>
#>       [,1]  [,2] 
#>  [1,]  27.0 219.5
#>  [2,]  27.0 209.0
#>  [3,]  27.0 204.0
#>  [4,]  27.0 194.5
#>  [5,]  27.0 189.5
#>  [6,] ...   ...  
#>  [7,]  30.0 266.0
#>  [8,]  29.5 255.5
#>  [9,]  28.5 250.5
#> [10,]  27.0 240.0
#> [11,]  27.0 235.0
#> 
#> $grimbergen
#> <xy [126 x 2]>
#>       [,1]  [,2] 
#>  [1,]  21.0 202.0
#>  [2,]  20.0 197.0
#>  [3,]  20.0 186.5
#>  [4,]  20.0 181.0
#>  [5,]  20.0 176.0
#>  [6,] ...   ...  
#>  [7,]  37.0 243.5
#>  [8,]  30.0 233.5
#>  [9,]  27.0 228.0
#> [10,]  25.0 223.0
#> [11,]  22.0 212.5
#> 
#> $guiness
#> <xy [183 x 2]>
#>       [,1]  [,2] 
#>  [1,]  34.5 192.5
#>  [2,]  34.5 188.5
#>  [3,]  34.5 184.5
#>  [4,]  34.5 180.0
#>  [5,]  34.5 172.0
#>  [6,] ...   ...  
#>  [7,]  36.5 221.0
#>  [8,]  35.5 216.5
#>  [9,]  33.5 209.0
#> [10,]  34.0 205.0
#> [11,]  34.5 200.5
#> 
#> $hoegardeen
#> <xy [193 x 2]>
#>       [,1]  [,2] 
#>  [1,]  21.0 272.0
#>  [2,]  20.0 265.5
#>  [3,]  20.0 259.5
#>  [4,]  20.0 253.0
#>  [5,]  20.0 246.5
#>  [6,] ...   ...  
#>  [7,]  29.0 309.5
#>  [8,]  27.0 303.0
#>  [9,]  25.5 297.0
#> [10,]  23.5 290.5
#> [11,]  23.0 284.0
#> 
#> $jupiler
#> <xy [156 x 2]>
#>       [,1]  [,2] 
#>  [1,]  27.5 257.5
#>  [2,]  27.0 250.5
#>  [3,]  27.0 244.0
#>  [4,]  27.0 237.0
#>  [5,]  27.0 230.0
#>  [6,] ...   ...  
#>  [7,]  37.0 298.5
#>  [8,]  34.5 291.5
#>  [9,]  33.0 285.0
#> [10,]  31.0 278.0
#> [11,]  29.5 271.0
#> 
#> $kingfisher
#> <xy [182 x 2]>
#>       [,1]  [,2] 
#>  [1,]  35.5 192.0
#>  [2,]  35.5 187.0
#>  [3,]  35.5 182.5
#>  [4,]  35.5 177.5
#>  [5,]  35.5 172.5
#>  [6,] ...   ...  
#>  [7,]  40.5 221.0
#>  [8,]  39.0 216.5
#>  [9,]  38.0 211.5
#> [10,]  36.5 206.5
#> [11,]  36.5 201.5
#> 
#> $latrappe
#> <xy [136 x 2]>
#>       [,1]  [,2] 
#>  [1,]  13.0 194.5
#>  [2,]  12.5 188.5
#>  [3,]  12.5 182.0
#>  [4,]  12.5 176.0
#>  [5,]  12.5 169.5
#>  [6,] ...   ...  
#>  [7,]  14.0 232.0
#>  [8,]  12.5 225.5
#>  [9,]  13.0 219.5
#> [10,]  13.0 213.0
#> [11,]  13.0 207.0
#> 
#> $lindemanskriek
#> <xy [176 x 2]>
#>       [,1]  [,2] 
#>  [1,]  30.0 213.5
#>  [2,]  30.0 209.5
#>  [3,]  27.5 202.0
#>  [4,]  27.0 197.5
#>  [5,]  27.0 193.5
#>  [6,] ...   ...  
#>  [7,]  38.5 243.0
#>  [8,]  37.5 239.0
#>  [9,]  36.0 234.5
#> [10,]  35.0 230.5
#> [11,]  32.5 222.0
#> 
#> $nicechouffe
#> <xy [146 x 2]>
#>       [,1]  [,2] 
#>  [1,]  41.0 180.5
#>  [2,]  40.5 176.5
#>  [3,]  38.5 168.0
#>  [4,]  38.5 163.5
#>  [5,]  38.0 159.5
#>  [6,] ...   ...  
#>  [7,]  48.0 209.0
#>  [8,]  46.5 205.0
#>  [9,]  45.5 200.5
#> [10,]  44.5 197.0
#> [11,]  42.5 189.0
#> 
#> $pecheresse
#> <xy [129 x 2]>
#>       [,1]  [,2] 
#>  [1,]  31.5 247.5
#>  [2,]  30.5 238.0
#>  [3,]  30.5 233.5
#>  [4,]  30.0 223.5
#>  [5,]  29.0 214.0
#>  [6,] ...   ...  
#>  [7,]  43.0 290.0
#>  [8,]  41.5 285.0
#>  [9,]  39.0 276.0
#> [10,]  36.5 266.5
#> [11,]  35.5 262.0
#> 
#> $sierranevada
#> <xy [176 x 2]>
#>       [,1]  [,2] 
#>  [1,]  30.5 172.5
#>  [2,]  30.5 166.5
#>  [3,]  30.5 166.5
#>  [4,]  30.5 160.0
#>  [5,]  30.5 154.0
#>  [6,] ...   ...  
#>  [7,]  31.5 203.5
#>  [8,]  30.5 197.0
#>  [9,]  29.5 191.0
#> [10,]  30.5 185.0
#> [11,]  30.5 185.0
#> 
#> $tanglefoot
#> <xy [174 x 2]>
#>       [,1]  [,2] 
#>  [1,]  24.0 183.5
#>  [2,]  24.0 179.5
#>  [3,]  24.0 175.5
#>  [4,]  24.0 167.5
#>  [5,]  24.5 163.5
#>  [6,] ...   ...  
#>  [7,]  26.0 211.5
#>  [8,]  24.5 207.5
#>  [9,]  24.0 203.5
#> [10,]  23.5 195.5
#> [11,]  23.5 191.5
#> 
#> $tauro
#> <xy [174 x 2]>
#>       [,1]  [,2] 
#>  [1,]  28.0 257.5
#>  [2,]  27.0 251.5
#>  [3,]  27.0 245.5
#>  [4,]  27.0 239.0
#>  [5,]  27.0 233.0
#>  [6,] ...   ...  
#>  [7,]  35.5 293.5
#>  [8,]  34.0 287.5
#>  [9,]  31.5 281.5
#> [10,]  30.5 275.5
#> [11,]  29.5 269.0
#> 
#> $westmalle
#> <xy [141 x 2]>
#>       [,1]  [,2] 
#>  [1,]  35.0 197.0
#>  [2,]  35.0 193.0
#>  [3,]  33.5 184.5
#>  [4,]  33.5 180.5
#>  [5,]  33.0 172.0
#>  [6,] ...   ...  
#>  [7,]  43.0 230.5
#>  [8,]  41.5 226.0
#>  [9,]  40.0 218.0
#> [10,]  38.0 213.5
#> [11,]  37.0 205.5
#> 
#> $amrut
#> <xy [191 x 2]>
#>       [,1]  [,2] 
#>  [1,]  28.5 220.5
#>  [2,]  28.5 215.5
#>  [3,]  28.5 210.5
#>  [4,]  28.5 205.5
#>  [5,]  28.5 200.5
#>  [6,] ...   ...  
#>  [7,]  27.5 250.5
#>  [8,]  28.5 245.5
#>  [9,]  28.5 240.5
#> [10,]  28.5 235.5
#> [11,]  28.5 230.5
#> 
#> $ballantines
#> <xy [146 x 2]>
#>       [,1]  [,2] 
#>  [1,]  19.0 178.5
#>  [2,]  19.0 170.5
#>  [3,]  19.0 166.5
#>  [4,]  19.0 159.0
#>  [5,]  19.0 155.0
#>  [6,] ...   ...  
#>  [7,]  19.0 214.0
#>  [8,]  19.0 206.0
#>  [9,]  19.0 202.0
#> [10,]  19.0 194.0
#> [11,]  19.0 190.5
#> 
#> $bushmills
#> <xy [165 x 2]>
#>       [,1]  [,2] 
#>  [1,]  36.0 228.0
#>  [2,]  36.0 220.5
#>  [3,]  36.0 212.5
#>  [4,]  36.0 212.5
#>  [5,]  36.0 205.0
#>  [6,] ...   ...  
#>  [7,]  35.0 266.5
#>  [8,]  35.0 259.0
#>  [9,]  35.0 251.0
#> [10,]  35.0 251.0
#> [11,]  35.0 243.5
#> 
#> $chivas
#> <xy [164 x 2]>
#>       [,1]  [,2] 
#>  [1,]  16.5 218.5
#>  [2,]  15.5 214.5
#>  [3,]  14.5 206.0
#>  [4,]  14.5 202.0
#>  [5,]  14.5 194.0
#>  [6,] ...   ...  
#>  [7,]  40.5 251.0
#>  [8,]  36.5 247.5
#>  [9,]  28.5 239.0
#> [10,]  25.5 235.0
#> [11,]  20.0 226.5
#> 
#> $dalmore
#> <xy [155 x 2]>
#>       [,1]  [,2] 
#>  [1,]  26.0 185.5
#>  [2,]  23.5 179.5
#>  [3,]  22.0 173.0
#>  [4,]  21.0 167.0
#>  [5,]  21.0 161.0
#>  [6,] ...   ...  
#>  [7,]  51.0 215.0
#>  [8,]  51.0 215.0
#>  [9,]  44.5 209.5
#> [10,]  38.5 204.0
#> [11,]  33.5 198.0
#> 
#> $famousgrouse
#> <xy [169 x 2]>
#>       [,1]  [,2] 
#>  [1,]  49.5 156.5
#>  [2,]  49.5 151.5
#>  [3,]  49.5 147.0
#>  [4,]  49.5 142.0
#>  [5,]  49.5 142.0
#>  [6,] ...   ...  
#>  [7,]  48.5 180.5
#>  [8,]  48.5 175.5
#>  [9,]  48.5 175.5
#> [10,]  48.5 171.0
#> [11,]  48.5 166.0
#> 
#> $glendronach
#> <xy [197 x 2]>
#>       [,1]  [,2] 
#>  [1,]  36.5 217.5
#>  [2,]  36.5 211.5
#>  [3,]  37.0 205.5
#>  [4,]  37.0 205.5
#>  [5,]  37.0 199.5
#>  [6,] ...   ...  
#>  [7,]  36.0 247.5
#>  [8,]  36.0 241.5
#>  [9,]  36.5 235.5
#> [10,]  36.5 235.5
#> [11,]  36.5 229.5
#> 
#> $glenmorangie
#> <xy [179 x 2]>
#>       [,1]  [,2] 
#>  [1,]  26.5 259.0
#>  [2,]  27.0 250.5
#>  [3,]  27.0 250.5
#>  [4,]  27.0 242.5
#>  [5,]  27.5 234.0
#>  [6,] ...   ...  
#>  [7,]  31.0 299.5
#>  [8,]  29.0 292.0
#>  [9,]  27.0 283.5
#> [10,]  26.5 275.0
#> [11,]  26.5 275.0
#> 
#> $highlandpark
#> <xy [169 x 2]>
#>       [,1]  [,2] 
#>  [1,]  21.0 185.5
#>  [2,]  21.0 178.5
#>  [3,]  21.0 178.5
#>  [4,]  21.0 171.5
#>  [5,]  21.0 164.5
#>  [6,] ...   ...  
#>  [7,]  20.5 220.5
#>  [8,]  21.0 213.5
#>  [9,]  21.0 206.5
#> [10,]  21.0 199.5
#> [11,]  21.0 199.5
#> 
#> $jackdaniels
#> <xy [150 x 2]>
#>       [,1]  [,2] 
#>  [1,]  31.5 207.0
#>  [2,]  31.5 200.5
#>  [3,]  31.5 194.0
#>  [4,]  31.5 187.5
#>  [5,]  31.5 181.0
#>  [6,] ...   ...  
#>  [7,]  35.0 246.5
#>  [8,]  34.0 239.5
#>  [9,]  32.5 233.0
#> [10,]  32.0 226.5
#> [11,]  32.5 220.0
#> 
#> $jb
#> <xy [174 x 2]>
#>       [,1]  [,2] 
#>  [1,]  21.5 265.5
#>  [2,]  21.5 260.0
#>  [3,]  21.0 255.0
#>  [4,]  21.0 244.0
#>  [5,]  21.5 238.5
#>  [6,] ...   ...  
#>  [7,]  21.0 303.0
#>  [8,]  20.0 297.5
#>  [9,]  21.0 292.5
#> [10,]  21.5 281.5
#> [11,]  21.5 276.0
#> 
#> $johnniewalker
#> <xy [168 x 2]>
#>       [,1]  [,2] 
#>  [1,] 66.5  87.5 
#>  [2,] 66.5  85.5 
#>  [3,] 66.5  83.5 
#>  [4,] 66.5  81.5 
#>  [5,] 67.0  77.5 
#>  [6,] ...   ...  
#>  [7,]  66.5 101.5
#>  [8,]  66.5  99.5
#>  [9,]  66.5  95.5
#> [10,]  66.5  93.5
#> [11,]  66.5  91.5
#> 
#> $magallan
#> <xy [141 x 2]>
#>       [,1]  [,2] 
#>  [1,]  39.0 198.5
#>  [2,]  39.0 191.0
#>  [3,]  40.0 187.5
#>  [4,]  40.0 180.5
#>  [5,]  40.5 173.0
#>  [6,] ...   ...  
#>  [7,]  37.5 231.0
#>  [8,]  37.5 227.5
#>  [9,]  37.5 220.5
#> [10,]  38.5 213.0
#> [11,]  38.5 209.5
#> 
#> $makersmark
#> <xy [177 x 2]>
#>       [,1]  [,2] 
#>  [1,]  15.5 216.0
#>  [2,]  11.5 210.0
#>  [3,]   8.0 204.0
#>  [4,]   8.0 204.0
#>  [5,]   6.5 197.0
#>  [6,] ...   ...  
#>  [7,]  39.5 243.5
#>  [8,]  37.0 236.5
#>  [9,]  33.5 232.0
#> [10,]  33.5 232.0
#> [11,]  26.5 227.0
#> 
#> $oban
#> <xy [179 x 2]>
#>       [,1]  [,2] 
#>  [1,]  37.0 228.5
#>  [2,]  37.0 224.0
#>  [3,]  37.0 215.5
#>  [4,]  37.0 211.5
#>  [5,]  37.0 207.0
#>  [6,] ...   ...  
#>  [7,]  36.0 258.5
#>  [8,]  36.5 254.0
#>  [9,]  36.5 250.0
#> [10,]  36.5 245.5
#> [11,]  36.5 237.0
#> 
#> $oldpotrero
#> <xy [131 x 2]>
#>       [,1]  [,2] 
#>  [1,]  41.5 153.5
#>  [2,]  38.5 149.5
#>  [3,]  35.5 145.5
#>  [4,]  31.5 137.0
#>  [5,]  30.0 132.5
#>  [6,] ...   ...  
#>  [7,]  59.5 183.0
#>  [8,]  58.5 179.0
#>  [9,]  56.0 174.5
#> [10,]  50.5 166.5
#> [11,]  47.5 162.0
#> 
#> $redbreast
#> <xy [177 x 2]>
#>       [,1]  [,2] 
#>  [1,]  52.5 116.5
#>  [2,]  51.5 114.0
#>  [3,]  50.5 112.0
#>  [4,]  49.0 107.0
#>  [5,]  49.0 105.0
#>  [6,] ...   ...  
#>  [7,]  68.5 130.5
#>  [8,]  66.0 128.5
#>  [9,]  63.5 126.5
#> [10,]  59.0 123.0
#> [11,]  56.5 121.0
#> 
#> $tamdhu
#> <xy [176 x 2]>
#>       [,1]  [,2] 
#>  [1,]  24.5 276.0
#>  [2,]  24.5 270.0
#>  [3,]  24.5 263.5
#>  [4,]  24.5 257.5
#>  [5,]  24.5 251.5
#>  [6,] ...   ...  
#>  [7,]  23.0 312.5
#>  [8,]  22.0 306.5
#>  [9,]  22.5 300.5
#> [10,]  23.0 294.5
#> [11,]  23.5 288.5
#> 
#> $wildturkey
#> <xy [185 x 2]>
#>       [,1]  [,2] 
#>  [1,]   9.0 284.5
#>  [2,]   9.0 277.5
#>  [3,]   9.0 270.5
#>  [4,]   9.0 263.5
#>  [5,]   9.0 256.5
#>  [6,] ...   ...  
#>  [7,]  10.0 325.5
#>  [8,]   9.0 319.0
#>  [9,]   7.5 312.5
#> [10,]   7.5 305.5
#> [11,]   7.5 298.5
#> 
#> $yoichi
#> <xy [123 x 2]>
#>       [,1]  [,2] 
#>  [1,]  34.5 192.0
#>  [2,]  34.5 184.5
#>  [3,]  34.5 177.5
#>  [4,]  34.5 170.0
#>  [5,]  34.5 162.5
#>  [6,] ...   ...  
#>  [7,]  34.0 228.5
#>  [8,]  34.0 225.0
#>  [9,]  34.0 217.5
#> [10,]  34.0 210.5
#> [11,]  34.5 203.0
#> 
#> attr(,"class")
#> [1] "out"  "coo"  "list"

# For tibbles - use stored scaling factors
bot$scale_factor <- rep(c(1, 2), length.out = nrow(bot))
bot %>% coo_rescale(scale = scale_factor)
#> # A tibble: 40 × 6
#>    id           coo       type   fake  price scale_factor
#>    <chr>        <out>     <fct>  <fct> <dbl>        <dbl>
#>  1 brahma       (138 x 2) whisky a       3              1
#>  2 caney        (168 x 2) whisky a       1.2            2
#>  3 chimay       (189 x 2) whisky a       3.8            1
#>  4 corona       (129 x 2) whisky a       2.6            2
#>  5 deusventrue  (152 x 2) whisky a       1.1            1
#>  6 duvel        (161 x 2) whisky a       3.1            2
#>  7 franziskaner (124 x 2) whisky a       2.6            1
#>  8 grimbergen   (126 x 2) whisky a       2.9            2
#>  9 guiness      (183 x 2) whisky a       1.2            1
#> 10 hoegardeen   (193 x 2) whisky a       3.6            2
#> # ℹ 30 more rows