Last active
June 20, 2018 23:41
-
-
Save murraycadzow/6d76749f0f0cf07d0a81b49043382d82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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