How to extract the datasets that are provided in r libraries into csv files. Faced this issue when trying to implement R related data analysis programs in python.
How to extract the datasets that are provided in r libraries into csv files. Faced this issue when trying to implement R related data analysis programs in python.
First you can make sure the data is loaded from the package with data() and then write it out with write.csv
data(Boston, package = "MASS")
write.csv(Boston, "Boston.csv")
If you want to save the "Boston" dataset that is available in the "MASS" library in R to a csv, and if the library() function is already called in your code like this:
library(MASS)
then, simply use the below line:
write.csv(Boston, "Boston.csv")