Abstract
In the process of learning programming, utilizing well-organized cheatsheets is a valuable technique. This "Data Import/Export in R" cheatsheet offers a quick reference guide for efficiently handling different file types in R. It covers importing and exporting CSV, TXT, XLS, XLSX, TSV, RDS, RDA, JSON, XML, images (JPG/PNG/TIFF/BMP), audio (MP3), video (MP4), HDF5, and netCDF files. Each slide provides concise R code for reading and writing specific file formats. This cheatsheet aims to empower learners with the necessary knowledge to manipulate and analyze diverse datasets effectively using R's data import/export capabilities. |
Introduction
R is a powerful programming language for data analysis. |
Efficient data import/export is crucial for data manipulation and analysis. |
This cheatsheet provides quick reference on reading/writing various file types in R. |
Conclusion
Proper data import/export enhances R's data analysis capabilities. |
Use this cheatsheet as a handy reference guide in your R programming journey. |
Thank You
Thank you for using this "Data Import/Export in R" cheatsheet. |
For more resources, visit my website[https://vccv.cc]. |
|
|
CSV
Import |
Export |
read.csv(file, header = TRUE, sep = " ", comment.char = "", ...)
|
write.csv(x, file = "", append = FALSE, sep = " ", row.names = TRUE, ...)
|
File: the name of the file which the data are to be read from. |
X: the object to be written, preferably a matrix or data frame. |
TXT
Import |
Export |
read.table(file, header = TRUE, sep = " ", comment.char = "", ...)
|
write.table(x, file = "", append = FALSE, sep = " ", row.names = TRUE, ...)
|
File: the name of the file which the data are to be read from. |
X: the object to be written, preferably a matrix or data frame. |
Code: read.table(file, header=TRUE) |
Code: write.table(x, export.txt) |
Video/HDF5/netCDF
Video |
HDF5 |
Read Video: videoplayR::readMP4()
|
Read HDF5: hdf5r::h5read()
|
Write Video: videoplayR::writeMP4()
|
Write HDF5: hdf5r::h5write()
|
netCDF |
Read netCDF: ncdf4::nc_open()
|
Write netCDF: ncdf4::ncvar_put()
|
|
|
TSV/RDS/RDA
TSV |
RDS |
RDA |
|
|
|
Write TSV: write.table()
|
|
JSON/XML
JSON |
XML |
Read JSON: jsonlite::fromJSON()
|
Read XML: XML::xmlTreeParse()
|
Write JSON: jsonlite::toJSON()
|
Write XML: XML::saveXML()
|
XLS/XLSX
XLS |
XLSX |
Read XLS: readxl::read_excel()
|
Read XLSX: readxl::read_xlsx()
|
Write XLS: writexl::write_xlsx()
|
Write XLSX: writexl::write_xlsx()
|
Image/Audio
Image |
Audio |
Read Images: jpeg::readJPEG()
, png::readPNG()
, tiff::readTIFF()
, bmp::readBMP()
|
Read Audio: tuneR::readMP3()
|
Write Images: jpeg::writeJPEG()
, png::writePNG()
, tiff::writeTIFF()
, bmp::writeBMP()
|
Write Audio: tuneR::writeMP3()
|
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment