#' read a ScanR data table
#'
#' Use \code{data.table::fread} to (quickly) load a parameter data file
#' generated by ScanR and run the usual operations that make it usable.
#'
#' This is a simple wrapper for fread from the package data.table.
#' It also uses some dplyr functions to modify the resulting data.table.
#' Some columns will be discarded. Usually the variables that are to be kept
#' will contain a specific pattern, e.g. an underscore (\code{_}).
#'
#' The \code{data.table} class is stripped from the object.
#'
#' @param path path to file
#' @param pattern regular expression to select variables to keep
#'
#' @return a data frame
#'
#' @export
#'
# #' @examples
# #' d <- read.delim('data/example_parameter_file.txt')
# #' dd <- freader('data/example_parameter_file.txt')
# #' ddd <- freader('data/example_parameter_file.txt', pattern = '_|green|red|black')
# #' head(d)
# #' head(dd)
# #' head(ddd)
#'
freader <- function(path, pattern = '_') {
x <- data.table::fread(path, check.names = TRUE)
x <- x[x$nuclei == 1, ]
names(x)[which(names(x) == 'Parent.Object.ID..Well.')] <- 'well'
x$well <- x$well + 1
x <- dplyr::select(x, 'well', dplyr::matches(pattern))
x <- data.frame(x, stringsAsFactors = FALSE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.