parseTable.elabftw: Parse Tables With References To Files On eLabFTW

View source: R/parseTable_elabftw.R

parseTable.elabftwR Documentation

Parse Tables With References To Files On eLabFTW

Description

This function processes tables generated by the GET.elabftw functions. If the resulting tables contain paths to files stored in the online labbook elabFTW this function will fetch the corresponding files via the eLabFTW API and reduces each file into a single value by applying a fully customisable function (e.g. mean, sum, ...). This function expects the files to be tables. The files will be converted into tables with read.csv(). The result is the initial list of tables with the file paths replaced by the corresponding values.

Usage

parseTable.elabftw(
  parseableTables,
  func,
  extension = ".csv",
  api.key = Sys.getenv("READ_ELABFTW_TOKEN"),
  url = Sys.getenv("ELABFTW_API_URL"),
  outputHTTP = F,
  ...
)

Arguments

parseableTables

A list generated by GET.elabftw functions with outputHTTP=TRUE. The list contains a list of data.frames with file references and the HTTP response from the API request.

func

Any function that takes a data.frame as input and returns a single value. Apply mean to a single column for example.

extension

One string or a vector of strings with file extensions that will be recognised by the function. Any other file type will be ignored.

api.key

The eLabFT API-key. See the eLabFTW documentation for details. The default settings retrieve this value from the enviourmental variable READ_ELABFTW_TOKEN. This variable can be set in the ~/.Renviron file.

url

The url to the eLabFTW API. See the eLabFTW documentation for details. The default settings retrieve this value from the enviourmental variable ELABFTW_API_URL. This variable can be set in the ~/.Renviron file.

outputHTTP

Boolean value. If FALSE only the data frames will be returned. If TRUE the data frames and the http response received from the API in a GET.elabftw function will be returned. The http response contains meta information needed by other parsing functions, like this function.

...

Parameters that will be passed to read.csv().

Details

Keep in mind: This functions needs the original HTTP API response. Therefore set the parameter outputHTTP to TRUE when calling a GET.elabftw function.

Value

The original list of data frames with the file paths replaced by the content of files from the online labbook eLabFTW. If outputHTTP is set TRUE the return value is a list containing the list of data frames and the original http response that was passed in the parseableTables parameter.


AlreadyTakenJonas/RHotStuff documentation built on Oct. 28, 2022, 10:15 p.m.