I am new to R and ggplot2, after a lot of struggle, watching videos and going through various open source sites I have created bar chart for my data.
My data has four columns i.e. Items, Quantity_2001, Quantity_2011 and Change. There are 11 different items with no missing vales. I want to create a side-by-side bar chart where each 'Item' will have three bars: one bar for 2001, one bar for 2011 and one bar for Change. I have managed to create one using the following set of commands:
So there are three bars for each item, for example 'Item1' has three bars one each for 2001, 2011 and change and so on for all 11 items. However, with the above command, the bars for each item in the chart appear first for 2011, then for 2001 and then change. I want bar for 2001 to appear first, then 2011 and then change. Please let me know if there is a way I can manually reorder the bars.
Thank you very much, this worked. One more question, is there a way to change the names of items on x-axis from 'A', 'B', 'C', to the proper names of item in my data and changing color of the bars.
I used the letters only as a convenience since I do not know how your Items are named. You should be able to use my code with your data frame except in the factor() function the levels should be
Thank you again. My items include agri commodities like rice, maize etc. When I use rep(LETTERS[1:14] the chart I get is correct. However, when I try to replace the LETTERS A, B, C using the following code I get an error which says Error in LETTERS["Maize", "Rice_paddy", "Beans_dry", "Seed_cotton", "Cassava", incorrect number of dimensions
Because you are new to R and the Tidyverse I'm going to recommend R for Data Science. It has helped me get a better understanding of the basics and helped me narrow down my internet search queries for the times when I need to find an example of what I'm trying to accomplish. Find the book here: