Online Learning Platform

Data Analysis > Reading Data in R > Saving data from a DataFrame to Excell

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)

 

Prev
Remove and Rename variables

No More

Feedback
ABOUT

Statlearner


Statlearner STUDY

Statlearner