Finds and imports reflectance/transmittance/absorbance data from spectra files in a given location.

lr_get_spec(
  where = getwd(),
  ext = "txt",
  lim = c(300, 700),
  decimal = ".",
  sep = NULL,
  subdir = FALSE,
  subdir.names = FALSE,
  cores = NULL,
  ignore.case = TRUE,
  interpolate = TRUE
)

Arguments

where

Folder in which files are located (defaults to current working directory).

ext

File extension to be searched for, without the "." (defaults to txt). You can also use a character vector to specify multiple file extensions.

lim

A vector with two numbers determining the wavelength limits to be considered (defaults to c(300, 700)).

decimal

Character to be used to identify decimal plates (defaults to .).

sep

Column delimiting characters to be considered in addition to the default (which are: tab, space, and ";")

subdir

Should subdirectories within the where folder be included in the search? (defaults to FALSE).

subdir.names

Should subdirectory path be included in the name of the spectra? (defaults to FALSE).

cores

deprecated. See future::plan() for more details on how to customise your parallelisation strategy.

ignore.case

Should the extension search be case insensitive? (defaults to TRUE)

interpolate

Boolean indicated whether spectral data should be interpolated and pruned at every nanometre. Note that this option can only work if all input data samples the same wavelengths. Defaults to TRUE.

Value

A data.frame, containing the wavelengths in the first column and individual imported spectral files in the subsequent columns.

Details

You can customise the type of parallel processing used by this function with the future::plan() function. This works on all operating systems, as well as high performance computing (HPC) environment. Similarly, you can customise the way progress is shown with the progressr::handlers() functions (progress bar, acoustic feedback, nothing, etc.)

See also

Examples

lr_get_spec(system.file("testdata", package = "lightr"), ext = "jdx")
#> 1 files found; importing spectra:
#> wl OceanOptics_period #> 1 300 154.30298 #> 2 301 129.29809 #> 3 302 115.91197 #> 4 303 122.58183 #> 5 304 125.93071 #> 6 305 152.31362 #> 7 306 128.13966 #> 8 307 117.86368 #> 9 308 112.84276 #> 10 309 109.71243 #> 11 310 121.54251 #> 12 311 123.28324 #> 13 312 124.74489 #> 14 313 110.73993 #> 15 314 112.68217 #> 16 315 113.78364 #> 17 316 117.45949 #> 18 317 118.54198 #> 19 318 118.19778 #> 20 319 106.34203 #> 21 320 107.39142 #> 22 321 109.76555 #> 23 322 114.72903 #> 24 323 119.33660 #> 25 324 107.52149 #> 26 325 101.75345 #> 27 326 104.28663 #> 28 327 107.87688 #> 29 328 108.62436 #> 30 329 111.85939 #> 31 330 103.38569 #> 32 331 103.56266 #> 33 332 104.83122 #> 34 333 108.91268 #> 35 334 108.29381 #> 36 335 106.73846 #> 37 336 101.76082 #> 38 337 102.86521 #> 39 338 106.13956 #> 40 339 109.13051 #> 41 340 106.55439 #> 42 341 103.14931 #> 43 342 100.21261 #> 44 343 101.34722 #> 45 344 100.78846 #> 46 345 104.12125 #> 47 346 102.68765 #> 48 347 100.50250 #> 49 348 101.25482 #> 50 349 101.50004 #> 51 350 103.00444 #> 52 351 102.58171 #> 53 352 101.68627 #> 54 353 100.49696 #> 55 354 99.17759 #> 56 355 99.60788 #> 57 356 101.45014 #> 58 357 100.34455 #> 59 358 98.66869 #> 60 359 99.71813 #> 61 360 100.61191 #> 62 361 100.46539 #> 63 362 99.89516 #> 64 363 98.10299 #> 65 364 98.26251 #> 66 365 99.10356 #> 67 366 99.65081 #> 68 367 99.66415 #> 69 368 97.96237 #> 70 369 96.50048 #> 71 370 96.25603 #> 72 371 97.09070 #> 73 372 96.86566 #> 74 373 97.39753 #> 75 374 96.90670 #> 76 375 97.20173 #> 77 376 98.67826 #> 78 377 100.04095 #> 79 378 98.87367 #> 80 379 99.06906 #> 81 380 97.86990 #> 82 381 98.65246 #> 83 382 99.59832 #> 84 383 99.00052 #> 85 384 98.54025 #> 86 385 98.66653 #> 87 386 99.01312 #> 88 387 98.13707 #> 89 388 98.49849 #> 90 389 97.16139 #> 91 390 97.35658 #> 92 391 98.29049 #> 93 392 98.50670 #> 94 393 99.19929 #> 95 394 99.36340 #> 96 395 97.98233 #> 97 396 99.20106 #> 98 397 98.83048 #> 99 398 99.67481 #> 100 399 99.04964 #> 101 400 98.91724 #> 102 401 99.73451 #> 103 402 100.83806 #> 104 403 100.38788 #> 105 404 99.60891 #> 106 405 99.04282 #> 107 406 100.57596 #> 108 407 99.34502 #> 109 408 99.63572 #> 110 409 98.51881 #> 111 410 97.59520 #> 112 411 99.52479 #> 113 412 98.25080 #> 114 413 98.79802 #> 115 414 97.38742 #> 116 415 98.28330 #> 117 416 98.69628 #> 118 417 99.17153 #> 119 418 98.79072 #> 120 419 98.54362 #> 121 420 98.76474 #> 122 421 100.32191 #> 123 422 100.67518 #> 124 423 99.35847 #> 125 424 98.34536 #> 126 425 98.35553 #> 127 426 98.73723 #> 128 427 98.18408 #> 129 428 98.35776 #> 130 429 99.05064 #> 131 430 100.25147 #> 132 431 99.87194 #> 133 432 99.50188 #> 134 433 98.86698 #> 135 434 98.87803 #> 136 435 99.35818 #> 137 436 99.23450 #> 138 437 98.51190 #> 139 438 98.28990 #> 140 439 98.82664 #> 141 440 98.42665 #> 142 441 100.37817 #> 143 442 99.68673 #> 144 443 99.89920 #> 145 444 101.25728 #> 146 445 100.85397 #> 147 446 100.05532 #> 148 447 100.45383 #> 149 448 101.41792 #> 150 449 101.23724 #> 151 450 101.83338 #> 152 451 100.63541 #> 153 452 100.92313 #> 154 453 100.94864 #> 155 454 101.08689 #> 156 455 101.40159 #> 157 456 100.96132 #> 158 457 101.78455 #> 159 458 102.77103 #> 160 459 102.04131 #> 161 460 103.14612 #> 162 461 102.44206 #> 163 462 104.30131 #> 164 463 102.95040 #> 165 464 102.08997 #> 166 465 101.93473 #> 167 466 102.01689 #> 168 467 102.15689 #> 169 468 101.08864 #> 170 469 101.18451 #> 171 470 102.24389 #> 172 471 102.95252 #> 173 472 102.95048 #> 174 473 102.68725 #> 175 474 102.72301 #> 176 475 102.85669 #> 177 476 103.65517 #> 178 477 102.70095 #> 179 478 102.62777 #> 180 479 102.71070 #> 181 480 102.52742 #> 182 481 101.63667 #> 183 482 101.12213 #> 184 483 100.99595 #> 185 484 102.11151 #> 186 485 101.84390 #> 187 486 100.74785 #> 188 487 100.57344 #> 189 488 102.12601 #> 190 489 102.44078 #> 191 490 102.78528 #> 192 491 103.62757 #> 193 492 104.46753 #> 194 493 104.75048 #> 195 494 104.19903 #> 196 495 102.77324 #> 197 496 103.63975 #> 198 497 103.83470 #> 199 498 103.51164 #> 200 499 103.38693 #> 201 500 104.34859 #> 202 501 104.69873 #> 203 502 104.51538 #> 204 503 103.31062 #> 205 504 104.85517 #> 206 505 104.91249 #> 207 506 105.51633 #> 208 507 105.60628 #> 209 508 104.71128 #> 210 509 104.89814 #> 211 510 104.07516 #> 212 511 103.38910 #> 213 512 104.69176 #> 214 513 104.88087 #> 215 514 105.51760 #> 216 515 104.73299 #> 217 516 104.97591 #> 218 517 104.33279 #> 219 518 104.65326 #> 220 519 104.08481 #> 221 520 103.79582 #> 222 521 103.60283 #> 223 522 104.47917 #> 224 523 104.97064 #> 225 524 104.09422 #> 226 525 103.77382 #> 227 526 104.32586 #> 228 527 103.28040 #> 229 528 103.94570 #> 230 529 105.77712 #> 231 530 104.69659 #> 232 531 106.06858 #> 233 532 105.02671 #> 234 533 105.57153 #> 235 534 104.28555 #> 236 535 104.05148 #> 237 536 104.97891 #> 238 537 105.19199 #> 239 538 106.06159 #> 240 539 105.70222 #> 241 540 105.96953 #> 242 541 104.74520 #> 243 542 105.22283 #> 244 543 104.11902 #> 245 544 104.28992 #> 246 545 104.52430 #> 247 546 105.08269 #> 248 547 105.08985 #> 249 548 105.74509 #> 250 549 106.77718 #> 251 550 106.13642 #> 252 551 106.97641 #> 253 552 106.69677 #> 254 553 106.75241 #> 255 554 106.13575 #> 256 555 106.47035 #> 257 556 106.36426 #> 258 557 104.88075 #> 259 558 103.80879 #> 260 559 104.35050 #> 261 560 104.51218 #> 262 561 104.90633 #> 263 562 104.86661 #> 264 563 105.08290 #> 265 564 106.73379 #> 266 565 106.12156 #> 267 566 106.34704 #> 268 567 105.62196 #> 269 568 105.58000 #> 270 569 105.00401 #> 271 570 106.07599 #> 272 571 107.28150 #> 273 572 107.43233 #> 274 573 107.13478 #> 275 574 107.59678 #> 276 575 107.16749 #> 277 576 106.26298 #> 278 577 105.47909 #> 279 578 106.35086 #> 280 579 105.11681 #> 281 580 107.38018 #> 282 581 107.15560 #> 283 582 107.34787 #> 284 583 106.47781 #> 285 584 106.17009 #> 286 585 104.63718 #> 287 586 105.33822 #> 288 587 105.76307 #> 289 588 106.21514 #> 290 589 106.46741 #> 291 590 107.61247 #> 292 591 105.93703 #> 293 592 106.69754 #> 294 593 107.12196 #> 295 594 106.87240 #> 296 595 106.53033 #> 297 596 108.44177 #> 298 597 107.11269 #> 299 598 107.42822 #> 300 599 107.24190 #> 301 600 107.87770 #> 302 601 107.47267 #> 303 602 107.72206 #> 304 603 109.67232 #> 305 604 108.43858 #> 306 605 107.81746 #> 307 606 106.52385 #> 308 607 107.00269 #> 309 608 107.01629 #> 310 609 106.41864 #> 311 610 106.99189 #> 312 611 106.42758 #> 313 612 106.43057 #> 314 613 109.10188 #> 315 614 107.68230 #> 316 615 107.74080 #> 317 616 109.22424 #> 318 617 111.72894 #> 319 618 109.76199 #> 320 619 109.72013 #> 321 620 111.44188 #> 322 621 109.26268 #> 323 622 107.91367 #> 324 623 109.35253 #> 325 624 109.35195 #> 326 625 107.56041 #> 327 626 107.68704 #> 328 627 108.72708 #> 329 628 108.43988 #> 330 629 107.72397 #> 331 630 108.77662 #> 332 631 108.69989 #> 333 632 109.52746 #> 334 633 110.73145 #> 335 634 111.84165 #> 336 635 109.76435 #> 337 636 109.30959 #> 338 637 110.05026 #> 339 638 107.62795 #> 340 639 107.61260 #> 341 640 110.06088 #> 342 641 110.27543 #> 343 642 110.15975 #> 344 643 112.66646 #> 345 644 111.05433 #> 346 645 109.94482 #> 347 646 111.02712 #> 348 647 111.02484 #> 349 648 108.35732 #> 350 649 108.45594 #> 351 650 108.16044 #> 352 651 106.98764 #> 353 652 107.45062 #> 354 653 110.18417 #> 355 654 106.82334 #> 356 655 105.86895 #> 357 656 106.98738 #> 358 657 106.01688 #> 359 658 105.40999 #> 360 659 108.06197 #> 361 660 108.46430 #> 362 661 106.88682 #> 363 662 108.21434 #> 364 663 109.16405 #> 365 664 108.64487 #> 366 665 110.31986 #> 367 666 112.63957 #> 368 667 109.43215 #> 369 668 110.57395 #> 370 669 109.43354 #> 371 670 108.48900 #> 372 671 108.83566 #> 373 672 109.49183 #> 374 673 106.20533 #> 375 674 107.60344 #> 376 675 108.51105 #> 377 676 105.21719 #> 378 677 108.63128 #> 379 678 108.38658 #> 380 679 106.73529 #> 381 680 107.36054 #> 382 681 107.88822 #> 383 682 107.61532 #> 384 683 107.18282 #> 385 684 107.85862 #> 386 685 106.81414 #> 387 686 107.49855 #> 388 687 110.28373 #> 389 688 110.29839 #> 390 689 109.94374 #> 391 690 111.95040 #> 392 691 109.80963 #> 393 692 109.22033 #> 394 693 111.90750 #> 395 694 108.69200 #> 396 695 107.59937 #> 397 696 112.01051 #> 398 697 109.95534 #> 399 698 110.27624 #> 400 699 114.85623 #> 401 700 111.52326