New release

7 views
Skip to first unread message

Rick

unread,
Mar 5, 2017, 3:00:17 PM3/5/17
to Data Management - watson
hi

A new release should appear tomorrow.

The main changes are in the chapter on Visualization (15).

Because dplyr and ggvis uses the pipe function, which breaks down a problem into simple steps, I have increased the focus on developing pipe and dplyr skills by
  • Using database access to  get a table (i.e., SELECT * FROM tablename)
  • Using dplyr and other R functions to process the data.
Here is an example

library(ggvis)

library(DBI)

library(dplyr)

library(lubridate)

conn <- dbConnect(RMySQL::MySQL(), "richardtwatson.com", dbname="ClassicModels", user="db1", password="student")

o <- dbGetQuery(conn,"SELECT * FROM Orders") 

od <- dbGetQuery(conn,"SELECT * FROM OrderDetails")

d <- inner_join(o,od)

d$month <- month(d$orderDate)

# Get the monthly value of orders

d2 <- d %>% group_by(month) %>% summarize(orderValue = sum(quantityOrdered*priceEach))

# Plot data orders by month

# Show the points and the line

d2 %>% ggvis(~month, ~orderValue/1000000) %>%  

  layer_lines(stroke:='blue') %>%

  layer_points(fill:='red') %>%

  add_axis('x', title = 'Month') %>%

  add_axis('y',title='Order value (millions)', title_offset=30)


I also fixed a few typos and errors as well.

Slides have been updated as well.

Cheers  

Rick

Reply all
Reply to author
Forward
0 new messages