Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```{r A11}
- library(tidyverse)
- library(janitor)
- library(googleVis)
- #Read the file <http://www.richardtwatson.com/data/InternetCompanies.csv> containing data about Internet companies.
- #warnings setting off
- oldw <- getOption("warn")
- options(warn = -1)
- url<-'http://www.richardtwatson.com/data/InternetCompanies.csv'
- w<-read_csv(url)
- #Cleaning the file
- w$MarketCap<-str_extract(w$MarketCap,"[\\d,.]+")%>%as.numeric()
- w$Cash<-str_extract(w$Cash,"[\\d,.]+")%>%as.numeric()
- w$Revenue<-str_extract(w$Revenue,"[\\d,.]+")%>%as.numeric()
- w<-w[1:5,]
- w
- # Use ggplot2 to create a point graph of market capitalization versus revenue for the five largest companies by market capitialization and label each point with the company's name.
- ggplot(w, aes(MarketCap, Revenue,label=Company)) + geom_point(color='salmon') +
- xlab('Market Capitalization') + ylab('Revenue') + ylim(0, 300) +
- geom_text(aes(label=Company), vjust= 2)
- w
- #Use googleVis to create a bubble chart for the same set of companies.
- Bubble <- gvisBubbleChart(w, idvar="Company",
- xvar="MarketCap", yvar="Revenue",
- sizevar="Cash", colorvar = "Country"
- )
- plot(Bubble)
- #Submit a markdown file with all code and a screen shot of the bubble chart.
- #normal warning setting
- options(warn = oldw)
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement