# Step 1: Set the working directory to the location where you want to save the CSV file
setwd("your_directory_path")
# Step 2: Create a data frame or use an existing one
data <- data.frame(
ID = c(1, 2, 3, 4, 5),
Name = c("John", "Alice", "Bob", "Eve", "Charlie"),
Age = c(25, 30, 22, 28, 35)
)
# Step 3: Specify the file path for the CSV file
file_path <- "output_file.csv"
# Step 4: Export the data frame to a CSV file
write.csv(data, file = file_path, row.names = FALSE)
# Step 5: Print a message indicating the successful export
cat("CSV file exported successfully to", file_path, "\n")