This is a template file. The example included is not considered a good example to follow for Assignment 2. Remove this warning prior to submitting.

Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.

Original


Source: Alphametic (2020).


Objective

Explain the objective of the original data visualisation and the targetted audience.

The visualisation chosen had the following three main issues:

  • Briefly explain issue 1
  • Briefly explain issue 2
  • Briefly explain issue 3

Reference

Code

The following code was used to fix the issues identified in the original.

Load the required packages

library(ggplot2)
library(readr)
library(tidyr)

Load the data

df<-read_csv("data\\users_2022_sum.csv")

Change the countries to factors and order them by total users

df$Country <- factor(df$Country,                                    # 
                  levels = df$Country[order(df$X_sum, decreasing = FALSE)])

Put the data in a tidy format to work with ggolot

df_long<-pivot_longer(df,cols=2:9,names_to="engine",values_to="users")

Create the new plot

#theme_set(theme_grey())
user_plot <- ggplot(df_long, aes(Country,users)) + scale_fill_brewer(palette ="Spectral")
user_plot<-user_plot + geom_bar(aes(fill=factor(engine, 
                             levels=c("Google", 
                                      "bing",
                                      "Baidu",
                                      "Yahoo!",
                                      "Haosou",
                                      "Mail.ru",
                                      "Shenma",
                                      "YANDEX"))),
             stat="identity", 
             width = 0.8,
             col="black",
             position="stack")

Theme

user_plot<-user_plot + theme(axis.text.x = element_text(angle=0,face="bold", vjust=0.6),
                             axis.text.y = element_text(angle=0,face="bold", vjust=0.6),
                             plot.title = element_text(hjust=0.5, face="bold")
                             )

Labels

user_plot<-user_plot + labs(title = "Search Engine Usage by Country 2022",
       fill = "Search Engine",
       x = "Country",
       y = "Total Users in Millions",
       subtitle="Most Pop etc",
       caption="sources: name them"
       )

Flip the coordinates

user_plot<-user_plot +coord_flip() 
#user_plot

Data Reference

insider intelligence emarketer % users https://forecasts-na1.emarketer.com/5a32abf7e0cb1d0dd489d23c/5a32abede0cb1d0dd489d23b

Total Users https://forecasts-na1.emarketer.com/5a32abf7e0cb1d0dd489d23c/5b36a61281f26a07b4aa6c7a

Use both

Reconstruction

The following plot fixes the main issues in the original.