Guillawme/rfret

Implement config file to abstract column names out

Closed this issue · 3 comments

See examples here: https://www.r-bloggers.com/a-principle-of-writing-robust-r-program

With a config file mapping actual column names found in the csv files to generic names used in the functions (like "fret_channel"), the whole package will be much more generic.

Current idea to implement this:

  • store mappings between internal names and names from the data files in a JSON file;
  • on package loading, create a package-local environment and populate it with default column names;
  • in *_format_data functions, start by updating this environment with any column names provided by the user (make a dedicated internal function to do that);
  • make sure all column names used internally have a mapping to an actual column name (this should eliminate all warnings from devtools::check mentioning a global variable name not found).

Might need the lazyeval package.

Actually, needs the rlang package.

format_data() should start by checking column and sample type names and whether they match the currently loaded metadata (either provided or default).

As it is now without this check, and if the column or sample type names don't match the metadata, everything fails with a cryptic error.

This belongs to #44.