R/readcsvtable.R

Defines functions ReadCsvTable

#' Read CSV File as Table.
#' \code{ReadCsvTable} reads a CSV file and turns the first column into row names.table in where the first row and column contain labels.
#' @param file A path and file name.
#' @param as.is Prevents factors from automatically being created (see \code{\link[utils]{read.csv}})
#' @param ... Further arguments to be passed to read.csv
#' @return A \code{\link[base]{data.frame}} containing a representation of the data in the file.
#' @importFrom utils read.csv
#' @export
ReadCsvTable <- function(file, as.is = TRUE, ...){
  # Reads a table in where the first row and column contain labels
  #
  # Args:
  #   file: file name and path
  # Returns: matrix or data.frame
  #
  x = read.csv(file, as.is = as.is, ...)
  row.names(x) = x[,1]
  x = x[,-1]
  x
}



#####'''#' @examples
#####'''#' dataset <- system.file("extdata", "Cola_perceptions.csv", package="flip")
#####'''#' ReadCsvTable(dataset)
Displayr/flipExampleData documentation built on March 26, 2024, 12:20 a.m.