Question
Need help with RStudio Read the national GDP file, which records GDP in millions, and count how many countries have a GDP greater than or
Need help with RStudio
Read the national GDP file, which records GDP in millions, and count how many countries have a GDP greater than or less than 10,000 million: http://people.terry.uga.edu/rwatson/data/GDP.csv.
library(ggvis)
library(readr)
url <- 'http://people.terry.uga.edu/rwatson/GDP.cvs'
t <- read_delim(url, delim=',')
trowcol <- ggvis(select GDP, country from t where GDP < 10000000 and GDP >10000000)
1. Show on a Google map the office locations in Honduras.
libray(ggplot)
library(ggmap)
library(mapproj)
library(DBI)
conn <- dbConnect(RMySQL::MySQL(), richardwatson.com,
dbname=ClassicModels, user=db1, password=student)
# Google maps requires lon and lat, in that order, to create markers
d <- dbGetQuery(conn,SELECT y(officeLocation) AS lon, x(officeLocation) AS lat FROM Offices;)
# show offices in Honduras
# vary zoom to change the size of the map
map <- get_googlemap(honduras,marker=d,zoom=4)
ggmap(map) + labs(x = Longitude, y = Latitude) + ggtitle(Hondura offices)
2. Show on a Google map the university locations in North Carolina.
libray(ggplot)
library(ggmap)
library(mapproj)
library(DBI)
conn <- dbConnect(RMySQL::MySQL(), richardwatson.com,
dbname=ClassicModels, user=db1, password=student)
# Google maps requires lon and lat, in that order, to create markers
d <- dbGetQuery(conn,SELECT y(universityLocation) AS lon, x(universityLocation) AS lat FROM University;)
# show university locations in North Carolina
# vary zoom to change the size of the map
map <- get_googlemap(NC,marker=d,zoom=4)
ggmap(map) + labs(x = Longitude, y = Latitude) + ggtitle(NC university locations)
3. Show on a Google map the residential communities in Charlotte, NC.
libray(ggplot)
library(ggmap)
library(mapproj)
library(DBI)
conn <- dbConnect(RMySQL::MySQL(), richardwatson.com,
dbname=ClassicModels, user=db1, password=student)
# Google maps requires lon and lat, in that order, to create markers
d <- dbGetQuery(conn,SELECT y(communityLocation) AS lon, x(communityLocation) AS lat FROM Communities;)
# show residential communities in Charlotte,NC
# vary zoom to change the size of the map
map <- get_googlemap(Charlotte,NC,marker=d,zoom=4)
ggmap(map) + labs(x = Longitude, y = Latitude) + ggtitle(Charlotte,NC residential communities)
4. Take the recent annual reports for UPS and convert them to text using an online service, such as http://www.fileformat.info/convert/doc/pdf2txt.htm. Undertake a cluster analysis, identify which reports are similar in nature, and see if you can explain why some reports are in different clusters.
require(ggplot2)
require(ggdendro)
#name the columns for the report's year
colnames(tdm) <- 2008:2012
#remove sparse terms
tdm1 <- removeSparseTerms(tdm, 0.5)
#transpose the matrix
tdmtranspose <- t(tdm1)
cluster = hclust(dist(tdmtranspose),method='centroid')
#get the clustering data
dend <- as.dendrogram(cluster)
#plot the tree
ggdendrogram(dend,rotate=T)
5. Build a topic model for the annual reports.
library(topicmodels)
library(slam)
dim(tdm)
# calculate tf-idf for each term
tfidf <- tapply(dtm$v/row_sums(dtm)[dtm$i], dtm$j, mean) * log2(nDocs(dtm)/col_sums(dtm > 0))
# report dimensions (terms)
dim(tfidf)
# report median to use as cut-off point
median(tfidf)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started