Skip to contents

This function allows you to read in sample files (.csv or .fcs) into a list, where each file is saved as a data.table object.

Usage

read.files(
  file.loc = getwd(),
  file.type = c(".csv", ".fcs"),
  files = NULL,
  nrows = NULL,
  do.embed.file.names = TRUE,
  header = TRUE
)

Arguments

file.loc

DEFAULT = getwd(). What is the location of your files?

file.type

DEFAULT = ".csv". What type of files do you want to read. Can be ".csv" or ".fcs".

files

DEFAULT = NULL. A vector of selected file names to import.

nrows

DEFAULT = NULL. Can specify a numerical target for the number of cells (rows) to be read from each file. Please note, order is random in FCS files.

do.embed.file.names

DEFAULT = TRUE. Do you want to embed each row (cell) of each file with the name name?

header

DEFAULT = TRUE. Does the first line of data contain column names? Only works for file.type = ".csv".

Value

Returns a list of data.tables – one per file.

References

Ashhurst, T. M., et al. (2019). https://www.ncbi.nlm.nih.gov/pubmed/31077106

Author

Thomas M Ashhurst, thomas.ashhurst@sydney.edu.au Felix Marsh-Wakefield, felix.marsh-wakefield@sydney.edu.au Givanna Putri

Examples

# download sample data
download.file(url='https://github.com/ImmuneDynamics/data/blob/main/msCNS.zip?raw=TRUE', destfile = 'msCNS.zip', mode = 'wb')
unzip(zipfile = 'msCNS.zip')
data.list <- read.files(file.loc = "msCNS/data", file.type = ".csv", do.embed.file.names = TRUE)
#> Reading CSV files...
#> Reading CNS_Mock_01.csv
#> Reading CNS_Mock_02.csv
#> Reading CNS_Mock_03.csv
#> Reading CNS_Mock_04.csv
#> Reading CNS_Mock_05.csv
#> Reading CNS_Mock_06.csv
#> Reading CNS_WNV_D7_01.csv
#> Reading CNS_WNV_D7_02.csv
#> Reading CNS_WNV_D7_03.csv
#> Reading CNS_WNV_D7_04.csv
#> Reading CNS_WNV_D7_05.csv
#> Reading CNS_WNV_D7_06.csv