Import Data, and set variable type as either character or numeric

library(readxl)
Yelp_Dataset_Copy <- read_excel("Yelp Dataset - Copy.xlsx",col_types = c("text", "numeric", "numeric", "numeric", "text", "text", "text", "numeric", "numeric"))


#Randomly pick up 2000 samples and use set.seed(123) function to make result repeatable.
set.seed(123)
yelp <- Yelp_Dataset_Copy[sample(nrow(Yelp_Dataset_Copy), 2000),]

Plot1: Business Category

library(ggplot2)
pie <- ggplot(yelp, aes(x = "", y=yelp$Open, fill = factor(yelp$`Business Category`))) + 
  geom_bar(width = 1, stat = "identity") +
  scale_fill_brewer(type = "seq", palette = "Set3", direction = 1) +
  theme(axis.line = element_blank(), 
        plot.title = element_text(hjust=0.5)) + 
  labs(fill="Business type", 
       x=NULL, 
       y=NULL, 
       title="Pie Chart of Business on Yelp", 
       caption="Yelp Business Categories")
pie + coord_polar(theta = "y", start=0)

# Plot2: Stars of review

ggplot(yelp, aes(x=yelp$Stars)) + 
  geom_bar() +
  xlab("Stars")+
  ylab("Count") + 
  labs(title="Stars of Review")

#Plot 3: Map #reference:https://amunategui.github.io/ggmap-example/

library(ggplot2)
library(ggmap)
map<-get_map(location='united states', zoom=4, maptype = "terrain",
             source='google',color='color')
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=united+states&zoom=4&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false
## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=united%20states&sensor=false
ggmap(map) + geom_point(data = yelp, aes(x = yelp$Longitude, y = yelp$Latitude), size = 0.5, col = "red") + 
  labs(title = "Dot Map of Reviews",
       x = "  ",
       y = "  ")
## Warning: Removed 73 rows containing missing values (geom_point).

#Plot 4: Review Counts

plot(yelp$Review_Count, yelp$Stars, main = "Scatterplot of x1 vs. y1", type = 'p', col = 'red', pch = 16)

qplot(yelp$Stars, yelp$Review_Count, data = yelp)