How to upload data from R into Google Sheets
Welcome back! R is a very powerful statistical programming language, you can bring data in, process it and export it out in many data formats (.CSV, .XLSX, etc.), some of you may not know this but you can actually export an R data frame straight into Google Sheets! This is how you do it!
Installation
First off, we want to install the Google Sheets 4 package, to do this, use the following installation line inside of your R console:
install.packages("googlesheets4")
Developing The Code
Awesome, next up we want to import that library and bring in a dataset into our R environment, you can bring in any data frame but in this case we’ll just make a sample one in R:
#IMPORTING THE LIBRARY
library(googlesheets4)#CREATING THE DATA FRAME
df = data.frame(matrix(rnorm(20), nrow=10))
Next up, we want to pretty much store this data into a new Google Sheet, to do this we want to use the following line of code:
(ss <- gs4_create("Sample R", sheets = df))
Let me explain this whole line of code. The ss is just a standard function within this package, the gs4_create function indicates that we’re going to be creating a new Google Sheet…