Skip to content

Commit

Permalink
cleaner approach to managing the data with Git
Browse files Browse the repository at this point in the history
  • Loading branch information
ellisp committed Sep 9, 2017
1 parent 8b85d43 commit 41e67e7
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 9 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,4 @@ vignettes/*.pdf



webrear.zip
data/all-data.csv
*.xlsx
2 changes: 1 addition & 1 deletion build.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ source("prep/download-mrtes.R")
# load in the data (not really necessary)
load("data/mrtes.rda")

# buidl the report. Note that the build will happen in the user's home directory (~).
# build the actual report. Note that the build will happen in the user's home directory (~).
build_doc(subdir = "report-1")

Binary file removed data/mrtes.rda
Binary file not shown.
1 change: 1 addition & 0 deletions data/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
holds both original data (eg .xlsx) and persistent versions of R data (.rda). But these are ignored by Git, this is just for your local clone.
8 changes: 5 additions & 3 deletions prep/download-mrtes.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
url <- "http://www.mbie.govt.nz/info-services/sectors-industries/tourism/tourism-research-data/monthly-regional-tourism-estimates/document-image-library/international-product-by-rto.xlsx"

# Only download the file if we haven't already done it as I don't want to cause unnecessary network traffic
if(!file.exists("mrtes.xlsx")){
download.file(url, destfile = "mrtes.xlsx", mode = "wb")
if(!file.exists("data/mrtes.xlsx")){
download.file(url, destfile = "data/mrtes.xlsx", mode = "wb")
}

mrtes_orig <- read.xlsx("mrtes.xlsx", sheet = "Data base", detectDates = TRUE)
mrtes_orig <- read.xlsx("data/mrtes.xlsx", sheet = "Data base", detectDates = TRUE)

# make some alternative names for the Regional Tourism Organisations, more grpahic friendly,
# including one that is just the 5 big ones plus "Other":
mrtes <- mrtes_orig %>%
mutate(rto_short = gsub(" RTO", "", RTO),
rto_lumped = fct_reorder(rto_short, -Spend),
Expand Down
6 changes: 6 additions & 0 deletions report-1/report.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ We see a very strong seasonal pattern, and also that people spend a lot on accom

```{r}
p <- mrtes %>%
# make products friendly with line wraps for the facet titles:
mutate(Product = str_wrap(Product, 20)) %>%
# add up all the "others""
group_by(Date, Product, rto_lumped) %>%
summarise(Spend = sum(Spend)) %>%
ungroup() %>%
mutate(rto_lumped = fct_reorder(rto_lumped, -Spend)) %>%
ggplot(aes(x = Date, y = Spend, colour = rto_lumped)) +
facet_wrap(~Product, scales = "free_y") +
theme(legend.position = c(0.9, 0.1)) +
Expand Down
6 changes: 3 additions & 3 deletions report-1/report.html

Large diffs are not rendered by default.

0 comments on commit 41e67e7

Please sign in to comment.