Journocoders January 2019

An introduction to analysing data and text with R


Show and tell

Read anything related to data or journalism recently? Please add links here! Stories, analysis, announcements -- anything you think others might be interested in.


Tutorial

You will need a couple of packages installed before starting the tutorial. To do this inside R Studio enter:

install.packages(c('tidyverse', 'tidytext', 'maps'))

It might take a few minutes to complete. You will also need to download the data from here. Then you need to tell R Studio where to look for the data. In the folders list on the bottom right of the R Studio window find the winemag-data.csv file you just downloaded, then click the More button just above, and then Set As Working Directory.


You can fix the incorrect character in 'Rhône Valley' by adding encoding = "UTF-8" to the read.csv parameters:
dataset <- read.csv("winemag-data.csv",
                    header = TRUE,
                    stringsAsFactors = FALSE,
                    encoding = "UTF-8")

If you are having a problem with this bit

counts <- francewines %>% 
group_by(province) %>% 
summarise(lat = lat, lon = lon, count = n(),
            mean_price = mean(price, na.rm = TRUE),
            mean_points = mean(points)) 
counts %>% glimpse()

Replace it with this

counts <- francewines %>% 
  group_by(province) %>% 
  summarise(lat = mean(lat), lon = mean(lon), count = n(),
            mean_price = mean(price, na.rm = TRUE),
            mean_points = mean(points)) 

Next time

The next Journocoders meetup will be on Thursday 14th February at the News Building.

What should we cover? Anything we should or shouldn’t be doing? We want your ideas!