Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save murraycadzow/6d76749f0f0cf07d0a81b49043382d82 to your computer and use it in GitHub Desktop.
Save murraycadzow/6d76749f0f0cf07d0a81b49043382d82 to your computer and use it in GitHub Desktop.
---
title: "gs webscrape"
author: "Murray Cadzow"
---
for how to get googlesheets setup first take a look here:
https://github.com/murraycadzow/r_googlesheets_lesson
```{r}
library(here)
library(googlesheets)
library(tidyverse)
# will look for the httpoauth file in the project root
here::here()
```
```{r}
if(gs_ls() %>% filter(sheet_title == "webscrape") %>% NROW() == 0){
gs_new(title = "webscrape")
}
ws <- gs_title("webscrape")
```
```{r}
gs_edit_cells(ss = gs_key(ws$sheet_key), ws = 1, input = '=IMPORTHTML("http://en.wikipedia.org/wiki/Demographics_of_New_Zealand", "table", 2)')
```
```{r}
gs_read(ss = gs_key(ws$sheet_key), skip = 1)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment