Site icon R-bloggers

Tutorial – Design Study in Solidworks with Data Analysis in R

[This article was first published on [R]eliability, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
  • I decided to do something a little bit different with this post and show how R can be used in tandem with a traditional engineering CAD program. Together they comprise a streamlined and repeatable workflow that I’ve tried to leverage on my job when it makes sense to do so.

    Solidworks is a 3d CAD program that is used commonly in industry. One powerful feature that I don’t see used that much is the Design Study module. This module allows the user to quickly vary the parameters of a solid model over a grid of specified values and measure one or more outputs of interest. Advanced users can quickly iterate geometries and perform FEA or optimize for mass or thermal properties. In this use case, we want to measure a geometrical feature of interest: the perimeter at a specific angle and location in a mock vessel.

    Motivation: Real arteries can take very abrupt turns that span a large angulation with a small radius of curvature. Some implantable devices cannot follow the curve perfectly and may therefore stabilize in a configuration that is not perfectly coaxial with the vessel. If the implant has important design features at specific positions (i.e. anchoring barbs, sealing rings, fixation zones, etc) then the device may not perform as intended. It is therefore important to understand the perimeter of the vessel on the cross sectional plane at which the implant may lie, not just orthogonal to the centerline. This perimeter can be very difficult to calculate analytically but a Solidworks Design Study can provide measurement data across a range of input values and the output function can be mapped similar to a Monte Carlo study (or more appropriately, a grid approximation method). The measurement of interest is shown below in green for 2 different angulations (45, 60 degrees) and two different inner radii of curvature (5 and 19 mm). The measurement plane is set to 15 degrees off orthogonal which assumes our implantable device can bend a little bit (15 deg) but not fully conform. We see that for these two scenarios, the perimeter (green trace) changes from 62.9 mm to 67.8 mm which is enough to be relevant with respect to implant sizing and performance.

    If you have no interest in the Solidworks portion then please skip down to the R portion, and visa versa.

    Libraries

    library(tidyverse)
    library(readxl)
    library(here)
    library(gt)
    library(rayshader)
    library(knitr)
    library(av)

    Solidworks Design Study

    Creating the Solid Model

    Sketch the Sweep Path that will Define Vessel Shape

    The first order of business is setting up a parameterized sketch. This allows us to change variables of interest without the whole structure breaking down. A convenient way to form a mock vessel is to sweep a profile (cross section) along a path. In this first sketch the sweep path is defined on the front plane and global variables are established that allow us to vary the angulation and the inner radius of curvature. Global variables are set up from the Tools -> Equations tabs. The controlling geometry should be on the inner curve, with the vessel centerline and greater curve constrained using offsets to the inner curve.

    Sketch the Sweep Profile that will Define Vessel Diameter

    On the top plane, sketch a circle and offset it about 1 mm. The center of the circle should be the point the represents the centerline of the sweep path from the front view. The circle should be coincident with the point that represents the inner curve of the sweep path.

    Sweep the Circular Profile along the Path From Sketch 1

    Create a sweep feature using the sketch profile and path previously defined. Check the box for “merge tangent faces”.

    Add Reference Geometry Planes

    Insert two planes using the “Reference Geometry” tab. Place the first on the same plane as we drew the sketch profile (this is just for convenience, you can use the face of the sketch profile if preferred). Place the second at the desired cutting measurement distance relative to the bend takeoff (in our case, 10 mm after the start of the bend). Assigning a variable to the vertical straight section and using an equation to position the reference plane 10 mm below that would be a good technique.

    Add Reference Axis for Cutting Plane

    Sketch a line on the 2nd reference plane orthogonal to the plane of the curves vessel centerline. This line will serve as an axis for the tilted cutting plane which will “slice” the vessel at 15 degrees relative to the reference planes.

    Add Angled Cutting Plane

    Create the cutting plane using the “Reference Geometry” tab. Define the plane using a first reference of the offset plane from 2 steps ago with a 15 degree designated angle. For the 2nd reference, use the the reference axis created in the previous step.

    Sketch Cutting Circle on Angled Cutting Plane

    Open a new sketch on the cutting plane. Sketch a large circle of arbitrary diameter – it just has to be sufficiently large to cut through any angulated vessel geometry below it when used as an extruded cut feature.

    Extuded Cut from Angled Plane

    Use the circle sketch from the previous step to create an extruded cut feature and specify “through all” as the end condition so it removes all geometry below it regardless of angulation.

    Set Up Design Study by Adding Variables

    Create a new Design Study by going to Insert -> Design Study -> Add. A new tab will open in the lower left with a Design Study interface and 3 sub-tabs with different views of the study. In Variable View tab, add new variables by clicking the drop down shown in Arrow 1. Enter names for the variables of interest as shown in Arrow 2 and specify that the variables are global variables (Arrow 3). Select the appropriate pre-existing variable at Arrow 4.

    Set Ranges for Variables of Interest

    Back in the Variable View tab, use the dropdown to select “Range with Steps” and then specify the desired range and step increment (I did 10 to 18 degrees of angulation by 5 and 5 to 30 mm vessel inner radius of curvature in steps of 1).

    Add Measurement Sensor

    In the “Constraints” section of the Variable View tab, add a sensor using the dropdown. Choose “Measurement” as the sensor type and select the inner perimeter of the mock vessel at the cut section as the edge to measure. After selecting the edge, be sure to click on the icon that looks like a line plot called “Add Sensor” in the “Measure” pop-up. Back in the Variable View Tab, use the drop down to select the newly created sensor (it will be called “Measurement1” or similar) and specify that the sensor will be used to monitor only.

    Design Study at Work

    On the Table View tab, click “Run”. You will get a warning about many iterations and then the study will start, with new realizations of the model displayed for each permutation in the table. Verify that the Measurement1 sensor field is being populated as the study progresses. When complete, click the disk icon to save the output as a .csv on your path of choice.

    Congrats! This concludes the Solidworks portion of this vignette.

    R Analyis and Visualization

    CSV Output from Design Study

    Take a look at how the Design Study sent the data to the .csv. It looks very similar to what was displayed in the Solidworks Design Study field with each Scenario as a column and the variables as rows. This is the exact opposite of what we want for a tidy data format. There are also some columns that won’t be useful (Format, Unit) and a couple of header lines that will need to be removed during the file import to R.

    Load Data

    Bring the data into R using read_csv with skip = 2 to omit those top rows that don’t contain useful information.

    data_raw_tbl <- read_csv(here("tilt_vessel_output_02apr2021.csv"), skip = 2)
    
    data_raw_tbl %>%
      gt_preview()
    Parameter Constraint or Goal Format Unit Initial Value Scenario 1 Scenario 2 Scenario 3 Scenario 4 Scenario 5 Scenario 6 Scenario 7 Scenario 8 Scenario 9 Scenario 10 Scenario 11 Scenario 12 Scenario 13 Scenario 14 Scenario 15 Scenario 16 Scenario 17 Scenario 18 Scenario 19 Scenario 20 Scenario 21 Scenario 22 Scenario 23 Scenario 24 Scenario 25 Scenario 26 Scenario 27 Scenario 28 Scenario 29 Scenario 30 Scenario 31 Scenario 32 Scenario 33 Scenario 34 Scenario 35 Scenario 36 Scenario 37 Scenario 38 Scenario 39 Scenario 40 Scenario 41 Scenario 42 Scenario 43 Scenario 44 Scenario 45 Scenario 46 Scenario 47 Scenario 48 Scenario 49 Scenario 50 Scenario 51 Scenario 52 Scenario 53 Scenario 54 Scenario 55 Scenario 56 Scenario 57 Scenario 58 Scenario 59 Scenario 60 Scenario 61 Scenario 62 Scenario 63 Scenario 64 Scenario 65 Scenario 66 Scenario 67 Scenario 68 Scenario 69 Scenario 70 Scenario 71 Scenario 72 Scenario 73 Scenario 74 Scenario 75 Scenario 76 Scenario 77 Scenario 78 Scenario 79 Scenario 80 Scenario 81 Scenario 82 Scenario 83 Scenario 84 Scenario 85 Scenario 86 Scenario 87 Scenario 88 Scenario 89 Scenario 90 Scenario 91 Scenario 92 Scenario 93 Scenario 94 Scenario 95 Scenario 96 Scenario 97 Scenario 98 Scenario 99 Scenario 100 Scenario 101 Scenario 102 Scenario 103 Scenario 104 Scenario 105 Scenario 106 Scenario 107 Scenario 108 Scenario 109 Scenario 110 Scenario 111 Scenario 112 Scenario 113 Scenario 114 Scenario 115 Scenario 116 Scenario 117 Scenario 118 Scenario 119 Scenario 120 Scenario 121 Scenario 122 Scenario 123 Scenario 124 Scenario 125 Scenario 126 Scenario 127 Scenario 128 Scenario 129 Scenario 130 Scenario 131 Scenario 132 Scenario 133 Scenario 134 Scenario 135 Scenario 136 Scenario 137 Scenario 138 Scenario 139 Scenario 140 Scenario 141 Scenario 142 Scenario 143 Scenario 144 Scenario 145 Scenario 146 Scenario 147 Scenario 148 Scenario 149 Scenario 150 Scenario 151 Scenario 152 Scenario 153 Scenario 154 Scenario 155 Scenario 156 Scenario 157 Scenario 158 Scenario 159 Scenario 160 Scenario 161 Scenario 162 Scenario 163 Scenario 164 Scenario 165 Scenario 166 Scenario 167 Scenario 168 Scenario 169 Scenario 170 Scenario 171 Scenario 172 Scenario 173 Scenario 174 Scenario 175 Scenario 176 Scenario 177 Scenario 178 Scenario 179 Scenario 180 Scenario 181 Scenario 182 Scenario 183 Scenario 184 Scenario 185 Scenario 186 Scenario 187 Scenario 188 Scenario 189 Scenario 190 Scenario 191 Scenario 192 Scenario 193 Scenario 194 Scenario 195 Scenario 196 Scenario 197 Scenario 198 Scenario 199 Scenario 200 Scenario 201 Scenario 202 Scenario 203 Scenario 204 Scenario 205 Scenario 206 Scenario 207 Scenario 208 Scenario 209 Scenario 210 Scenario 211 Scenario 212 Scenario 213 Scenario 214 Scenario 215 Scenario 216 Scenario 217 Scenario 218 Scenario 219 Scenario 220 Scenario 221 Scenario 222 Scenario 223 Scenario 224 Scenario 225 Scenario 226 Scenario 227 Scenario 228 Scenario 229 Scenario 230 Scenario 231 Scenario 232 Scenario 233 Scenario 234 Scenario 235 Scenario 236 Scenario 237 Scenario 238 Scenario 239 Scenario 240 Scenario 241 Scenario 242 Scenario 243 Scenario 244 Scenario 245 Scenario 246 Scenario 247 Scenario 248 Scenario 249 Scenario 250 Scenario 251 Scenario 252 Scenario 253 Scenario 254 Scenario 255 Scenario 256 Scenario 257 Scenario 258 Scenario 259 Scenario 260 Scenario 261 Scenario 262 Scenario 263 Scenario 264 Scenario 265 Scenario 266 Scenario 267 Scenario 268 Scenario 269 Scenario 270 Scenario 271 Scenario 272 Scenario 273 Scenario 274 Scenario 275 Scenario 276 Scenario 277 Scenario 278 Scenario 279 Scenario 280 Scenario 281 Scenario 282 Scenario 283 Scenario 284 Scenario 285 Scenario 286 Scenario 287 Scenario 288 Scenario 289 Scenario 290 Scenario 291 Scenario 292 Scenario 293 Scenario 294 Scenario 295 Scenario 296 Scenario 297 Scenario 298 Scenario 299 Scenario 300 Scenario 301 Scenario 302 Scenario 303 Scenario 304 Scenario 305 Scenario 306 Scenario 307 Scenario 308 Scenario 309 Scenario 310 Scenario 311 Scenario 312 Scenario 313 Scenario 314 Scenario 315 Scenario 316 Scenario 317 Scenario 318 Scenario 319 Scenario 320 Scenario 321 Scenario 322 Scenario 323 Scenario 324 Scenario 325 Scenario 326 Scenario 327 Scenario 328 Scenario 329 Scenario 330 Scenario 331 Scenario 332 Scenario 333 Scenario 334 Scenario 335 Scenario 336 Scenario 337 Scenario 338 Scenario 339 Scenario 340 Scenario 341 Scenario 342 Scenario 343 Scenario 344 Scenario 345 Scenario 346 Scenario 347 Scenario 348 Scenario 349 Scenario 350 Scenario 351 Scenario 352 Scenario 353 Scenario 354 Scenario 355 Scenario 356 Scenario 357 Scenario 358 Scenario 359 Scenario 360 Scenario 361 Scenario 362 Scenario 363 Scenario 364 Scenario 365 Scenario 366 Scenario 367 Scenario 368 Scenario 369 Scenario 370 Scenario 371 Scenario 372 Scenario 373 Scenario 374 Scenario 375 Scenario 376 Scenario 377 Scenario 378 Scenario 379 Scenario 380 Scenario 381 Scenario 382 Scenario 383 Scenario 384 Scenario 385 Scenario 386 Scenario 387 Scenario 388 Scenario 389 Scenario 390
    1 NA NA NA NA Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated Calculated
    2 vessel_angulation NA N/A 40.00000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000 10.000000 15.000000 20.000000 25.000000 30.000000 35.000000 40.000000 45.000000 50.000000 55.000000 60.000000 65.000000 70.000000 75.000000 80.000000
    3 vessel_roc NA N/A 16.00000 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 6.000000 6.000000 6.000000 6.000000 6.000000 6.000000 6.000000 6.000000 6.000000 6.000000 6.000000 6.000000 6.000000 6.000000 6.000000 7.000000 7.000000 7.000000 7.000000 7.000000 7.000000 7.000000 7.000000 7.000000 7.000000 7.000000 7.000000 7.000000 7.000000 7.000000 8.000000 8.000000 8.000000 8.000000 8.000000 8.000000 8.000000 8.000000 8.000000 8.000000 8.000000 8.000000 8.000000 8.000000 8.000000 9.000000 9.000000 9.000000 9.000000 9.000000 9.000000 9.000000 9.000000 9.000000 9.000000 9.000000 9.000000 9.000000 9.000000 9.000000 10.000000 10.000000 10.000000 10.000000 10.000000 10.000000 10.000000 10.000000 10.000000 10.000000 10.000000 10.000000 10.000000 10.000000 10.000000 11.000000 11.000000 11.000000 11.000000 11.000000 11.000000 11.000000 11.000000 11.000000 11.000000 11.000000 11.000000 11.000000 11.000000 11.000000 12.000000 12.000000 12.000000 12.000000 12.000000 12.000000 12.000000 12.000000 12.000000 12.000000 12.000000 12.000000 12.000000 12.000000 12.000000 13.000000 13.000000 13.000000 13.000000 13.000000 13.000000 13.000000 13.000000 13.000000 13.000000 13.000000 13.000000 13.000000 13.000000 13.000000 14.000000 14.000000 14.000000 14.000000 14.000000 14.000000 14.000000 14.000000 14.000000 14.000000 14.000000 14.000000 14.000000 14.000000 14.000000 15.000000 15.000000 15.000000 15.000000 15.000000 15.000000 15.000000 15.000000 15.000000 15.000000 15.000000 15.000000 15.000000 15.000000 15.000000 16.000000 16.000000 16.000000 16.000000 16.000000 16.000000 16.000000 16.000000 16.000000 16.000000 16.000000 16.000000 16.000000 16.000000 16.000000 17.000000 17.000000 17.000000 17.000000 17.000000 17.000000 17.000000 17.000000 17.000000 17.000000 17.000000 17.000000 17.000000 17.000000 17.000000 18.000000 18.000000 18.000000 18.000000 18.000000 18.000000 18.000000 18.000000 18.000000 18.000000 18.000000 18.000000 18.000000 18.000000 18.000000 19.000000 19.000000 19.000000 19.000000 19.000000 19.000000 19.000000 19.000000 19.000000 19.000000 19.000000 19.000000 19.000000 19.000000 19.000000 20.000000 20.000000 20.000000 20.000000 20.000000 20.000000 20.000000 20.000000 20.000000 20.000000 20.000000 20.000000 20.000000 20.000000 20.000000 21.000000 21.000000 21.000000 21.000000 21.000000 21.000000 21.000000 21.000000 21.000000 21.000000 21.000000 21.000000 21.000000 21.000000 21.000000 22.000000 22.000000 22.000000 22.000000 22.000000 22.000000 22.000000 22.000000 22.000000 22.000000 22.000000 22.000000 22.000000 22.000000 22.000000 23.000000 23.000000 23.000000 23.000000 23.000000 23.000000 23.000000 23.000000 23.000000 23.000000 23.000000 23.000000 23.000000 23.000000 23.000000 24.000000 24.000000 24.000000 24.000000 24.000000 24.000000 24.000000 24.000000 24.000000 24.000000 24.000000 24.000000 24.000000 24.000000 24.000000 25.000000 25.000000 25.000000 25.000000 25.000000 25.000000 25.000000 25.000000 25.000000 25.000000 25.000000 25.000000 25.000000 25.000000 25.000000 26.000000 26.000000 26.000000 26.000000 26.000000 26.000000 26.000000 26.000000 26.000000 26.000000 26.000000 26.000000 26.000000 26.000000 26.000000 27.000000 27.000000 27.000000 27.000000 27.000000 27.000000 27.000000 27.000000 27.000000 27.000000 27.000000 27.000000 27.000000 27.000000 27.000000 28.000000 28.000000 28.000000 28.000000 28.000000 28.000000 28.000000 28.000000 28.000000 28.000000 28.000000 28.000000 28.000000 28.000000 28.000000 29.000000 29.000000 29.000000 29.000000 29.000000 29.000000 29.000000 29.000000 29.000000 29.000000 29.000000 29.000000 29.000000 29.000000 29.000000 30.000000 30.000000 30.000000 30.000000 30.000000 30.000000 30.000000 30.000000 30.000000 30.000000 30.000000 30.000000 30.000000 30.000000 30.000000
    4 Measurement10 Monitor Only mm 63.05834 62.95036 62.83031 62.95036 63.31585 63.93487 64.62673 65.26081 65.83663 66.36728 66.86994 67.36246 67.85257 68.35924 68.93072 69.60636 62.95036 62.83031 62.95036 63.31585 63.91162 64.50316 65.00708 65.42964 65.78604 66.08339 66.33346 66.53433 66.68587 66.79083 66.83779 62.95036 62.83031 62.95036 63.31585 63.87091 64.35726 64.73313 65.0138 65.20934 65.33565 65.39249 65.40139 65.40103 65.40077 65.40056 62.95033 62.83039 62.95033 63.31585 63.81243 64.19258 64.44842 64.59954 64.66684 64.67658 64.67634 64.676 64.67571 64.67565 64.67575 62.95037 62.83031 62.95037 63.31497 63.73724 64.01349 64.16 64.20899 64.21092 64.21082 64.21054 64.21028 64.21015 64.21013 64.21015 62.95028 62.83022 62.95028 63.30702 63.64702 63.82562 63.88225 63.8842 63.88426 63.88409 63.88386 63.88363 63.88346 63.88345 63.88363 62.95036 62.83031 62.95036 63.28922 63.54456 63.63764 63.64425 63.64435 63.64435 63.64417 63.6439 63.64363 63.64354 63.64376 63.64427 62.95036 62.83031 62.95036 63.26047 63.43379 63.4627 63.46272 63.46282 63.46278 63.46253 63.46222 63.46205 63.46218 63.46262 63.46326 62.95036 62.83031 62.95036 63.22116 63.32 63.32263 63.32269 63.32278 63.32265 63.32234 63.32208 63.32212 63.32245 63.32296 63.32353 62.95036 62.83031 62.95036 63.17251 63.21318 63.21311 63.21321 63.21326 63.21303 63.21273 63.21264 63.21284 63.21323 63.21371 63.21412 62.95036 62.83031 62.95036 63.11687 63.12677 63.12673 63.12686 63.12681 63.12653 63.12633 63.12639 63.12666 63.12703 63.12744 63.12764 62.95036 62.83031 62.94992 63.05791 63.05822 63.05822 63.05834 63.05819 63.05794 63.05787 63.05801 63.05829 63.05861 63.05889 63.05891 62.95036 62.83031 62.94557 63.00376 63.0037 63.00376 63.00381 63.0036 63.00344 63.00346 63.00363 63.00389 63.00413 63.00429 63.00415 62.95036 62.83031 62.93535 62.96041 62.96036 62.96043 62.96042 62.96021 62.96013 62.9602 62.96038 62.96059 62.96079 62.96078 62.96058 62.95036 62.83031 62.91923 62.92605 62.92601 62.92609 62.92601 62.92585 62.92582 62.92591 62.92608 62.92626 62.92636 62.92626 62.92605 62.95036 62.83031 62.89864 62.89899 62.89897 62.89903 62.89892 62.89881 62.89881 62.89891 62.89905 62.89918 62.89921 62.89906 62.89891 62.95036 62.83031 62.87792 62.87791 62.87791 62.87794 62.87783 62.87776 62.87777 62.87787 62.87799 62.87807 62.87803 62.87789 62.87782 62.95036 62.83031 62.86177 62.86176 62.86177 62.86177 62.86167 62.86163 62.86166 62.86174 62.86184 62.86187 62.8618 62.86171 62.86167 62.95036 62.83031 62.84971 62.84969 62.84972 62.84969 62.84962 62.84959 62.84962 62.84969 62.84976 62.84977 62.84969 62.84964 62.84961 62.95036 62.83031 62.84105 62.84104 62.84106 62.84102 62.84096 62.84094 62.84097 62.84103 62.84109 62.84107 62.84101 62.84098 62.84095 62.95036 62.83031 62.83524 62.83522 62.83524 62.83521 62.83516 62.83513 62.83516 62.83522 62.83525 62.83523 62.83519 62.83517 62.83515 62.95036 62.83031 62.83181 62.8318 62.83181 62.83178 62.83173 62.83171 62.83174 62.83178 62.83181 62.83179 62.83177 62.83174 62.83172 62.95036 62.83031 62.83039 62.83037 62.83039 62.83036 62.83031 62.83029 62.83031 62.83036 62.83039 62.83037 62.83035 62.83033 62.83031 62.95036 62.83066 62.83066 62.83065 62.83066 62.83063 62.83058 62.83057 62.83059 62.83063 62.83066 62.83064 62.83062 62.8306 62.83057 62.95036 62.83236 62.83236 62.83235 62.83236 62.83233 62.83228 62.83227 62.83229 62.83233 62.83235 62.83234 62.83232 62.8323 62.83227 62.95036 62.83526 62.83526 62.83525 62.83527 62.83523 62.83518 62.83516 62.83519 62.83525 62.83525 62.83525 62.83522 62.83519 62.83517

    Clean Data

    Now a series of initial cleaning steps:

    • clean_names() to convert the column names to snake_case and remove any other weirdness
    • remove the format and unit columns using select
    • drop_na() to remove the useless row containing just “calculated”
    • rename the first column header to something shorter “param”
    • recode the value “Measurement7” as just “measurement” in a way that would work for other numeric suffixes
    • convert the param column to be a factor

    Reformat and clean in wide format

    study_1_wide_tbl <- data_raw_tbl %>%
      janitor::clean_names() %>%
      select(-c(format, unit)) %>%
      drop_na() %>%
      rename(param = parameter_constraint_or_goal) %>%
      mutate(across(contains(match = "_"), as.double)) %>%
      mutate(param = case_when(
        str_detect(param, "Measurement") ~ "measurement",
        TRUE ~ param
      )) %>%
      mutate(param = param %>% as_factor())
    
    study_1_wide_tbl %>%
      gt_preview()
    param initial_value scenario_1 scenario_2 scenario_3 scenario_4 scenario_5 scenario_6 scenario_7 scenario_8 scenario_9 scenario_10 scenario_11 scenario_12 scenario_13 scenario_14 scenario_15 scenario_16 scenario_17 scenario_18 scenario_19 scenario_20 scenario_21 scenario_22 scenario_23 scenario_24 scenario_25 scenario_26 scenario_27 scenario_28 scenario_29 scenario_30 scenario_31 scenario_32 scenario_33 scenario_34 scenario_35 scenario_36 scenario_37 scenario_38 scenario_39 scenario_40 scenario_41 scenario_42 scenario_43 scenario_44 scenario_45 scenario_46 scenario_47 scenario_48 scenario_49 scenario_50 scenario_51 scenario_52 scenario_53 scenario_54 scenario_55 scenario_56 scenario_57 scenario_58 scenario_59 scenario_60 scenario_61 scenario_62 scenario_63 scenario_64 scenario_65 scenario_66 scenario_67 scenario_68 scenario_69 scenario_70 scenario_71 scenario_72 scenario_73 scenario_74 scenario_75 scenario_76 scenario_77 scenario_78 scenario_79 scenario_80 scenario_81 scenario_82 scenario_83 scenario_84 scenario_85 scenario_86 scenario_87 scenario_88 scenario_89 scenario_90 scenario_91 scenario_92 scenario_93 scenario_94 scenario_95 scenario_96 scenario_97 scenario_98 scenario_99 scenario_100 scenario_101 scenario_102 scenario_103 scenario_104 scenario_105 scenario_106 scenario_107 scenario_108 scenario_109 scenario_110 scenario_111 scenario_112 scenario_113 scenario_114 scenario_115 scenario_116 scenario_117 scenario_118 scenario_119 scenario_120 scenario_121 scenario_122 scenario_123 scenario_124 scenario_125 scenario_126 scenario_127 scenario_128 scenario_129 scenario_130 scenario_131 scenario_132 scenario_133 scenario_134 scenario_135 scenario_136 scenario_137 scenario_138 scenario_139 scenario_140 scenario_141 scenario_142 scenario_143 scenario_144 scenario_145 scenario_146 scenario_147 scenario_148 scenario_149 scenario_150 scenario_151 scenario_152 scenario_153 scenario_154 scenario_155 scenario_156 scenario_157 scenario_158 scenario_159 scenario_160 scenario_161 scenario_162 scenario_163 scenario_164 scenario_165 scenario_166 scenario_167 scenario_168 scenario_169 scenario_170 scenario_171 scenario_172 scenario_173 scenario_174 scenario_175 scenario_176 scenario_177 scenario_178 scenario_179 scenario_180 scenario_181 scenario_182 scenario_183 scenario_184 scenario_185 scenario_186 scenario_187 scenario_188 scenario_189 scenario_190 scenario_191 scenario_192 scenario_193 scenario_194 scenario_195 scenario_196 scenario_197 scenario_198 scenario_199 scenario_200 scenario_201 scenario_202 scenario_203 scenario_204 scenario_205 scenario_206 scenario_207 scenario_208 scenario_209 scenario_210 scenario_211 scenario_212 scenario_213 scenario_214 scenario_215 scenario_216 scenario_217 scenario_218 scenario_219 scenario_220 scenario_221 scenario_222 scenario_223 scenario_224 scenario_225 scenario_226 scenario_227 scenario_228 scenario_229 scenario_230 scenario_231 scenario_232 scenario_233 scenario_234 scenario_235 scenario_236 scenario_237 scenario_238 scenario_239 scenario_240 scenario_241 scenario_242 scenario_243 scenario_244 scenario_245 scenario_246 scenario_247 scenario_248 scenario_249 scenario_250 scenario_251 scenario_252 scenario_253 scenario_254 scenario_255 scenario_256 scenario_257 scenario_258 scenario_259 scenario_260 scenario_261 scenario_262 scenario_263 scenario_264 scenario_265 scenario_266 scenario_267 scenario_268 scenario_269 scenario_270 scenario_271 scenario_272 scenario_273 scenario_274 scenario_275 scenario_276 scenario_277 scenario_278 scenario_279 scenario_280 scenario_281 scenario_282 scenario_283 scenario_284 scenario_285 scenario_286 scenario_287 scenario_288 scenario_289 scenario_290 scenario_291 scenario_292 scenario_293 scenario_294 scenario_295 scenario_296 scenario_297 scenario_298 scenario_299 scenario_300 scenario_301 scenario_302 scenario_303 scenario_304 scenario_305 scenario_306 scenario_307 scenario_308 scenario_309 scenario_310 scenario_311 scenario_312 scenario_313 scenario_314 scenario_315 scenario_316 scenario_317 scenario_318 scenario_319 scenario_320 scenario_321 scenario_322 scenario_323 scenario_324 scenario_325 scenario_326 scenario_327 scenario_328 scenario_329 scenario_330 scenario_331 scenario_332 scenario_333 scenario_334 scenario_335 scenario_336 scenario_337 scenario_338 scenario_339 scenario_340 scenario_341 scenario_342 scenario_343 scenario_344 scenario_345 scenario_346 scenario_347 scenario_348 scenario_349 scenario_350 scenario_351 scenario_352 scenario_353 scenario_354 scenario_355 scenario_356 scenario_357 scenario_358 scenario_359 scenario_360 scenario_361 scenario_362 scenario_363 scenario_364 scenario_365 scenario_366 scenario_367 scenario_368 scenario_369 scenario_370 scenario_371 scenario_372 scenario_373 scenario_374 scenario_375 scenario_376 scenario_377 scenario_378 scenario_379 scenario_380 scenario_381 scenario_382 scenario_383 scenario_384 scenario_385 scenario_386 scenario_387 scenario_388 scenario_389 scenario_390
    1 vessel_angulation 40.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.0000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.0000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.0000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.0000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.0000 35.00000 40.00000 45.0000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.0000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.0000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.0000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.0000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.0000 80.00000 10.00000 15.00000 20.00000 25.00000 30.00000 35.00000 40.00000 45.00000 50.00000 55.00000 60.00000 65.00000 70.00000 75.00000 80.00000
    2 vessel_roc 16.00000 5.00000 5.00000 5.00000 5.00000 5.00000 5.00000 5.00000 5.00000 5.00000 5.00000 5.00000 5.00000 5.00000 5.00000 5.00000 6.00000 6.00000 6.00000 6.00000 6.00000 6.00000 6.00000 6.00000 6.00000 6.00000 6.00000 6.00000 6.00000 6.00000 6.00000 7.00000 7.00000 7.00000 7.00000 7.00000 7.00000 7.00000 7.0000 7.00000 7.00000 7.00000 7.00000 7.00000 7.00000 7.00000 8.00000 8.00000 8.00000 8.00000 8.00000 8.00000 8.00000 8.00000 8.00000 8.00000 8.00000 8.000 8.00000 8.00000 8.00000 9.00000 9.00000 9.00000 9.00000 9.00000 9.00000 9.00 9.00000 9.00000 9.00000 9.00000 9.00000 9.00000 9.00000 9.00000 10.00000 10.00000 10.00000 10.00000 10.00000 10.00000 10.00000 10.0000 10.00000 10.00000 10.00000 10.00000 10.00000 10.00000 10.00000 11.00000 11.00000 11.00000 11.00000 11.00000 11.00000 11.00000 11.00000 11.00000 11.00000 11.0000 11.00000 11.00000 11.00000 11.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.0000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 13.00000 13.00000 13.00000 13.00000 13.00 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 14.00000 14.00000 14.00000 14.00000 14.00000 14.00000 14.00000 14.00000 14.00000 14.00000 14.00000 14.00000 14.00000 14.00000 14.00000 15.00000 15.00000 15.00000 15.00000 15.00000 15.00000 15.00000 15.00000 15.00000 15.00000 15.00000 15.00000 15.00000 15.00000 15.00000 16.00000 16.00000 16.00000 16.00000 16.00000 16.00000 16.00000 16.00000 16.00000 16.00000 16.00000 16.00000 16.00000 16.00000 16.00000 17.00000 17.00000 17.00000 17.00000 17.0000 17.00000 17.00000 17.0000 17.00000 17.00000 17.00000 17.00000 17.00000 17.00000 17.00000 18.00000 18.00000 18.00000 18.00000 18.00000 18.00000 18.00000 18.00000 18.00000 18.0000 18.00000 18.00000 18.00000 18.00000 18.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 20.00000 20.00000 20.00000 20.00000 20.00000 20.00000 20.00000 20.00000 20.00000 20.00000 20.00000 20.00000 20.00000 20.00000 20.00000 21.00000 21.00000 21.00000 21.00000 21.00000 21.00000 21.00000 21.00000 21.00000 21.00000 21.00000 21.00000 21.00000 21.00000 21.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.0000 22.00000 22.00000 23.00000 23.00000 23.00000 23.00000 23.00000 23.00000 23.00000 23.00000 23.00000 23.00000 23.00000 23.00000 23.00000 23.00000 23.00000 24.00000 24.00000 24.00000 24.00000 24.00000 24.00000 24.00000 24.00000 24.00000 24.00000 24.00000 24.00000 24.00000 24.00000 24.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 26.00000 26.00000 26.00000 26.0000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000 28.00000 28.00000 28.00000 28.00000 28.00000 28.00000 28.00000 28.00000 28.00000 28.00000 28.00000 28.00000 28.00000 28.0000 28.00000 29.00000 29.00000 29.00000 29.00000 29.00000 29.00000 29.00000 29.00000 29.00000 29.00000 29.00000 29.00000 29.00000 29.0000 29.00000 30.00000 30.00000 30.00000 30.00000 30.00000 30.00000 30.00000 30.00000 30.00000 30.00000 30.00000 30.00000 30.00000 30.00000 30.00000
    3 measurement 63.05834 62.95036 62.83031 62.95036 63.31585 63.93487 64.62673 65.26081 65.83663 66.36728 66.86994 67.36246 67.85257 68.35924 68.93072 69.60636 62.95036 62.83031 62.95036 63.31585 63.91162 64.50316 65.00708 65.42964 65.78604 66.08339 66.33346 66.53433 66.68587 66.79083 66.83779 62.95036 62.83031 62.95036 63.31585 63.87091 64.35726 64.73313 65.0138 65.20934 65.33565 65.39249 65.40139 65.40103 65.40077 65.40056 62.95033 62.83039 62.95033 63.31585 63.81243 64.19258 64.44842 64.59954 64.66684 64.67658 64.67634 64.676 64.67571 64.67565 64.67575 62.95037 62.83031 62.95037 63.31497 63.73724 64.01349 64.16 64.20899 64.21092 64.21082 64.21054 64.21028 64.21015 64.21013 64.21015 62.95028 62.83022 62.95028 63.30702 63.64702 63.82562 63.88225 63.8842 63.88426 63.88409 63.88386 63.88363 63.88346 63.88345 63.88363 62.95036 62.83031 62.95036 63.28922 63.54456 63.63764 63.64425 63.64435 63.64435 63.64417 63.6439 63.64363 63.64354 63.64376 63.64427 62.95036 62.83031 62.95036 63.26047 63.43379 63.4627 63.46272 63.46282 63.46278 63.46253 63.46222 63.46205 63.46218 63.46262 63.46326 62.95036 62.83031 62.95036 63.22116 63.32 63.32263 63.32269 63.32278 63.32265 63.32234 63.32208 63.32212 63.32245 63.32296 63.32353 62.95036 62.83031 62.95036 63.17251 63.21318 63.21311 63.21321 63.21326 63.21303 63.21273 63.21264 63.21284 63.21323 63.21371 63.21412 62.95036 62.83031 62.95036 63.11687 63.12677 63.12673 63.12686 63.12681 63.12653 63.12633 63.12639 63.12666 63.12703 63.12744 63.12764 62.95036 62.83031 62.94992 63.05791 63.05822 63.05822 63.05834 63.05819 63.05794 63.05787 63.05801 63.05829 63.05861 63.05889 63.05891 62.95036 62.83031 62.94557 63.00376 63.0037 63.00376 63.00381 63.0036 63.00344 63.00346 63.00363 63.00389 63.00413 63.00429 63.00415 62.95036 62.83031 62.93535 62.96041 62.96036 62.96043 62.96042 62.96021 62.96013 62.9602 62.96038 62.96059 62.96079 62.96078 62.96058 62.95036 62.83031 62.91923 62.92605 62.92601 62.92609 62.92601 62.92585 62.92582 62.92591 62.92608 62.92626 62.92636 62.92626 62.92605 62.95036 62.83031 62.89864 62.89899 62.89897 62.89903 62.89892 62.89881 62.89881 62.89891 62.89905 62.89918 62.89921 62.89906 62.89891 62.95036 62.83031 62.87792 62.87791 62.87791 62.87794 62.87783 62.87776 62.87777 62.87787 62.87799 62.87807 62.87803 62.87789 62.87782 62.95036 62.83031 62.86177 62.86176 62.86177 62.86177 62.86167 62.86163 62.86166 62.86174 62.86184 62.86187 62.8618 62.86171 62.86167 62.95036 62.83031 62.84971 62.84969 62.84972 62.84969 62.84962 62.84959 62.84962 62.84969 62.84976 62.84977 62.84969 62.84964 62.84961 62.95036 62.83031 62.84105 62.84104 62.84106 62.84102 62.84096 62.84094 62.84097 62.84103 62.84109 62.84107 62.84101 62.84098 62.84095 62.95036 62.83031 62.83524 62.83522 62.83524 62.83521 62.83516 62.83513 62.83516 62.83522 62.83525 62.83523 62.83519 62.83517 62.83515 62.95036 62.83031 62.83181 62.8318 62.83181 62.83178 62.83173 62.83171 62.83174 62.83178 62.83181 62.83179 62.83177 62.83174 62.83172 62.95036 62.83031 62.83039 62.83037 62.83039 62.83036 62.83031 62.83029 62.83031 62.83036 62.83039 62.83037 62.83035 62.83033 62.83031 62.95036 62.83066 62.83066 62.83065 62.83066 62.83063 62.83058 62.83057 62.83059 62.83063 62.83066 62.83064 62.83062 62.8306 62.83057 62.95036 62.83236 62.83236 62.83235 62.83236 62.83233 62.83228 62.83227 62.83229 62.83233 62.83235 62.83234 62.83232 62.8323 62.83227 62.95036 62.83526 62.83526 62.83525 62.83527 62.83523 62.83518 62.83516 62.83519 62.83525 62.83525 62.83525 62.83522 62.83519 62.83517

    Reshape Data

    Convert to long format in preparation for visualization

    We’ve done some good cleaning but need to pivot from wide format to long so that each column can be a variable and each row a value. To accomplish this, use a pipe that does the following:

    • pivot_longer() on all columns except param to bring the data into 3 total columns: “param”, “name”, and “value”
    • use the underscore character within the “scenario_x” values to separate the “name” column into 2 columns (“delete” and “scenario”)
    • remove the first row that wasn’t part of the design study (was just the initial state of the model)
    • convert “scenario” column to type double
    • remove the “delete” column
    • reorder the columns using select()
    • pivot_wider() to push all the variables contained as values in “param” into columns of their own
    • format the measurement column
    study_1_long_tbl <- study_1_wide_tbl %>%
      pivot_longer(cols = -param) %>%
      separate(col = name, into = c("delete", "scenario"), sep = "_") %>%
      filter(scenario != "value") %>%
      mutate(scenario = scenario %>% as.double()) %>%
      select(-delete) %>%
      select(scenario, param, value) %>%
      pivot_wider(id_cols = c(param, scenario), names_from = param) %>%
      mutate(measurement = measurement %>% round(digits = 2))
    
    study_1_long_tbl %>%
      gt_preview()
    scenario vessel_angulation vessel_roc measurement
    1 1 10 5 62.95
    2 2 15 5 62.83
    3 3 20 5 62.95
    4 4 25 5 63.32
    5 5 30 5 63.93
    6..389
    390 390 80 30 62.84

    Visualize

    ggplot

    Create a raster plot with Radius of Curvature plotted against Vessel Angulation.

    surface_plt <- study_1_long_tbl %>%
      ggplot(aes(x = vessel_roc, y = vessel_angulation)) +
      geom_raster(aes(fill = measurement), interpolate = TRUE) +
      scale_fill_viridis_c(option = "A") +
      labs(
        x = "Vessel Inner Radius of Curvature (mm)",
        y = "Vessel Centerline Angulation (degrees)",
        title = "Vessel Perimeter as a Function of Angulation and Radius of Curvature",
        subtitle = "Measured at 10 mm below onset of angulation, Vessel ID = 20 mm",
        fill = "Perimeter (mm)"
      )
    
    
    surface_plt

    There’s not a lot of action after about 15 on the x-axis so filter away those points and replot. Normally you would just rescale the axis limits but this way you don’t have to fiddle with the margins.

    surface_plt_2 <- study_1_long_tbl %>%
      filter(vessel_roc < 15) %>%
      ggplot(aes(x = vessel_roc, y = vessel_angulation)) +
      geom_raster(aes(fill = measurement), interpolate = TRUE) +
      scale_fill_viridis_c(option = "A") +
      labs(
        x = "Vessel Inner Radius of Curvature (mm)",
        y = "Vessel Centerline Angulation (degrees)",
        title = "Vessel Perimeter as a Function of Angulation and Radius of Curvature",
        subtitle = "Measured at 10 mm below onset of angulation, Vessel ID = 20 mm",
        fill = "Perimeter (mm)"
      )
    
    surface_plt_2

    rayshader

    Push the plot into 3d using rayshader for some better perspective

    # plot_gg(surface_plt_2, width=7, height = 5, multicore = TRUE, windowsize = c(1400,866), sunangle=225,
    #         zoom = 0.60, phi = 30, theta = 45)

    Static

    Dynamic

    Takeaways and Conclusions

    The figure tells an interesting story: as long as the vessel angulation is less than about 20 degrees and the radius of curvature less than about 15 mm then the perimeter at the plane of interest is relatively low. But if the radius of curvature is less than 15 mm and the angulation greater than 20 degree, the perimeter will increase relative to baseline with the largest increases occurring at higher values of angulation and lower values of radius of curvature. Let’s look at a couple of cases as a gut-check, using this little helper tibble to plot lines in some regions of interest.

    Case 1:

    • Radius of Curvature = 5, Angulation = 20, 70: we can see that when both variables are on the low end of their range, the cut plane is actually below the angulation and the perimeter will be relatively low. As the Angulation goes up to 70, the perimeter is affected and will be larger.
    vlines_tbl <- tibble(
      vessel_roc = c(5, 5, 13, 13),
      vessel_angulation = c(20, 70, 20, 70),
      plot = c(1, 1, 2, 2)
    )
    
    surface_plt_2 +
      geom_line(data = vlines_tbl %>% filter(plot == 1), color = "white", linetype = "dashed") +
      geom_point(data = vlines_tbl %>% filter(plot == 1), color = "white", size = 2)

    Case 2:

    • Radius of Curvature = 13, Angulation = 20, 70: when the radius of curvature is sufficiently large, the perimeter measurement at the cutting plane is relatively insensitive the angulation.
    surface_plt_2 +
      geom_line(data = vlines_tbl %>% filter(plot == 2), color = "white", linetype = "dashed") +
      geom_point(data = vlines_tbl %>% filter(plot == 2), color = "white", size = 2)

    Final Thought

    This provides our hypothetical clinical imaging team with some important insight about patient screening that will hopefully improve outcomes. If you’ve made it this far, I thank you for your attention and hope this walkthrough was useful!

    sessionInfo

    sessionInfo()
    ## R version 4.0.3 (2020-10-10)
    ## Platform: x86_64-w64-mingw32/x64 (64-bit)
    ## Running under: Windows 10 x64 (build 18363)
    ## 
    ## Matrix products: default
    ## 
    ## locale:
    ## [1] LC_COLLATE=English_United States.1252 
    ## [2] LC_CTYPE=English_United States.1252   
    ## [3] LC_MONETARY=English_United States.1252
    ## [4] LC_NUMERIC=C                          
    ## [5] LC_TIME=English_United States.1252    
    ## 
    ## attached base packages:
    ## [1] stats     graphics  grDevices utils     datasets  methods   base     
    ## 
    ## other attached packages:
    ##  [1] av_0.5.1         knitr_1.30       rayshader_0.19.2 gt_0.2.2        
    ##  [5] here_1.0.0       readxl_1.3.1     forcats_0.5.0    stringr_1.4.0   
    ##  [9] dplyr_1.0.2      purrr_0.3.4      readr_1.4.0      tidyr_1.1.2     
    ## [13] tibble_3.0.4     ggplot2_3.3.2    tidyverse_1.3.0 
    ## 
    ## loaded via a namespace (and not attached):
    ##  [1] fs_1.5.0                lubridate_1.7.9.2       doParallel_1.0.16      
    ##  [4] webshot_0.5.2           progress_1.2.2          httr_1.4.2             
    ##  [7] rprojroot_2.0.2         tools_4.0.3             backports_1.2.0        
    ## [10] R6_2.5.0                DBI_1.1.0               colorspace_2.0-0       
    ## [13] manipulateWidget_0.10.1 withr_2.3.0             tidyselect_1.1.0       
    ## [16] prettyunits_1.1.1       compiler_4.0.3          cli_2.2.0              
    ## [19] rvest_0.3.6             xml2_1.3.2              labeling_0.4.2         
    ## [22] bookdown_0.21           sass_0.3.1              scales_1.1.1           
    ## [25] checkmate_2.0.0         digest_0.6.27           rmarkdown_2.5          
    ## [28] pkgconfig_2.0.3         htmltools_0.5.0         dbplyr_2.0.0           
    ## [31] fastmap_1.0.1           htmlwidgets_1.5.2       rlang_0.4.9            
    ## [34] rstudioapi_0.13         shiny_1.5.0             generics_0.1.0         
    ## [37] farver_2.0.3            jsonlite_1.7.1          crosstalk_1.1.0.1      
    ## [40] magrittr_2.0.1          Rcpp_1.0.5              munsell_0.5.0          
    ## [43] fansi_0.4.1             lifecycle_0.2.0         stringi_1.5.3          
    ## [46] yaml_2.2.1              snakecase_0.11.0        grid_4.0.3             
    ## [49] parallel_4.0.3          promises_1.1.1          crayon_1.3.4           
    ## [52] miniUI_0.1.1.1          haven_2.3.1             hms_0.5.3              
    ## [55] ps_1.4.0                pillar_1.4.7            codetools_0.2-18       
    ## [58] reprex_0.3.0            glue_1.4.2              evaluate_0.14          
    ## [61] blogdown_0.15           modelr_0.1.8            vctrs_0.3.5            
    ## [64] httpuv_1.5.4            foreach_1.5.1           cellranger_1.1.0       
    ## [67] gtable_0.3.0            assertthat_0.2.1        xfun_0.19              
    ## [70] mime_0.9                janitor_2.0.1           xtable_1.8-4           
    ## [73] broom_0.7.2             later_1.1.0.1           viridisLite_0.3.0      
    ## [76] iterators_1.0.13        rgl_0.103.5             ellipsis_0.3.1

    To leave a comment for the author, please follow the link and comment on their blog: [R]eliability.

    R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
    Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.