Saving data from a DataFrame to Excell
Suppose we want to save datafile in my own folder, so set the working directory.
setwd("/Users/mdfazlulkarimpatwary/documents/Rtraining/")
The associated package need to be loaded.
library(openxlsx)
"mtcars" is the default dataset as a dataframe. So lets try on it.
>head(mtcars)

>str(mtcars)
What you can see?
> mtcars[1:5,]
> mtcars[1:5,1:4]
> mtcars[,1:3]
write.xlsx(mtcars, file="mtcars.xlsx")
The above command will save a datafile named “mtcars.xlsx” if you don’t want to export column names the command is
write.xlsx(mtcars, file="mtcars.xlsx",colnames=FALSE)
No More
Statlearner
Statlearner