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

Time:09-13

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.

CodePudding user response:

If you want to save the "Boston" dataset that is available in the "MASS" library in R to a csv, do the following:

library(MASS)
attach(Boston)
b<-cbind(Boston)
write.csv(b, "Boston.csv")

CodePudding user response:

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