Learn R Programming

photobiologyInOut (version 0.4.30)

read_CIE_csv: Read '.CSV' files from CIE

Description

Reads a CSV spectral data file and its companion JSON file with metadata as published by International Commission on Illumination (CIE) and then imports wavelengths and spectral values into one the classes for spectral data defined in package 'photobiology.

Usage

read_CIE_csv(file.name, label = NULL, simplify = FALSE)

Value

Depending on the contents of the file, a source_mspct or

source_spct object, a response_spct or response_spct

object, or a chroma_spct object, containing both data and metadata. The whole metadata JSON converted into an R `list` is stored in attribute "header".

Arguments

file.name

character string Name of CSV file.

label

character string. If NULL metadata read from the JSON file is used, and if NA the "what.measured" attribute is not set, and if a character string is passed, it is used to set the "what.measured" attribute.

simplify

logical If TRUE and the read file contained a single spectrum, extract the spectral object from the collection.

Details

The CSV file contains only numbers encoded as character strings, and the JSON file contains extensive metadata. The type of spectral data is encoded as part of the file name. If the original file name of the CSV file is passed as argument to parameter file, the function can retrieve all data and metadata, enough to return an R object of the correct class. The JSON file must be located in the same folder as the CSV file.

References

https://cie.co.at/data-tables

Examples

Run this code

file.name <- 
  system.file("extdata", "CIE_illum_C.csv", 
              package = "photobiologyInOut", mustWork = TRUE)

CIE_illum_C.spct <- read_CIE_csv(file.name)
CIE_illum_C.spct
   
file.name <- 
  system.file("extdata", "CIE_sle_photopic.csv", 
              package = "photobiologyInOut", mustWork = TRUE)

CIE_sle_photopic.spct <- read_CIE_csv(file.name)
CIE_sle_photopic.spct
   

Run the code above in your browser using DataLab