Hello people, i would like to ask you how to create a Barplot with ggplot, where i show the production of an element in 2 diferents years for a same country
I'm using this Dataset: data.world
Thanks in advance
Hello people, i would like to ask you how to create a Barplot with ggplot, where i show the production of an element in 2 diferents years for a same country
I'm using this Dataset: data.world
Thanks in advance
Your data link asks for log in credentials. Please post some data here. If your data frame is named DF, you can display 20 rows of data by posting the output of
dput(head(DF, 20))
Place a line with three back ticks just before and after the pasted output of dput(), like this
```
output of dput() goes here
```
structure(list(Area.Code = c(8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L), Area = c("Antigua and Barbuda",
"Antigua and Barbuda", "Antigua and Barbuda", "Antigua and Barbuda",
"Antigua and Barbuda", "Antigua and Barbuda", "Antigua and Barbuda",
"Antigua and Barbuda", "Antigua and Barbuda", "Antigua and Barbuda",
"Antigua and Barbuda", "Antigua and Barbuda", "Antigua and Barbuda",
"Antigua and Barbuda", "Antigua and Barbuda", "Antigua and Barbuda",
"Antigua and Barbuda", "Antigua and Barbuda", "Antigua and Barbuda",
"Antigua and Barbuda"), Item.Code = c(486L, 486L, 486L, 414L,
414L, 414L, 358L, 358L, 358L, 426L, 426L, 426L, 125L, 125L, 125L,
401L, 401L, 401L, 397L, 397L), Item = c("Bananas", "Bananas",
"Bananas", "Beans, green", "Beans, green", "Beans, green", "Cabbages and other brassicas",
"Cabbages and other brassicas", "Cabbages and other brassicas",
"Carrots and turnips", "Carrots and turnips", "Carrots and turnips",
"Cassava", "Cassava", "Cassava", "Chillies and peppers, green",
"Chillies and peppers, green", "Chillies and peppers, green",
"Cucumbers and gherkins", "Cucumbers and gherkins"), Element.Code = c(5312L,
5419L, 5510L, 5312L, 5419L, 5510L, 5312L, 5419L, 5510L, 5312L,
5419L, 5510L, 5312L, 5419L, 5510L, 5312L, 5419L, 5510L, 5312L,
5419L), Element = c("Area harvested", "Yield", "Production",
"Area harvested", "Yield", "Production", "Area harvested", "Yield",
"Production", "Area harvested", "Yield", "Production", "Area harvested",
"Yield", "Production", "Area harvested", "Yield", "Production",
"Area harvested", "Yield"), Unit = c("ha", "hg/ha", "tonnes",
"ha", "hg/ha", "tonnes", "ha", "hg/ha", "tonnes", "ha", "hg/ha",
"tonnes", "ha", "hg/ha", "tonnes", "ha", "hg/ha", "tonnes", "ha",
"hg/ha"), Y1961 = c(NA, NA, NA, 1, 40000, 4, 2, 40000, 8, 1,
30000, 3, 3, 33333, 10, NA, NA, NA, 1, 20000), Y1961F = c("",
"", "", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F",
"Fc", "F", "", "", "", "F", "Fc"), Y1962 = c(NA, NA, NA, 1, 40000,
4, 3, 33333, 10, 1, 50000, 5, 4, 30000, 12, NA, NA, NA, 1, 30000
), Y1962F = c("", "", "", "F", "Fc", "F", "F", "Fc", "F", "F",
"Fc", "F", "F", "Fc", "F", "", "", "", "F", "Fc"), Y1963 = c(NA,
NA, NA, 2, 30000, 6, 3, 40000, 12, 2, 40000, 8, 5, 28000, 14,
1, 30000, 3, 1, 40000), Y1963F = c("", "", "", "F", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F",
"F", "Fc"), Y1964 = c(NA, NA, NA, 2, 40000, 8, 4, 37500, 15,
2, 50000, 10, 6, 26667, 16, 1, 50000, 5, 1, 60000), Y1964F = c("",
"", "", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F",
"Fc", "F", "F", "Fc", "F", "F", "Fc"), Y1965 = c(NA, NA, NA,
2, 50000, 10, 5, 40000, 20, 2, 50000, 10, 7, 25714, 18, 2, 40000,
8, 1, 80000), Y1965F = c("", "", "", "F", "Fc", "F", "F", "Fc",
"F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc"
), Y1966 = c(3, 16667, 5, 2, 50000, 10, 5, 40000, 20, 2, 50000,
10, 8, 25000, 20, 2, 50000, 10, 2, 50000), Y1966F = c("F", "Fc",
"F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc",
"F", "F", "Fc", "F", "F", "Fc"), Y1967 = c(6, 13333, 8, 5, 40000,
20, 7, 42857, 30, 3, 50000, 15, 12, 25000, 30, 3, 46667, 14,
4, 50000), Y1967F = c("F", "Fc", "F", "F", "Fc", "F", "F", "Fc",
"F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc"
), Y1968 = c(8, 12500, 10, 7, 50000, 35, 10, 40000, 40, 5, 40000,
20, 14, 28571, 40, 4, 45000, 18, 6, 50000), Y1968F = c("F", "Fc",
"F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc",
"F", "F", "Fc", "F", "F", "Fc"), Y1969 = c(10, 12000, 12, 10,
45000, 45, 15, 40000, 60, 6, 46667, 28, 16, 37500, 60, 5, 40000,
20, 10, 45000), Y1969F = c("F", "Fc", "F", "F", "Fc", "F", "F",
"Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F",
"Fc"), Y1970 = c(10, 15000, 15, 12, 50000, 60, 20, 40000, 80,
9, 44444, 40, 20, 40000, 80, 6, 41667, 25, 13, 46154), Y1970F = c("F",
"Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F",
"Fc", "F", "F", "Fc", "F", "F", "Fc"), Y1971 = c(16, 11250, 18,
15, 53333, 80, 25, 40000, 100, 12, 41667, 50, 37, 32432, 120,
7, 42857, 30, 16, 50000), Y1971F = c("F", "Fc", "F", "F", "Fc",
"F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc",
"F", "F", "Fc"), Y1972 = c(18, 11111, 20, 20, 49000, 98, 30,
37333, 112, 13, 43077, 56, 40, 37250, 149, 8, 46250, 37, 18,
52222), Y1972F = c("F", "Fc", "", "F", "Fc", "", "F", "Fc", "",
"F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc"), Y1973 = c(6,
13333, 8, 7, 50000, 35, 14, 37857, 53, 6, 45000, 27, 18, 38333,
69, 5, 38000, 19, 17, 51176), Y1973F = c("F", "Fc", "", "F",
"Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc",
"", "F", "Fc"), Y1974 = c(30, 10667, 32, 4, 37500, 15, 4, 37500,
15, 2, 55000, 11, 8, 22500, 18, 3, 50000, 15, 15, 52000), Y1974F = c("F",
"Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc",
"", "F", "Fc", "", "F", "Fc"), Y1975 = c(10, 12000, 12, 6, 46667,
28, 3, 33333, 10, 3, 46667, 14, 15, 25333, 38, 3, 43333, 13,
19, 51579), Y1975F = c("F", "Fc", "", "F", "Fc", "", "F", "Fc",
"", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc"),
Y1976 = c(20, 11500, 23, 8, 46250, 37, 5, 40000, 20, 15,
44000, 66, 17, 25882, 44, 5, 42000, 21, 18, 48889), Y1976F = c("F",
"Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F",
"Fc", "", "F", "Fc", "", "F", "Fc"), Y1977 = c(9, 12222,
11, 5, 40000, 20, 2, 35000, 7, 15, 40667, 61, 15, 22000,
33, 2, 45000, 9, 15, 41333), Y1977F = c("F", "Fc", "", "F",
"Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F",
"Fc", "", "F", "Fc"), Y1978 = c(20, 116000, 232, 5, 38000,
19, 5, 42000, 21, 16, 55000, 88, 12, 41667, 50, 2, 40000,
8, 18, 27778), Y1978F = c("F", "Fc", "", "F", "Fc", "", "F",
"Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F",
"Fc"), Y1979 = c(12, 126667, 152, 10, 43000, 43, 35, 41143,
144, 23, 63913, 147, 30, 43000, 129, 2, 55000, 11, 35, 38571
), Y1979F = c("F", "Fc", "", "F", "Fc", "", "F", "Fc", "",
"F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc"),
Y1980 = c(34, 140000, 476, 13, 11538, 15, 23, 35217, 81,
19, 65263, 124, 12, 39167, 47, 9, 75556, 68, 26, 55769),
Y1980F = c("", "Fc", "", "", "Fc", "", "", "Fc", "", "",
"Fc", "", "", "Fc", "", "", "Fc", "", "", "Fc"), Y1981 = c(36,
142778, 514, 25, 8800, 22, 30, 32667, 98, 23, 77391, 178,
19, 56316, 107, 10, 89000, 89, 29, 53793), Y1981F = c("",
"Fc", "", "", "Fc", "", "", "Fc", "", "", "Fc", "", "", "Fc",
"", "", "Fc", "", "", "Fc"), Y1982 = c(45, 140889, 634, 23,
33913, 78, 19, 96842, 184, 14, 84286, 118, 12, 56667, 68,
17, 30000, 51, 18, 82222), Y1982F = c("", "Fc", "", "", "Fc",
"", "", "Fc", "", "", "Fc", "", "", "Fc", "", "", "Fc", "",
"", "Fc"), Y1983 = c(5, 94000, 47, 13, 41538, 54, 20, 83000,
166, 35, 42286, 148, 10, 44000, 44, 14, 40000, 56, 16, 87500
), Y1983F = c("F", "Fc", "", "", "Fc", "", "", "Fc", "",
"", "Fc", "", "", "Fc", "", "", "Fc", "", "", "Fc"), Y1984 = c(8,
1e+05, 80, 2, 35000, 7, 15, 59333, 89, 30, 49000, 147, 5,
50000, 25, 11, 44545, 49, 10, 80000), Y1984F = c("F", "Fc",
"", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc",
"", "F", "Fc", "", "F", "Fc"), Y1985 = c(8, 87500, 70, 22,
45000, 99, 18, 65000, 117, 30, 46000, 138, 10, 55000, 55,
8, 33750, 27, 32, 85938), Y1985F = c("F", "Fc", "", "F",
"Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F",
"Fc", "", "F", "Fc"), Y1986 = c(8, 87500, 70, 17, 41176,
70, 18, 55556, 100, 30, 46667, 140, 9, 55556, 50, 8, 35000,
28, 25, 80000), Y1986F = c("F", "Fc", "F", "F", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc",
"F", "F", "Fc"), Y1987 = c(8, 87500, 70, 9, 37778, 34, 16,
58125, 93, 35, 42286, 148, 6, 51667, 31, 8, 36250, 29, 18,
75000), Y1987F = c("F", "Fc", "", "F", "Fc", "", "F", "Fc",
"", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc"
), Y1988 = c(8, 105000, 84, 11, 37273, 41, 18, 61667, 111,
42, 42143, 177, 8, 46250, 37, 9, 38889, 35, 19, 84737), Y1988F = c("F",
"Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F",
"Fc", "", "F", "Fc", "", "F", "Fc"), Y1989 = c(9, 111111,
100, 12, 37500, 45, 18, 63889, 115, 45, 40000, 180, 8, 50000,
40, 10, 30000, 30, 21, 85714), Y1989F = c("F", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc",
"F", "F", "Fc", "F", "F", "Fc"), Y1990 = c(10, 120000, 120,
13, 38462, 50, 20, 60000, 120, 49, 40816, 200, 9, 50000,
45, 11, 36364, 40, 22, 90909), Y1990F = c("F", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "Im", "Fc", "F", "F", "Fc",
"F", "F", "Fc", "F", "F", "Fc"), Y1991 = c(12, 108333, 130,
15, 40000, 60, 21, 58571, 123, 52, 42308, 220, 10, 50000,
50, 12, 41667, 50, 25, 92000), Y1991F = c("F", "Fc", "F",
"F", "Fc", "F", "Im", "Fc", "Im", "F", "Fc", "F", "F", "Fc",
"F", "F", "Fc", "F", "F", "Fc"), Y1992 = c(12, 116667, 140,
20, 40000, 80, 22, 59091, 130, 54, 48148, 260, 10, 46000,
46, 15, 53333, 80, 28, 89286), Y1992F = c("Im", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "Im", "Fc",
"Im", "F", "Fc", "F", "F", "Fc"), Y1993 = c(12, 114167, 137,
17, 39412, 67, 21, 57143, 120, 52, 43846, 228, 10, 46000,
46, 15, 45333, 68, 27, 87037), Y1993F = c("Im", "Fc", "Im",
"Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"), Y1994 = c(12,
113333, 136, 18, 37222, 67, 21, 55714, 117, 52, 43269, 225,
10, 46000, 46, 14, 46429, 65, 26, 84615), Y1994F = c("F",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"), Y1995 = c(12,
114167, 137, 18, 36111, 65, 20, 50000, 100, 52, 40385, 210,
9, 44444, 40, 13, 46154, 60, 26, 76923), Y1995F = c("F",
"Fc", "Im", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "F", "Fc"), Y1996 = c(13,
115385, 150, 19, 35789, 68, 22, 53182, 117, 53, 41887, 222,
9, 45556, 41, 14, 45000, 63, 24, 84167), Y1996F = c("F",
"Fc", "F", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "F", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"), Y1997 = c(14,
110714, 155, 19, 36316, 69, 23, 51304, 118, 53, 42075, 223,
10, 46000, 46, 14, 45714, 64, 25, 81600), Y1997F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"), Y1998 = c(14,
114286, 160, 20, 35500, 71, 23, 52609, 121, 54, 41667, 225,
10, 46000, 46, 14, 47143, 66, 26, 79615), Y1998F = c("F",
"Fc", "F", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"), Y1999 = c(15,
113333, 170, 20, 36000, 72, 24, 51667, 124, 55, 41273, 227,
10, 46000, 46, 15, 45333, 68, 26, 80769), Y1999F = c("F",
"Fc", "F", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"), Y2000 = c(14,
114286, 160, 20, 35000, 70, 25, 50000, 125, 55, 40000, 220,
10, 45000, 45, 15, 46667, 70, 27, 78148), Y2000F = c("F",
"Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F",
"F", "Fc", "Im", "F", "Fc", "F", "F", "Fc"), Y2001 = c(16,
112500, 180, 21, 35714, 75, 25, 51200, 128, 57, 40702, 232,
10, 45000, 45, 16, 46875, 75, 27, 75926), Y2001F = c("F",
"Fc", "F", "Im", "Fc", "F", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "F", "Im", "Fc", "F", "Im", "Fc"), Y2002 = c(18,
111111, 200, 22, 36364, 80, 26, 50000, 130, 58, 40517, 235,
12, 45000, 54, 17, 46471, 79, 28, 75000), Y2002F = c("F",
"Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "Im", "Fc", "Im",
"F", "Fc", "F", "Im", "Fc", "Im", "F", "Fc"), Y2003 = c(19,
110526, 210, 24, 37500, 90, 28, 50000, 140, 58, 40517, 235,
15, 40000, 60, 18, 50000, 90, 29, 75862), Y2003F = c("F",
"Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "F", "Fc"), Y2004 = c(20,
110000, 220, 25, 38000, 95, 30, 50000, 150, 60, 40000, 240,
18, 41667, 75, 20, 47500, 95, 30, 75000), Y2004F = c("F",
"Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "F", "Fc"), Y2005 = c(21,
103810, 218, 24, 37500, 90, 29, 48276, 140, 63, 39206, 247,
17, 42941, 73, 19, 47895, 91, 30, 69667), Y2005F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"), Y2006 = c(22,
101364, 223, 25, 38400, 96, 30, 47333, 142, 65, 38769, 252,
20, 40000, 80, 19, 47895, 91, 30, 66000), Y2006F = c("Im",
"Fc", "Im", "F", "Fc", "Im", "F", "Fc", "Im", "Im", "Fc",
"Im", "F", "Fc", "F", "Im", "Fc", "Im", "F", "Fc"), Y2007 = c(22,
100909, 222, 24, 38333, 92, 30, 46667, 140, 65, 40000, 260,
19, 44737, 85, 19, 47895, 91, 30, 62667), Y2007F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "F", "Fc", "Im", "F", "Fc",
"F", "Im", "Fc", "Im", "Im", "Fc", "Im", "F", "Fc"), Y2008 = c(23,
97826, 225, 24, 38333, 92, 30, 45667, 137, 70, 37714, 264,
20, 46000, 92, 20, 46000, 92, 27, 58889), Y2008F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "F", "Fc"), Y2009 = c(25,
91200, 228, 24, 38750, 93, 30, 45333, 136, 73, 36849, 269,
21, 46667, 98, 20, 46000, 92, 22, 55455), Y2009F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "F", "Fc"), Y2010 = c(25,
90000, 225, 22, 39545, 87, 31, 43548, 135, 76, 36184, 275,
21, 50000, 105, 20, 46000, 92, 15, 50000), Y2010F = c("F",
"Fc", "Im", "Im", "Fc", "F", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"), Y2011 = c(28,
85357, 239, 24, 39583, 95, 31, 43226, 134, 80, 35000, 280,
22, 50455, 111, 20, 46000, 92, 17, 48824), Y2011F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"), Y2012 = c(35,
71429, 250, 25, 40000, 100, 30, 41667, 125, 97, 30928, 300,
20, 57500, 115, 20, 45000, 90, 20, 41000), Y2012F = c("F",
"Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "F", "Fc"), Y2013 = c(32,
79688, 255, 25, 39600, 99, 32, 41563, 133, 86, 33256, 286,
24, 51667, 124, 20, 47500, 95, 21, 40000), Y2013F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"), Y2014 = c(35,
74000, 259, 25, 39200, 98, 33, 40909, 135, 87, 33218, 289,
24, 54167, 130, 20, 48000, 96, 19, 42105), Y2014F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"), Y2015 = c(37,
71081, 263, 25, 40400, 101, 32, 41250, 132, 90, 32444, 292,
25, 54000, 135, 21, 47143, 99, 20, 42500), Y2015F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"), Y2016 = c(40,
66250, 265, 25, 40000, 100, 33, 39394, 130, 93, 31828, 296,
26, 54231, 141, 21, 46667, 98, 19, 43684), Y2016F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"), Y2017 = c(42,
64048, 269, 25, 40400, 101, 33, 39394, 130, 96, 31250, 300,
26, 56538, 147, 21, 47143, 99, 18, 44444), Y2017F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "F", "Fc"), Y2018 = c(45,
60667, 273, 25, 40400, 101, 33, 39091, 129, 99, 30606, 303,
27, 56667, 153, 21, 47143, 99, 18, 42222), Y2018F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"), Y2019 = c(49,
56327, 276, 25, 40800, 102, 34, 37647, 128, 102, 30000, 306,
27, 58889, 159, 21, 47619, 100, 18, 38889), Y2019F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc")), row.names = c(NA,
20L), class = "data.frame")
Here is code that produces a bar plot for one country, one element, and two years. The important step is to pivot the data to a long format.
library(dplyr)
library(tidyr)
library(ggplot2)
DF <- structure(list(Area.Code = c(8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L),
Area = c("Antigua and Barbuda",
"Antigua and Barbuda", "Antigua and Barbuda", "Antigua and Barbuda",
"Antigua and Barbuda", "Antigua and Barbuda", "Antigua and Barbuda",
"Antigua and Barbuda", "Antigua and Barbuda", "Antigua and Barbuda",
"Antigua and Barbuda", "Antigua and Barbuda", "Antigua and Barbuda",
"Antigua and Barbuda", "Antigua and Barbuda", "Antigua and Barbuda",
"Antigua and Barbuda", "Antigua and Barbuda", "Antigua and Barbuda",
"Antigua and Barbuda"),
Item.Code = c(486L, 486L, 486L, 414L,
414L, 414L, 358L, 358L, 358L, 426L, 426L, 426L, 125L, 125L, 125L,
401L, 401L, 401L, 397L, 397L),
Item = c("Bananas", "Bananas",
"Bananas", "Beans, green", "Beans, green", "Beans, green", "Cabbages and other brassicas",
"Cabbages and other brassicas", "Cabbages and other brassicas",
"Carrots and turnips", "Carrots and turnips", "Carrots and turnips",
"Cassava", "Cassava", "Cassava", "Chillies and peppers, green",
"Chillies and peppers, green", "Chillies and peppers, green",
"Cucumbers and gherkins", "Cucumbers and gherkins"),
Element.Code = c(5312L,
5419L, 5510L, 5312L, 5419L, 5510L, 5312L, 5419L, 5510L, 5312L,
5419L, 5510L, 5312L, 5419L, 5510L, 5312L, 5419L, 5510L, 5312L,
5419L),
Element = c("Area harvested", "Yield", "Production",
"Area harvested", "Yield", "Production", "Area harvested", "Yield",
"Production", "Area harvested", "Yield", "Production", "Area harvested",
"Yield", "Production", "Area harvested", "Yield", "Production",
"Area harvested", "Yield"),
Unit = c("ha", "hg/ha", "tonnes",
"ha", "hg/ha", "tonnes", "ha", "hg/ha", "tonnes", "ha", "hg/ha",
"tonnes", "ha", "hg/ha", "tonnes", "ha", "hg/ha", "tonnes", "ha",
"hg/ha"),
Y1961 = c(NA, NA, NA, 1, 40000, 4, 2, 40000, 8, 1,
30000, 3, 3, 33333, 10, NA, NA, NA, 1, 20000),
Y1961F = c("",
"", "", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F",
"Fc", "F", "", "", "", "F", "Fc"),
Y1962 = c(NA, NA, NA, 1, 40000,
4, 3, 33333, 10, 1, 50000, 5, 4, 30000, 12, NA, NA, NA, 1, 30000
),
Y1962F = c("", "", "", "F", "Fc", "F", "F", "Fc", "F", "F",
"Fc", "F", "F", "Fc", "F", "", "", "", "F", "Fc"),
Y1963 = c(NA,
NA, NA, 2, 30000, 6, 3, 40000, 12, 2, 40000, 8, 5, 28000, 14,
1, 30000, 3, 1, 40000),
Y1963F = c("", "", "", "F", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F",
"F", "Fc"),
Y1964 = c(NA, NA, NA, 2, 40000, 8, 4, 37500, 15,
2, 50000, 10, 6, 26667, 16, 1, 50000, 5, 1, 60000),
Y1964F = c("",
"", "", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F",
"Fc", "F", "F", "Fc", "F", "F", "Fc"),
Y1965 = c(NA, NA, NA,
2, 50000, 10, 5, 40000, 20, 2, 50000, 10, 7, 25714, 18, 2, 40000,
8, 1, 80000),
Y1965F = c("", "", "", "F", "Fc", "F", "F", "Fc",
"F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc"
),
Y1966 = c(3, 16667, 5, 2, 50000, 10, 5, 40000, 20, 2, 50000,
10, 8, 25000, 20, 2, 50000, 10, 2, 50000),
Y1966F = c("F", "Fc",
"F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc",
"F", "F", "Fc", "F", "F", "Fc"),
Y1967 = c(6, 13333, 8, 5, 40000,
20, 7, 42857, 30, 3, 50000, 15, 12, 25000, 30, 3, 46667, 14,
4, 50000),
Y1967F = c("F", "Fc", "F", "F", "Fc", "F", "F", "Fc",
"F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc"
),
Y1968 = c(8, 12500, 10, 7, 50000, 35, 10, 40000, 40, 5, 40000,
20, 14, 28571, 40, 4, 45000, 18, 6, 50000),
Y1968F = c("F", "Fc",
"F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc",
"F", "F", "Fc", "F", "F", "Fc"),
Y1969 = c(10, 12000, 12, 10,
45000, 45, 15, 40000, 60, 6, 46667, 28, 16, 37500, 60, 5, 40000,
20, 10, 45000),
Y1969F = c("F", "Fc", "F", "F", "Fc", "F", "F",
"Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F",
"Fc"),
Y1970 = c(10, 15000, 15, 12, 50000, 60, 20, 40000, 80,
9, 44444, 40, 20, 40000, 80, 6, 41667, 25, 13, 46154),
Y1970F = c("F",
"Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F",
"Fc", "F", "F", "Fc", "F", "F", "Fc"),
Y1971 = c(16, 11250, 18,
15, 53333, 80, 25, 40000, 100, 12, 41667, 50, 37, 32432, 120,
7, 42857, 30, 16, 50000),
Y1971F = c("F", "Fc", "F", "F", "Fc",
"F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc",
"F", "F", "Fc"),
Y1972 = c(18, 11111, 20, 20, 49000, 98, 30,
37333, 112, 13, 43077, 56, 40, 37250, 149, 8, 46250, 37, 18,
52222), Y1972F = c("F", "Fc", "", "F", "Fc", "", "F", "Fc", "",
"F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc"),
Y1973 = c(6,
13333, 8, 7, 50000, 35, 14, 37857, 53, 6, 45000, 27, 18, 38333,
69, 5, 38000, 19, 17, 51176),
Y1973F = c("F", "Fc", "", "F",
"Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc",
"", "F", "Fc"), Y1974 = c(30, 10667, 32, 4, 37500, 15, 4, 37500,
15, 2, 55000, 11, 8, 22500, 18, 3, 50000, 15, 15, 52000),
Y1974F = c("F",
"Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc",
"", "F", "Fc", "", "F", "Fc"),
Y1975 = c(10, 12000, 12, 6, 46667,
28, 3, 33333, 10, 3, 46667, 14, 15, 25333, 38, 3, 43333, 13,
19, 51579),
Y1975F = c("F", "Fc", "", "F", "Fc", "", "F", "Fc",
"", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc"),
Y1976 = c(20, 11500, 23, 8, 46250, 37, 5, 40000, 20, 15,
44000, 66, 17, 25882, 44, 5, 42000, 21, 18, 48889),
Y1976F = c("F",
"Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F",
"Fc", "", "F", "Fc", "", "F", "Fc"),
Y1977 = c(9, 12222,
11, 5, 40000, 20, 2, 35000, 7, 15, 40667, 61, 15, 22000,
33, 2, 45000, 9, 15, 41333),
Y1977F = c("F", "Fc", "", "F",
"Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F",
"Fc", "", "F", "Fc"),
Y1978 = c(20, 116000, 232, 5, 38000,
19, 5, 42000, 21, 16, 55000, 88, 12, 41667, 50, 2, 40000,
8, 18, 27778),
Y1978F = c("F", "Fc", "", "F", "Fc", "", "F",
"Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F",
"Fc"),
Y1979 = c(12, 126667, 152, 10, 43000, 43, 35, 41143,
144, 23, 63913, 147, 30, 43000, 129, 2, 55000, 11, 35, 38571
),
Y1979F = c("F", "Fc", "", "F", "Fc", "", "F", "Fc", "",
"F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc"),
Y1980 = c(34, 140000, 476, 13, 11538, 15, 23, 35217, 81,
19, 65263, 124, 12, 39167, 47, 9, 75556, 68, 26, 55769),
Y1980F = c("", "Fc", "", "", "Fc", "", "", "Fc", "", "",
"Fc", "", "", "Fc", "", "", "Fc", "", "", "Fc"),
Y1981 = c(36,
142778, 514, 25, 8800, 22, 30, 32667, 98, 23, 77391, 178,
19, 56316, 107, 10, 89000, 89, 29, 53793),
Y1981F = c("",
"Fc", "", "", "Fc", "", "", "Fc", "", "", "Fc", "", "", "Fc",
"", "", "Fc", "", "", "Fc"),
Y1982 = c(45, 140889, 634, 23,
33913, 78, 19, 96842, 184, 14, 84286, 118, 12, 56667, 68,
17, 30000, 51, 18, 82222),
Y1982F = c("", "Fc", "", "", "Fc",
"", "", "Fc", "", "", "Fc", "", "", "Fc", "", "", "Fc", "",
"", "Fc"),
Y1983 = c(5, 94000, 47, 13, 41538, 54, 20, 83000,
166, 35, 42286, 148, 10, 44000, 44, 14, 40000, 56, 16, 87500
),
Y1983F = c("F", "Fc", "", "", "Fc", "", "", "Fc", "",
"", "Fc", "", "", "Fc", "", "", "Fc", "", "", "Fc"),
Y1984 = c(8,
1e+05, 80, 2, 35000, 7, 15, 59333, 89, 30, 49000, 147, 5,
50000, 25, 11, 44545, 49, 10, 80000),
Y1984F = c("F", "Fc",
"", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc",
"", "F", "Fc", "", "F", "Fc"),
Y1985 = c(8, 87500, 70, 22,
45000, 99, 18, 65000, 117, 30, 46000, 138, 10, 55000, 55,
8, 33750, 27, 32, 85938),
Y1985F = c("F", "Fc", "", "F",
"Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F",
"Fc", "", "F", "Fc"),
Y1986 = c(8, 87500, 70, 17, 41176,
70, 18, 55556, 100, 30, 46667, 140, 9, 55556, 50, 8, 35000,
28, 25, 80000),
Y1986F = c("F", "Fc", "F", "F", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc",
"F", "F", "Fc"),
Y1987 = c(8, 87500, 70, 9, 37778, 34, 16,
58125, 93, 35, 42286, 148, 6, 51667, 31, 8, 36250, 29, 18,
75000),
Y1987F = c("F", "Fc", "", "F", "Fc", "", "F", "Fc",
"", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc"
),
Y1988 = c(8, 105000, 84, 11, 37273, 41, 18, 61667, 111,
42, 42143, 177, 8, 46250, 37, 9, 38889, 35, 19, 84737),
Y1988F = c("F",
"Fc", "", "F", "Fc", "", "F", "Fc", "", "F", "Fc", "", "F",
"Fc", "", "F", "Fc", "", "F", "Fc"),
Y1989 = c(9, 111111,
100, 12, 37500, 45, 18, 63889, 115, 45, 40000, 180, 8, 50000,
40, 10, 30000, 30, 21, 85714),
Y1989F = c("F", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc",
"F", "F", "Fc", "F", "F", "Fc"),
Y1990 = c(10, 120000, 120,
13, 38462, 50, 20, 60000, 120, 49, 40816, 200, 9, 50000,
45, 11, 36364, 40, 22, 90909),
Y1990F = c("F", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "Im", "Fc", "F", "F", "Fc",
"F", "F", "Fc", "F", "F", "Fc"),
Y1991 = c(12, 108333, 130,
15, 40000, 60, 21, 58571, 123, 52, 42308, 220, 10, 50000,
50, 12, 41667, 50, 25, 92000),
Y1991F = c("F", "Fc", "F",
"F", "Fc", "F", "Im", "Fc", "Im", "F", "Fc", "F", "F", "Fc",
"F", "F", "Fc", "F", "F", "Fc"),
Y1992 = c(12, 116667, 140,
20, 40000, 80, 22, 59091, 130, 54, 48148, 260, 10, 46000,
46, 15, 53333, 80, 28, 89286),
Y1992F = c("Im", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "Im", "Fc",
"Im", "F", "Fc", "F", "F", "Fc"),
Y1993 = c(12, 114167, 137,
17, 39412, 67, 21, 57143, 120, 52, 43846, 228, 10, 46000,
46, 15, 45333, 68, 27, 87037),
Y1993F = c("Im", "Fc", "Im",
"Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"),
Y1994 = c(12,
113333, 136, 18, 37222, 67, 21, 55714, 117, 52, 43269, 225,
10, 46000, 46, 14, 46429, 65, 26, 84615),
Y1994F = c("F",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"),
Y1995 = c(12,
114167, 137, 18, 36111, 65, 20, 50000, 100, 52, 40385, 210,
9, 44444, 40, 13, 46154, 60, 26, 76923),
Y1995F = c("F",
"Fc", "Im", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "F", "Fc"),
Y1996 = c(13,
115385, 150, 19, 35789, 68, 22, 53182, 117, 53, 41887, 222,
9, 45556, 41, 14, 45000, 63, 24, 84167),
Y1996F = c("F",
"Fc", "F", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "F", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"),
Y1997 = c(14,
110714, 155, 19, 36316, 69, 23, 51304, 118, 53, 42075, 223,
10, 46000, 46, 14, 45714, 64, 25, 81600),
Y1997F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"),
Y1998 = c(14,
114286, 160, 20, 35500, 71, 23, 52609, 121, 54, 41667, 225,
10, 46000, 46, 14, 47143, 66, 26, 79615),
Y1998F = c("F",
"Fc", "F", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"),
Y1999 = c(15,
113333, 170, 20, 36000, 72, 24, 51667, 124, 55, 41273, 227,
10, 46000, 46, 15, 45333, 68, 26, 80769),
Y1999F = c("F",
"Fc", "F", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"),
Y2000 = c(14,
114286, 160, 20, 35000, 70, 25, 50000, 125, 55, 40000, 220,
10, 45000, 45, 15, 46667, 70, 27, 78148),
Y2000F = c("F",
"Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F",
"F", "Fc", "Im", "F", "Fc", "F", "F", "Fc"),
Y2001 = c(16,
112500, 180, 21, 35714, 75, 25, 51200, 128, 57, 40702, 232,
10, 45000, 45, 16, 46875, 75, 27, 75926),
Y2001F = c("F",
"Fc", "F", "Im", "Fc", "F", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "F", "Im", "Fc", "F", "Im", "Fc"),
Y2002 = c(18,
111111, 200, 22, 36364, 80, 26, 50000, 130, 58, 40517, 235,
12, 45000, 54, 17, 46471, 79, 28, 75000),
Y2002F = c("F",
"Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "Im", "Fc", "Im",
"F", "Fc", "F", "Im", "Fc", "Im", "F", "Fc"),
Y2003 = c(19,
110526, 210, 24, 37500, 90, 28, 50000, 140, 58, 40517, 235,
15, 40000, 60, 18, 50000, 90, 29, 75862),
Y2003F = c("F",
"Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "F", "Fc"),
Y2004 = c(20,
110000, 220, 25, 38000, 95, 30, 50000, 150, 60, 40000, 240,
18, 41667, 75, 20, 47500, 95, 30, 75000),
Y2004F = c("F",
"Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "F", "Fc"),
Y2005 = c(21,
103810, 218, 24, 37500, 90, 29, 48276, 140, 63, 39206, 247,
17, 42941, 73, 19, 47895, 91, 30, 69667),
Y2005F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"),
Y2006 = c(22,
101364, 223, 25, 38400, 96, 30, 47333, 142, 65, 38769, 252,
20, 40000, 80, 19, 47895, 91, 30, 66000),
Y2006F = c("Im",
"Fc", "Im", "F", "Fc", "Im", "F", "Fc", "Im", "Im", "Fc",
"Im", "F", "Fc", "F", "Im", "Fc", "Im", "F", "Fc"),
Y2007 = c(22,
100909, 222, 24, 38333, 92, 30, 46667, 140, 65, 40000, 260,
19, 44737, 85, 19, 47895, 91, 30, 62667),
Y2007F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "F", "Fc", "Im", "F", "Fc",
"F", "Im", "Fc", "Im", "Im", "Fc", "Im", "F", "Fc"),
Y2008 = c(23,
97826, 225, 24, 38333, 92, 30, 45667, 137, 70, 37714, 264,
20, 46000, 92, 20, 46000, 92, 27, 58889),
Y2008F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "F", "Fc"),
Y2009 = c(25,
91200, 228, 24, 38750, 93, 30, 45333, 136, 73, 36849, 269,
21, 46667, 98, 20, 46000, 92, 22, 55455),
Y2009F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "F", "Fc"),
Y2010 = c(25,
90000, 225, 22, 39545, 87, 31, 43548, 135, 76, 36184, 275,
21, 50000, 105, 20, 46000, 92, 15, 50000),
Y2010F = c("F",
"Fc", "Im", "Im", "Fc", "F", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"),
Y2011 = c(28,
85357, 239, 24, 39583, 95, 31, 43226, 134, 80, 35000, 280,
22, 50455, 111, 20, 46000, 92, 17, 48824),
Y2011F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"),
Y2012 = c(35,
71429, 250, 25, 40000, 100, 30, 41667, 125, 97, 30928, 300,
20, 57500, 115, 20, 45000, 90, 20, 41000),
Y2012F = c("F",
"Fc", "F", "F", "Fc", "F", "F", "Fc", "F", "F", "Fc", "F",
"F", "Fc", "F", "F", "Fc", "F", "F", "Fc"),
Y2013 = c(32,
79688, 255, 25, 39600, 99, 32, 41563, 133, 86, 33256, 286,
24, 51667, 124, 20, 47500, 95, 21, 40000),
Y2013F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"),
Y2014 = c(35,
74000, 259, 25, 39200, 98, 33, 40909, 135, 87, 33218, 289,
24, 54167, 130, 20, 48000, 96, 19, 42105),
Y2014F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"),
Y2015 = c(37,
71081, 263, 25, 40400, 101, 32, 41250, 132, 90, 32444, 292,
25, 54000, 135, 21, 47143, 99, 20, 42500),
Y2015F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"),
Y2016 = c(40,
66250, 265, 25, 40000, 100, 33, 39394, 130, 93, 31828, 296,
26, 54231, 141, 21, 46667, 98, 19, 43684),
Y2016F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"),
Y2017 = c(42,
64048, 269, 25, 40400, 101, 33, 39394, 130, 96, 31250, 300,
26, 56538, 147, 21, 47143, 99, 18, 44444),
Y2017F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "F", "Fc"),
Y2018 = c(45,
60667, 273, 25, 40400, 101, 33, 39091, 129, 99, 30606, 303,
27, 56667, 153, 21, 47143, 99, 18, 42222),
Y2018F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc"),
Y2019 = c(49,
56327, 276, 25, 40800, 102, 34, 37647, 128, 102, 30000, 306,
27, 58889, 159, 21, 47619, 100, 18, 38889),
Y2019F = c("Im",
"Fc", "Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc",
"Im", "Im", "Fc", "Im", "Im", "Fc", "Im", "Im", "Fc")),
row.names = c(NA, 20L), class = "data.frame")
NumData <- select(DF, c(1:7, seq(8, 124,2)))
NumLong <- pivot_longer(NumData,cols = Y1961:Y2019, names_to = "Year")
head(NumLong)
NumLong |> filter(Area == "Antigua and Barbuda",
Element == "Area harvested",
Year %in% c("Y1968", "Y1969")) |>
ggplot(aes(x= Year, y = value)) + geom_col(fill = "steelblue") +
labs(title = "Area Harvested")
Great. Thanks for your help
Excuse me, something else. It is possible to get the production of a crop in a country? For example Avocados in Chile in 1975 and 2015 using barplot again.
After you make the NumLong data frame, I think this will work.
NumLong |> filter(Area == "Chile",
Element == "Production",
Item == "Avocado",
Year %in% c("Y1975", "Y2015")) |>
ggplot(aes(x= Year, y = value)) + geom_col(fill = "steelblue") +
labs(title = "Avocado Production in Chile")
Thank you very much friend, this is very useful for my investigation
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.