In an R script upload a spreadsheet, manipulate the data by removing column/variable, change variable name, and pivot columns, and then producing a bar chart.
Timings:
00:00 Intro - How to create bar chart in R (ggplot2)
00:40 Set up R script and load data
02:10 Remove a column/variable from the database
03:20 Change column/variable header name
04:35 Set order of category (change from default alphabetical)
07:20 Pivot using pivot_longer (tidyr package)
10:10 Set up bar chart (ggplot2 package)
13:00 Add labels to bar chart
15:10 Themes (theme()) changes to bar chart
19:00 Change colour of bars/columns.
The video mentioned at 3.10 relating to altering the number of observations/variables (rows/columns) can be found at https://youtu.be/gkE5hToDFJg
There is a lot more alterations which can be done to the bar chart using ggplot2. A reference which you may find helpful - https://ggplot2.tidyverse.org/reference/index.html. This also explains why geom_col is used in this video, rather than geom_bar - ie it is because want height of bars to represent the values in the data.
The excel spreadsheet used in this project can be found at https://dataforknowledge.co.uk/r-project-create-bar-chart/
Note: 3rd party data was used in this project therefore I take no responsibility for the quality or accuracy of the data. The data can be found at https://www.gov.scot/publications/teacher-census-supplementary-statistics/
** SUBSCRIBE **
Like and subscribe for more R tutorials! http://www.youtube.com/@DFK_data
** PLAYLISTS **
R programming: https://www.youtube.com/playlist?list=PL856L03J0TRzutyNPb5yD2glKnrcWKpFm
** FOLLOW ME **
LinkedIn: www.linkedin.com/in/pauline-cairns-data
#rprogramming #barchart #ggplot2 #rproject #data #ggplot2barchart