| Start | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Importing .csv files Importing using base RComma separated value files (CSVs) can be imported using A user friendly option, Notes
Importing using packagesThe |
||||||||||||||||||
| Importing with data.table The Where argument
Notes
|
||||||||||||||||||
Exporting .csv files Exporting using base RData can be written to a CSV file using Commonly-specified parameters include Exporting using packages
|
||||||||||||||||||
Import multiple csv files This read every file and adds it to a list. Afterwards, if all data.frame have the same structure they can be combined into one big data.frame: |
||||||||||||||||||
| Importing fixed-width files Fixed-width files are text files in which columns are not separated by any character delimiter, like An example: Let's assume this data table exists in the local file Importing with base RNote:
Importing with readrNote:
|
||||||||||||||||||
| Importing .tsv files as matrices (basic R) Many people don't make use of Generally this is sufficient for most people. Sometimes it happens the matrix dimensions are so large that procedure of memory allocation must be taken into account while reading in the matrix, which means reading in the matrix line by line. Take the previous example, In this case
Similarly this file can be read line by line, There's also the Syntaxdata.table::fread(input, sep="auto", sep2="auto", nrows=-1L, header="auto", na.strings="NA", stringsAsFactors=FALSE, verbose=getOption("datatable.verbose"), autostart=1L, skip=0L, select=NULL, drop=NULL, colClasses=NULL, integer64=getOption("datatable.integer64"), # default: "integer64" dec=if (sep!=".") "." else ",", col.names, check.names=FALSE, encoding="unknown", strip.white=TRUE, showProgress=getOption("datatable.showProgress"), # default: TRUE data.table=getOption("datatable.fread.datatable") # default: TRUE ) Parameters
RemarksNote that exporting to a plain text format sacrifices much of the information encoded in the data like variable classes for the sake of wide portability. For cases that do not require such portability, a format like .RData (opens new window) or Feather (opens new window) may be more useful. Input/output for other types of files is covered in several other topics, all linked from Input and output (opens new window). |
Read Article
https://develop.horje.com/learn/1434/reference