You are on page 1of 2

Pie chart :

> slices <- c(7, 8,9, 10,11)

> lbls <- c("NA_Sales", "EU_Sales", "JP_Sales", "Other_Sales", "Global_Sales")

> pie(slices, labels = lbls, main="Pie Chart of Countries")

>pie3D(slices,labels=lbls,explode=0.1,
   main="Pie Chart of Countries ")

# Case 04: Create

# grouping by Genre and summarize

new_df <- games_dataset %>%

group_by(Genre) %>%

summarise(TotalSales = sum(JP_Sales))

#create pie chart

piechart <- ggplot(new_df,aes(x=Genre,y=TotalSales,fill=Genre)) +

geom_bar(stat='identity') +

coord_polar("y",start = 0)

piechart

#adding labels inside the slices

piechart <- ggplot(new_df,aes(x=Genre,y=TotalSales,fill=Genre)) +

geom_bar(stat='identity') +

coord_polar("y",start = 0)+

geom_text(aes(label = paste0(round(TotalSales,2), "%")),

position = position_stack(vjust = 0.5)) +

labs(title="Global Sales by Genre",

x= NULL,

You might also like