This function loads spike data and the laboratory results, then processes it so that the `sample_ID` ties the spike value and the results together, using the `left_join` function from the `dplyr` package.
bs_prep_and_analysis(spike_data, lab_data)data frame containing all needed data to be used in subsequent functions.
name of the loaded dataset (no quotes) or the name of the file, with path, containing the spike values, in quotes. Example forms, my_spike_data, or "C:/my_directory/my_spike_data.csv". This file column headings must be as identified in the Details section.
name of the loaded dataset (no quotes) or the name of the file, with path, containing the laboratory results. Example forms, my_lab_data, or "C:/my_directory/my_lab_data.csv". This file column headings must be as identified in the Details section.
False negative results are flagged for laboratory results below the detection level in the analysis of a sample spiked above the detection level. False positives are flagged for laboratory results above the detection when the analyte was not spiked. Error rates are computed with the `table_false` function.
To use this function, first set up spike value data in a .csv file (in any column order) matching the column headers of the following values:
Required for spike data:
`sample_ID` unique identifier, character or numeric
`analyte` character data
`spike_value` numeric value
`spike_units` character data
`submission_date` character data that will be converted to date in format YYYY-MM-DD (for example 1999-12-31)
Optional for spike data:
`sv_unc` numeric, the uncertainty of the spike value. Default = 0
`sv_k` the coverage factor for the spike value uncertainty. Default = 2
`provider lab` character name of laboratory providing spiked samples
Required for laboratory results:
`sample_ID` must match spike `sample_ID`
`analyte` must match spike `analyte`
`result` numeric value
`units` must match `spike_units`
`result_date`
`det_lvl` numeric detection level
`unc` numeric uncertainty of the laboratory result
#' Optional for lab data:
`k` the coverage factor for the result uncertainty. Default = 2
Note that the two data sets (spike values and laboratory results) will be combined by `sample_ID`, and also by `analyte` if present in both sets. (If the laboratory data includes a non-zero result for an analyte not present in the spike data, that would indicate a false positive.)
Use this function to load the spike data and establish a data frame named `bs_df`. All plotting and data analysis functions will default to look for this data set.
example_spike_data <- system.file("extdata", "spikevals.csv", package = "blindspiker")
example_lab_data <- system.file("extdata", "labvals.csv", package = "blindspiker")
example_df <- bs_prep_and_analysis(spike_data = example_spike_data, lab_data = example_lab_data)
Run the code above in your browser using DataLab