Let's learn How to Export Data to R. When we acquire the data, we do it with intention of processing it and then exporting it for the user. Here user can either use it to visualize to make decision. And in some other cases the user can use that output to read through other software.
So in such case we are going to take a look at one use case where we basically export the dataframe to CSV file.
You can take a look at the Video instruction of the tutorial - How to Export Data to CSV File in R.
Let's create a data frame before we can export the data.
df <- data.frame("No" = 1:2, "Age" = c(21,31), "Name" = c("Abbey","Bob"))
Here we have df as our dataframe variable name. And we have this data of two people where we have number, age and name of those people. You can add more if you wish but I am limiting this to two for simplicity. You can also make use of the external data source.
Now let's export this data to CSV.
write.csv(df,'D\csvData.csv', row.names = FALSE)
Here we are making use of the write.csv() method. And this is built into the R language. So we are not using any external library to accomplish this. We are also passing the path where the file is stored.
So say you have D: drive where you want this file named csvdata.csv to be stored there. And finally row.names = FALSE is set that way because we are already passing the row specific data through dataframe so no need to specify them.
If you check the path, you'd find the file named csvdata.csv.
That's it. You have now managed to export the data from the dataframe to the CSV file using R language.
Single Responsibility Principle (or SRP) is one of the most important concepts in software development. The main idea of this concept is: all pieces of software must have only a single responsibility.