This function reads spectral data from a file, automatically detecting the format and using either `readr` or `readxl` functions. It also sets the specified wavenumber column as the default using `set_spec_wn()`.
Details
The function automatically determines the file format based on the extension: - `.txt`, `.csv`, `.tsv`, and `.csv2` are read using `readr` functions. - `.xls` and `.xlsx` are read using `readxl::read_excel()`.
If the specified `wn_col` does not exist in the data, an error is returned.
Examples
# \donttest{
file_path <- system.file("extdata", "CoHAspec.csv", package = "tidyspec")
df <- spec_read(file_path, wn_col = "Wavenumber")
#> Rows: 1868 Columns: 5
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> dbl (5): Wavenumber, CoHA01, CoHA025, CoHA05, CoHA100
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Successfully set 'Wavenumber' as the default wavenumber column.
#> File loaded successfully! Wavenumber column set to: Wavenumber
check_wn_col() # Verifica se a coluna de wavenumber está definida
#> The current wavenumber column is: Wavenumber
# }