10. Reading and Writing External Data

Import of tabular data

Import of Excel file. Note: working with tab- or comma-delimited files is more flexible and preferred.

library(gdata)myDF<-read.xls"myData.xls")

Import of Google Sheets. The following example imports a sample Google Sheet from here.
Detailed instructions for interacting from R with Google Sheets with the required googlesheets package are here.

library("googlesheets");library("dplyr");library(knitr)gs_auth()# Creates authorizaton token (.httr-oauth) in current directory if not present
sheetid<-"1U-32UcwZP1k3saKeaH1mbvEAOfZRdNHNkWK2GI1rpPM"gap<-gs_key(sheetid)mysheet<-gs_read(gap,skip=4)myDF<-as.data.frame(mysheet)myDF