R Data Import/Export

R provides functions to import and export data from various formats such as CSV, Excel, and text files. Common functions include read.csv() for reading CSV files and write.csv() for exporting data.

Key Topics

Importing Data

# Reading a CSV file
data <- read.csv("path/to/your/file.csv")

head(data)

Note:

Use head() to view the first few rows of the imported data.

Exporting Data

# Writing data to a CSV file
write.csv(data, "path/to/your/output.csv")

Note:

Use write.csv() to export data to a CSV file.

Key Takeaways

  • Use read.csv() to import data from a CSV file.
  • Use write.csv() to export data to a CSV file.
  • Data can be imported/exported in various formats, depending on your needs.