Search code examples
rstatisticsdatasetexport-to-csv

How to save R datasets(eg: datasets from libraries like MASS, ISLR, etc.,) to a csv file


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.


Solution

  • 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")