File Operations

Reading and writing text files:

# Writing to a file
writeLines("Hello, File!", "example.txt")

# Reading from a file
content <- readLines("example.txt")
print(content)

Handling CSV files:

# Reading a CSV file
data <- read.csv("data.csv")
head(data)

# Writing a CSV file
write.csv(data, "output.csv", row.names = FALSE)

Working with Excel files using readxl and writexl:

library(readxl)
library(writexl)

# Reading Excel
data <- read_excel("data.xlsx")
print(data)

# Writing Excel
write_xlsx(data, "output.xlsx")