Analytics Log - Adil Khan

View Original

How To Export Google Analytics Data From R Studio To Excel

Alright, so in the first R project related post, I looked at analyzing Google Analytics data for my blog based on day of week [via geom_boxplot]

The next question that popped up was ...ok, great...I have the data loaded and the visualization...what if I still wanted this in Excel? How would I go about it?

Note: I have a feeling most of these blog posts will be based on finding answers to questions that pop up as I move along with R.

The below script uses the gadata boxplot we created. Once the dataframe is ready to be exported, install the "xlsx" package and run the library.

Saving Excel file to default folder in R Studio

This bit of the code creates a file "mygadata20180526" and saves it in the default folder for R. In my case, the Documents folder. If you'd like it to save to a particular folder, write out the

 

See this content in the original post

Saving Excel file to a specific folder in R Studio

If you'd like to save it to a specific folder of your choice, you'd change the save query to:

See this content in the original post

 


 

And that's it.

To change the default save folder, you'd go to R Studio > Tools > Global Options

 

See this content in the original post

 

This one is pretty straight forward.

Source to answer: http://www.sthda.com/english/wiki/writing-data-from-r-to-excel-files-xls-xlsx

See this form in the original post