It's always better to write CSV with R after data preparation or cleaning in order to save the data for further analysis and to share with others.
Before writing any data frame or matrix to CSV, check the default working directory of your machine by the following command:
You can change your default working directory by the following command:
As an example lets say you have a data frame:
Now suppose you have cleaned or prepared the data frame, and you want to save the data frame. You can do that by the following command: