dwt <- c(2566, 3704, 4008, 5984, 7700, 8034, 8229, 7858, 8408, 8939)
year <- c(1970, 1980, 1990, 2000, 2006, 2007, 2008, 2009, 2010, 2011)
library(ggvis)
dwt <- c(2566, 3704, 4008, 5984, 7700, 8034, 8229, 7858, 8408, 8939)
year <- c(1970, 1980, 1990, 2000, 2006, 2007, 2008, 2009, 2010, 2011)
df1 <- data.frame(year, dwt)
df1 %>% ggvis(~year,~dwt) %>% layer_points(fill:='red') %>%
layer_model_predictions(model = 'lm') %>%
add_axis('x',title='Year', format='####') %>%
add_axis('y',title='Millions of dead weight tons', title_offset=50) %>%
scale_numeric('y',zero=T)
library(ggvis)
library(DBI)
# connect to the database
conn <- dbConnect(RMySQL::MySQL(),"wallaby.terry.uga.edu", dbname = "ClassicModels", user = "student", password = "student")
# Query the database and create file for use with R
d <- dbGetQuery(conn,"SELECT productScale from Products;")
# Plot the number of product lines by specifying the appropriate column name
# Internal fill color is blue
d %>% ggvis(~productScale) %>% layer_bars(fill:='blue') %>%
add_axis('x',title='Product scale') %>%
add_axis('y',title='Frequency')
library(ggvis) library(DBI) # connect to the database conn <- dbConnect(RMySQL::MySQL(),"wallaby.terry.uga.edu", dbname = "ClassicModels", user = "student", password = "student") # Query the database and create file for use with R d <- dbGetQuery(conn,"SELECT country, sum(quantityOrdered*priceEach) AS orders FROM Orders, OrderDetails, Customers WHERE Orders.orderNumber = OrderDetails.orderNumber and Customers.customerNumber = Orders.customerNumber AND country IN ('Denmark','Finland', 'Norway','Sweden') GROUP BY country") d %>% ggvis(~country,~orders) %>% layer_bars(fill:='yellow') %>% add_axis('x',title='Country') %>% add_axis('y',title='Orders',title_offset = 60)
library(ggplot2) library(DBI) library(ggmap) # connect to the database conn <- dbConnect(RMySQL::MySQL(),"wallaby.terry.uga.edu", dbname = "ClassicModels", user = "student", password = "student") # Query the database and create file for use with R d <- dbGetQuery(conn,"SELECT y(officeLocation) AS lon, x(officeLocation) AS lat FROM Offices;") map <- get_googlemap('tokyo, japan',marker=d,zoom=5) ggmap(map) + labs(x = 'Longitude', y = 'Latitude') + ggtitle('Japanese offices')
library(ggvis) library(readr) url <- 'http://people.terry.uga.edu/rwatson/data/manheim.txt' t <- read_delim(url, delim=',') t %>% ggvis(~model) %>% layer_bars(fill:='lightgreen')
library(ggvis) url <- 'http://people.terry.uga.edu/rwatson/data/wealth.csv' t <- read_delim(url, delim=',') t %>% ggvis(~`GDP per capita`) %>% layer_histograms(fill:='Crimson') t %>% ggvis(~`Wealth per capita`) %>% layer_histograms(fill:='DarkOrange') t %>% ggvis(~`Wealth per adult`) %>% layer_histograms(fill:='DarkSeaGreen')
This page is part of the promotional and support material for Data Management (open edition) by Richard T. Watson |