phii m@iii@g oii phiiipsmith@c@
2019-Aug-25 02:45 UTC
[R] Colouring selected columns in a facetted column chart
Resubmitted as recommended: I am having difficulty with a chart using ggplot. It is a facetted column chart showing GDP growth rates by country. The columns are coloured navyblue, except that I want to colour the most recent columns, for 2019-Q1 and 2019-Q2, red. For some countries data are available up to 2019-Q2 while for others data are only available up to 2019-Q1. My code and data frame are shown below and it almost works, but not quite. For some reason the red bars for Germany, Korea, Norway, Sweden and United Kingdom are slightly off. Any help will be much appreciated. Here is my reprex: library(tidyverse) t1 <- read.table("t1.txt",header=TRUE,sep="\t") col <- rep("navyblue",nrow(t1)) for (i in 1:nrow(t1)) { if((t1$TIME[i]=="2019-Q1" | t1$TIME[i]=="2019-Q2")) { col[i] <- "red"} } ggplot(t1) + geom_col(aes(x=TIME,y=GDPgr),fill=col) + facet_wrap(~Country,ncol=3) Here is my data frame, called "t1.txt", output by dput(): structure(list(TIME = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L), .Label = c("2016-Q4", "2017-Q1", "2017-Q2", "2017-Q3", "2017-Q4", "2018-Q1", "2018-Q2", "2018-Q3", "2018-Q4", "2019-Q1", "2019-Q2"), class = "factor"), LOCATION = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L ), .Label = c("AUS", "BEL", "CAN", "CHE", "DEU", "DNK", "ESP", "EU28", "FIN", "FRA", "GBR", "ISR", "ITA", "JPN", "KOR", "NLD", "NOR", "NZL", "PRT", "SWE", "USA"), class = "factor"), Country = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L), .Label = c("Australia", "Belgium", "Canada", "Denmark", "European Union (28 countries)", "Finland", "France", "Germany", "Israel", "Italy", "Japan", "Korea", "Netherlands", "New Zealand", "Norway", "Portugal", "Spain", "Sweden", "Switzerland", "United Kingdom", "United States"), class = "factor"), Value = c(440518, 442141, 445739, 448672, 451302, 455680, 459697, 461024, 462032, 463907, 106675, 107394, 107828, 108003, 108744, 109037, 109386, 109676, 110081, 110459, 110680, 493742, 498719, 504100.5, 505745, 507883, 509758.75, 512958, 515639.25, 515971.75, 516489.5, 499945, 511319, 505254, 500363, 504837, 508633, 511901, 513630, 517726, 518368, 3301202.652555, 3323886.876398, 3345038.332666, 3367136.027609, 3390431.080785, 3404554.778774, 3419358.570571, 3430321.169276, 3440915.89772, 3458087.265837, 3465003.441, 48525, 49368, 49430, 49596, 50153, 50352, 50449, 50507, 50530, 50822, 551760, 556305, 560160, 563998, 568125, 569542, 570670, 572387, 574640, 576494, 577905, 716743.4074, 725268.5864, 729321.5731, 735610.6375, 740991.229, 741969.5787, 744834.6127, 744065.912, 745603.2305, 748468.2276, 747909.2496, 307789.55, 308323.023, 311759.624, 315651.46, 319056.442, 322272.592, 323422.356, 325702.534, 329052.641, 332851.725, 333686.876, 396162.2, 398379, 399893, 401534, 403053.4, 403937.8, 403977.3, 403434.2, 403190.7, 403697.9, 403794.7, 130406025, 131558850, 132121450, 133064400, 133475100, 133386850, 133931825, 133289800, 133836225, 134777725, 135369050, 431473400, 435435200, 437712100, 444064400, 443599800, 447909300, 450495800, 452561100, 456769700, 455081000, 459958000, 178453.593134, 179367.793134, 180964.533134, 182189.893134, 183625.193134, 184793.473134, 185981.973134, 186425.153134, 187434.343134, 188324.263134, 189297.773134, 59062, 59348, 59743, 60320, 60737, 61031, 61655, 61927, 62282, 62800, 784704, 788709, 794220, 798283, 800232, 803756, 807187, 810942, 815921, 815323, 44303.821, 44632.068, 44803.721, 45062.631, 45426.14, 45641.37, 45910.934, 46027.362, 46203.578, 46453.392, 46685.65896, 279431, 281707, 284169, 285986, 288064, 289861, 291583, 293145, 294768, 296732, 298147, 1150761, 1151977, 1169243, 1177835, 1181734, 1192111, 1197931, 1196262, 1209430, 1215583, 1214691, 168268.356822, 168865.076317, 170078.764694, 171405.16327, 172777.427869, 174168.535837, 175400.870886, 175089.0314, 175664.228343, 176651.744992, 496470, 498582, 499885, 502473, 504487, 504785, 506842, 510346, 511482, 514019, 513029, 4456057.75, 4481314, 4505262, 4540889.5, 4580616, 4609563.5, 4649533.75, 4683180, 4695887, 4731820.25, 4755955), GDPgr = c(1, 0.4, 0.8, 0.7, 0.6, 1, 0.9, 0.3, 0.2, 0.4, 0.3, 0.7, 0.4, 0.2, 0.7, 0.3, 0.3, 0.3, 0.4, 0.3, 0.2, 0.6, 1, 1.1, 0.3, 0.4, 0.4, 0.6, 0.5, 0.1, 0.1, 0.9, 2.3, -1.2, -1, 0.9, 0.8, 0.6, 0.3, 0.8, 0.1, 0.8, 0.7, 0.6, 0.7, 0.7, 0.4, 0.4, 0.3, 0.3, 0.5, 0.2, 0.2, 1.7, 0.1, 0.3, 1.1, 0.4, 0.2, 0.1, 0, 0.6, 0.6, 0.8, 0.7, 0.7, 0.7, 0.2, 0.2, 0.3, 0.4, 0.3, 0.2, 0.4, 1.2, 0.6, 0.9, 0.7, 0.1, 0.4, -0.1, 0.2, 0.4, -0.1, 0.9, 0.2, 1.1, 1.2, 1.1, 1, 0.4, 0.7, 1, 1.2, 0.3, 0.5, 0.6, 0.4, 0.4, 0.4, 0.2, 0, -0.1, -0.1, 0.1, 0, 0.2, 0.9, 0.4, 0.7, 0.3, -0.1, 0.4, -0.5, 0.4, 0.7, 0.4, 0.8, 0.9, 0.5, 1.5, -0.1, 1, 0.6, 0.5, 0.9, -0.4, 1.1, 0.9, 0.5, 0.9, 0.7, 0.8, 0.6, 0.6, 0.2, 0.5, 0.5, 0.5, 0.5, 0.5, 0.7, 1, 0.7, 0.5, 1, 0.4, 0.6, 0.8, 2, 0.5, 0.7, 0.5, 0.2, 0.4, 0.4, 0.5, 0.6, -0.1, 0.8, 0.7, 0.4, 0.6, 0.8, 0.5, 0.6, 0.3, 0.4, 0.5, 0.5, 0.6, 0.8, 0.9, 0.6, 0.7, 0.6, 0.6, 0.5, 0.6, 0.7, 0.5, 0.4, 0.1, 1.5, 0.7, 0.3, 0.9, 0.5, -0.1, 1.1, 0.5, -0.1, -0.1, 0.4, 0.7, 0.8, 0.8, 0.8, 0.7, -0.2, 0.3, 0.6, 0.7, 0.4, 0.3, 0.5, 0.4, 0.1, 0.4, 0.7, 0.2, 0.5, -0.2, 0.5, 0.6, 0.5, 0.8, 0.9, 0.6, 0.9, 0.7, 0.3, 0.8, 0.5)), class = "data.frame", row.names = c(NA, -224L)) On 2019-08-24 22:39, Eric Berger wrote:> Hi Phil, > Please resubmit your question with the data frame contents shown as > the output from the command > dput(t1.txt). This will make it easier for people to run your reprex > and respond to your question. > > Best, > Eric > > On Sun, Aug 25, 2019 at 5:26 AM <phil at philipsmith.ca> wrote: > >> I am having difficulty with a chart using ggplot. It is a facetted >> column chart showing GDP growth rates by country. The columns are >> coloured navyblue, except that I want to colour the most recent >> columns, >> for 2019-Q1 and 2019-Q2, red. For some countries data are available >> up >> to 2019-Q2 while for others data are only available up to 2019-Q1. >> My >> code and data frame are shown below and it almost works, but not >> quite. >> For some reason the red bars for Germany, Korea, Norway, Sweden and >> United Kingdom are slightly off. Any help will be much appreciated. >> >> Here is my reprex: >> >> library(tidyverse) >> t1 <- read.table("t1.txt",header=TRUE,sep="\t") >> col <- rep("navyblue",nrow(t1)) >> for (i in 1:nrow(t1)) { >> if((t1$TIME[i]=="2019-Q1" | t1$TIME[i]=="2019-Q2")) { >> col[i] <- "red"} >> } >> ggplot(t1) + >> geom_col(aes(x=TIME,y=GDPgr),fill=col) + >> facet_wrap(~Country,ncol=3) >> >> Here is my data frame, called "t1.txt": >> >> "TIME" "LOCATION" "Country" "Value" "GDPgr" >> "2016-Q4" "AUS" "Australia" 440518 1 >> "2017-Q1" "AUS" "Australia" 442141 0.4 >> "2017-Q2" "AUS" "Australia" 445739 0.8 >> "2017-Q3" "AUS" "Australia" 448672 0.7 >> "2017-Q4" "AUS" "Australia" 451302 0.6 >> "2018-Q1" "AUS" "Australia" 455680 1 >> "2018-Q2" "AUS" "Australia" 459697 0.9 >> "2018-Q3" "AUS" "Australia" 461024 0.3 >> "2018-Q4" "AUS" "Australia" 462032 0.2 >> "2019-Q1" "AUS" "Australia" 463907 0.4 >> "2016-Q4" "BEL" "Belgium" 106675 0.3 >> "2017-Q1" "BEL" "Belgium" 107394 0.7 >> "2017-Q2" "BEL" "Belgium" 107828 0.4 >> "2017-Q3" "BEL" "Belgium" 108003 0.2 >> "2017-Q4" "BEL" "Belgium" 108744 0.7 >> "2018-Q1" "BEL" "Belgium" 109037 0.3 >> "2018-Q2" "BEL" "Belgium" 109386 0.3 >> "2018-Q3" "BEL" "Belgium" 109676 0.3 >> "2018-Q4" "BEL" "Belgium" 110081 0.4 >> "2019-Q1" "BEL" "Belgium" 110459 0.3 >> "2019-Q2" "BEL" "Belgium" 110680 0.2 >> "2016-Q4" "CAN" "Canada" 493742 0.6 >> "2017-Q1" "CAN" "Canada" 498719 1 >> "2017-Q2" "CAN" "Canada" 504100.5 1.1 >> "2017-Q3" "CAN" "Canada" 505745 0.3 >> "2017-Q4" "CAN" "Canada" 507883 0.4 >> "2018-Q1" "CAN" "Canada" 509758.75 0.4 >> "2018-Q2" "CAN" "Canada" 512958 0.6 >> "2018-Q3" "CAN" "Canada" 515639.25 0.5 >> "2018-Q4" "CAN" "Canada" 515971.75 0.1 >> "2019-Q1" "CAN" "Canada" 516489.5 0.1 >> "2016-Q4" "DNK" "Denmark" 499945 0.9 >> "2017-Q1" "DNK" "Denmark" 511319 2.3 >> "2017-Q2" "DNK" "Denmark" 505254 -1.2 >> "2017-Q3" "DNK" "Denmark" 500363 -1 >> "2017-Q4" "DNK" "Denmark" 504837 0.9 >> "2018-Q1" "DNK" "Denmark" 508633 0.8 >> "2018-Q2" "DNK" "Denmark" 511901 0.6 >> "2018-Q3" "DNK" "Denmark" 513630 0.3 >> "2018-Q4" "DNK" "Denmark" 517726 0.8 >> "2019-Q1" "DNK" "Denmark" 518368 0.1 >> "2016-Q4" "EU28" "European Union (28 countries)" >> 3301202.652555 0.8 >> "2017-Q1" "EU28" "European Union (28 countries)" >> 3323886.876398 0.7 >> "2017-Q2" "EU28" "European Union (28 countries)" >> 3345038.332666 0.6 >> "2017-Q3" "EU28" "European Union (28 countries)" >> 3367136.027609 0.7 >> "2017-Q4" "EU28" "European Union (28 countries)" >> 3390431.080785 0.7 >> "2018-Q1" "EU28" "European Union (28 countries)" >> 3404554.778774 0.4 >> "2018-Q2" "EU28" "European Union (28 countries)" >> 3419358.570571 0.4 >> "2018-Q3" "EU28" "European Union (28 countries)" >> 3430321.169276 0.3 >> "2018-Q4" "EU28" "European Union (28 countries)" >> 3440915.89772 0.3 >> "2019-Q1" "EU28" "European Union (28 countries)" >> 3458087.265837 0.5 >> "2019-Q2" "EU28" "European Union (28 countries)" 3465003.441 >> 0.2 >> "2016-Q4" "FIN" "Finland" 48525 0.2 >> "2017-Q1" "FIN" "Finland" 49368 1.7 >> "2017-Q2" "FIN" "Finland" 49430 0.1 >> "2017-Q3" "FIN" "Finland" 49596 0.3 >> "2017-Q4" "FIN" "Finland" 50153 1.1 >> "2018-Q1" "FIN" "Finland" 50352 0.4 >> "2018-Q2" "FIN" "Finland" 50449 0.2 >> "2018-Q3" "FIN" "Finland" 50507 0.1 >> "2018-Q4" "FIN" "Finland" 50530 0 >> "2019-Q1" "FIN" "Finland" 50822 0.6 >> "2016-Q4" "FRA" "France" 551760 0.6 >> "2017-Q1" "FRA" "France" 556305 0.8 >> "2017-Q2" "FRA" "France" 560160 0.7 >> "2017-Q3" "FRA" "France" 563998 0.7 >> "2017-Q4" "FRA" "France" 568125 0.7 >> "2018-Q1" "FRA" "France" 569542 0.2 >> "2018-Q2" "FRA" "France" 570670 0.2 >> "2018-Q3" "FRA" "France" 572387 0.3 >> "2018-Q4" "FRA" "France" 574640 0.4 >> "2019-Q1" "FRA" "France" 576494 0.3 >> "2019-Q2" "FRA" "France" 577905 0.2 >> "2016-Q4" "DEU" "Germany" 716743.4074 0.4 >> "2017-Q1" "DEU" "Germany" 725268.5864 1.2 >> "2017-Q2" "DEU" "Germany" 729321.5731 0.6 >> "2017-Q3" "DEU" "Germany" 735610.6375 0.9 >> "2017-Q4" "DEU" "Germany" 740991.229 0.7 >> "2018-Q1" "DEU" "Germany" 741969.5787 0.1 >> "2018-Q2" "DEU" "Germany" 744834.6127 0.4 >> "2018-Q3" "DEU" "Germany" 744065.912 -0.1 >> "2018-Q4" "DEU" "Germany" 745603.2305 0.2 >> "2019-Q1" "DEU" "Germany" 748468.2276 0.4 >> "2019-Q2" "DEU" "Germany" 747909.2496 -0.1 >> "2016-Q4" "ISR" "Israel" 307789.55 0.9 >> "2017-Q1" "ISR" "Israel" 308323.023 0.2 >> "2017-Q2" "ISR" "Israel" 311759.624 1.1 >> "2017-Q3" "ISR" "Israel" 315651.46 1.2 >> "2017-Q4" "ISR" "Israel" 319056.442 1.1 >> "2018-Q1" "ISR" "Israel" 322272.592 1 >> "2018-Q2" "ISR" "Israel" 323422.356 0.4 >> "2018-Q3" "ISR" "Israel" 325702.534 0.7 >> "2018-Q4" "ISR" "Israel" 329052.641 1 >> "2019-Q1" "ISR" "Israel" 332851.725 1.2 >> "2019-Q2" "ISR" "Israel" 333686.876 0.3 >> "2016-Q4" "ITA" "Italy" 396162.2 0.5 >> "2017-Q1" "ITA" "Italy" 398379 0.6 >> "2017-Q2" "ITA" "Italy" 399893 0.4 >> "2017-Q3" "ITA" "Italy" 401534 0.4 >> "2017-Q4" "ITA" "Italy" 403053.4 0.4 >> "2018-Q1" "ITA" "Italy" 403937.8 0.2 >> "2018-Q2" "ITA" "Italy" 403977.3 0 >> "2018-Q3" "ITA" "Italy" 403434.2 -0.1 >> "2018-Q4" "ITA" "Italy" 403190.7 -0.1 >> "2019-Q1" "ITA" "Italy" 403697.9 0.1 >> "2019-Q2" "ITA" "Italy" 403794.7 0 >> "2016-Q4" "JPN" "Japan" 130406025 0.2 >> "2017-Q1" "JPN" "Japan" 131558850 0.9 >> "2017-Q2" "JPN" "Japan" 132121450 0.4 >> "2017-Q3" "JPN" "Japan" 133064400 0.7 >> "2017-Q4" "JPN" "Japan" 133475100 0.3 >> "2018-Q1" "JPN" "Japan" 133386850 -0.1 >> "2018-Q2" "JPN" "Japan" 133931825 0.4 >> "2018-Q3" "JPN" "Japan" 133289800 -0.5 >> "2018-Q4" "JPN" "Japan" 133836225 0.4 >> "2019-Q1" "JPN" "Japan" 134777725 0.7 >> "2019-Q2" "JPN" "Japan" 135369050 0.4 >> "2016-Q4" "KOR" "Korea" 431473400 0.8 >> "2017-Q1" "KOR" "Korea" 435435200 0.9 >> "2017-Q2" "KOR" "Korea" 437712100 0.5 >> "2017-Q3" "KOR" "Korea" 444064400 1.5 >> "2017-Q4" "KOR" "Korea" 443599800 -0.1 >> "2018-Q1" "KOR" "Korea" 447909300 1 >> "2018-Q2" "KOR" "Korea" 450495800 0.6 >> "2018-Q3" "KOR" "Korea" 452561100 0.5 >> "2018-Q4" "KOR" "Korea" 456769700 0.9 >> "2019-Q1" "KOR" "Korea" 455081000 -0.4 >> "2019-Q2" "KOR" "Korea" 459958000 1.1 >> "2016-Q4" "NLD" "Netherlands" 178453.593134 0.9 >> "2017-Q1" "NLD" "Netherlands" 179367.793134 0.5 >> "2017-Q2" "NLD" "Netherlands" 180964.533134 0.9 >> "2017-Q3" "NLD" "Netherlands" 182189.893134 0.7 >> "2017-Q4" "NLD" "Netherlands" 183625.193134 0.8 >> "2018-Q1" "NLD" "Netherlands" 184793.473134 0.6 >> "2018-Q2" "NLD" "Netherlands" 185981.973134 0.6 >> "2018-Q3" "NLD" "Netherlands" 186425.153134 0.2 >> "2018-Q4" "NLD" "Netherlands" 187434.343134 0.5 >> "2019-Q1" "NLD" "Netherlands" 188324.263134 0.5 >> "2019-Q2" "NLD" "Netherlands" 189297.773134 0.5 >> "2016-Q4" "NZL" "New Zealand" 59062 0.5 >> "2017-Q1" "NZL" "New Zealand" 59348 0.5 >> "2017-Q2" "NZL" "New Zealand" 59743 0.7 >> "2017-Q3" "NZL" "New Zealand" 60320 1 >> "2017-Q4" "NZL" "New Zealand" 60737 0.7 >> "2018-Q1" "NZL" "New Zealand" 61031 0.5 >> "2018-Q2" "NZL" "New Zealand" 61655 1 >> "2018-Q3" "NZL" "New Zealand" 61927 0.4 >> "2018-Q4" "NZL" "New Zealand" 62282 0.6 >> "2019-Q1" "NZL" "New Zealand" 62800 0.8 >> "2016-Q4" "NOR" "Norway" 784704 2 >> "2017-Q1" "NOR" "Norway" 788709 0.5 >> "2017-Q2" "NOR" "Norway" 794220 0.7 >> "2017-Q3" "NOR" "Norway" 798283 0.5 >> "2017-Q4" "NOR" "Norway" 800232 0.2 >> "2018-Q1" "NOR" "Norway" 803756 0.4 >> "2018-Q2" "NOR" "Norway" 807187 0.4 >> "2018-Q3" "NOR" "Norway" 810942 0.5 >> "2018-Q4" "NOR" "Norway" 815921 0.6 >> "2019-Q1" "NOR" "Norway" 815323 -0.1 >> "2016-Q4" "PRT" "Portugal" 44303.821 0.8 >> "2017-Q1" "PRT" "Portugal" 44632.068 0.7 >> "2017-Q2" "PRT" "Portugal" 44803.721 0.4 >> "2017-Q3" "PRT" "Portugal" 45062.631 0.6 >> "2017-Q4" "PRT" "Portugal" 45426.14 0.8 >> "2018-Q1" "PRT" "Portugal" 45641.37 0.5 >> "2018-Q2" "PRT" "Portugal" 45910.934 0.6 >> "2018-Q3" "PRT" "Portugal" 46027.362 0.3 >> "2018-Q4" "PRT" "Portugal" 46203.578 0.4 >> "2019-Q1" "PRT" "Portugal" 46453.392 0.5 >> "2019-Q2" "PRT" "Portugal" 46685.65896 0.5 >> "2016-Q4" "ESP" "Spain" 279431 0.6 >> "2017-Q1" "ESP" "Spain" 281707 0.8 >> "2017-Q2" "ESP" "Spain" 284169 0.9 >> "2017-Q3" "ESP" "Spain" 285986 0.6 >> "2017-Q4" "ESP" "Spain" 288064 0.7 >> "2018-Q1" "ESP" "Spain" 289861 0.6 >> "2018-Q2" "ESP" "Spain" 291583 0.6 >> "2018-Q3" "ESP" "Spain" 293145 0.5 >> "2018-Q4" "ESP" "Spain" 294768 0.6 >> "2019-Q1" "ESP" "Spain" 296732 0.7 >> "2019-Q2" "ESP" "Spain" 298147 0.5 >> "2016-Q4" "SWE" "Sweden" 1150761 0.4 >> "2017-Q1" "SWE" "Sweden" 1151977 0.1 >> "2017-Q2" "SWE" "Sweden" 1169243 1.5 >> "2017-Q3" "SWE" "Sweden" 1177835 0.7 >> "2017-Q4" "SWE" "Sweden" 1181734 0.3 >> "2018-Q1" "SWE" "Sweden" 1192111 0.9 >> "2018-Q2" "SWE" "Sweden" 1197931 0.5 >> "2018-Q3" "SWE" "Sweden" 1196262 -0.1 >> "2018-Q4" "SWE" "Sweden" 1209430 1.1 >> "2019-Q1" "SWE" "Sweden" 1215583 0.5 >> "2019-Q2" "SWE" "Sweden" 1214691 -0.1 >> "2016-Q4" "CHE" "Switzerland" 168268.356822 -0.1 >> "2017-Q1" "CHE" "Switzerland" 168865.076317 0.4 >> "2017-Q2" "CHE" "Switzerland" 170078.764694 0.7 >> "2017-Q3" "CHE" "Switzerland" 171405.16327 0.8 >> "2017-Q4" "CHE" "Switzerland" 172777.427869 0.8 >> "2018-Q1" "CHE" "Switzerland" 174168.535837 0.8 >> "2018-Q2" "CHE" "Switzerland" 175400.870886 0.7 >> "2018-Q3" "CHE" "Switzerland" 175089.0314 -0.2 >> "2018-Q4" "CHE" "Switzerland" 175664.228343 0.3 >> "2019-Q1" "CHE" "Switzerland" 176651.744992 0.6 >> "2016-Q4" "GBR" "United Kingdom" 496470 0.7 >> "2017-Q1" "GBR" "United Kingdom" 498582 0.4 >> "2017-Q2" "GBR" "United Kingdom" 499885 0.3 >> "2017-Q3" "GBR" "United Kingdom" 502473 0.5 >> "2017-Q4" "GBR" "United Kingdom" 504487 0.4 >> "2018-Q1" "GBR" "United Kingdom" 504785 0.1 >> "2018-Q2" "GBR" "United Kingdom" 506842 0.4 >> "2018-Q3" "GBR" "United Kingdom" 510346 0.7 >> "2018-Q4" "GBR" "United Kingdom" 511482 0.2 >> "2019-Q1" "GBR" "United Kingdom" 514019 0.5 >> "2019-Q2" "GBR" "United Kingdom" 513029 -0.2 >> "2016-Q4" "USA" "United States" 4456057.75 0.5 >> "2017-Q1" "USA" "United States" 4481314 0.6 >> "2017-Q2" "USA" "United States" 4505262 0.5 >> "2017-Q3" "USA" "United States" 4540889.5 0.8 >> "2017-Q4" "USA" "United States" 4580616 0.9 >> "2018-Q1" "USA" "United States" 4609563.5 0.6 >> "2018-Q2" "USA" "United States" 4649533.75 0.9 >> "2018-Q3" "USA" "United States" 4683180 0.7 >> "2018-Q4" "USA" "United States" 4695887 0.3 >> "2019-Q1" "USA" "United States" 4731820.25 0.8 >> "2019-Q2" "USA" "United States" 4755955 0.5 >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code.
Eric Berger
2019-Aug-25 03:21 UTC
[R] Colouring selected columns in a facetted column chart
This seems to work ggplot(t1) + geom_col(aes(x=TIME,y=GDPgr,fill=col),show.legend=FALSE) + scale_fill_manual(values=c("navyblue","red")) + facet_wrap(~Country,ncol=3) HTH, Eric On Sun, Aug 25, 2019 at 5:45 AM <phil at philipsmith.ca> wrote:> Resubmitted as recommended: > > I am having difficulty with a chart using ggplot. It is a facetted > column chart showing GDP growth rates by country. The columns are > coloured navyblue, except that I want to colour the most recent columns, > for 2019-Q1 and 2019-Q2, red. For some countries data are available up > to 2019-Q2 while for others data are only available up to 2019-Q1. My > code and data frame are shown below and it almost works, but not quite. > For some reason the red bars for Germany, Korea, Norway, Sweden and > United Kingdom are slightly off. Any help will be much appreciated. > > Here is my reprex: > > library(tidyverse) > t1 <- read.table("t1.txt",header=TRUE,sep="\t") > col <- rep("navyblue",nrow(t1)) > for (i in 1:nrow(t1)) { > if((t1$TIME[i]=="2019-Q1" | t1$TIME[i]=="2019-Q2")) { > col[i] <- "red"} > } > ggplot(t1) + > geom_col(aes(x=TIME,y=GDPgr),fill=col) + > facet_wrap(~Country,ncol=3) > > Here is my data frame, called "t1.txt", output by dput(): > > structure(list(TIME = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, > 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, > 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, > 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, > 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, > 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, > 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, > 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, > 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, > 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, > 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, > 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, > 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, > 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, > 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, > 5L, 6L, 7L, 8L, 9L, 10L, 11L), .Label = c("2016-Q4", "2017-Q1", > "2017-Q2", "2017-Q3", "2017-Q4", "2018-Q1", "2018-Q2", "2018-Q3", > "2018-Q4", "2019-Q1", "2019-Q2"), class = "factor"), LOCATION > structure(c(1L, > 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, > 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 6L, 6L, > 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, > 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, > 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 5L, 5L, 5L, 5L, > 5L, 5L, 5L, 5L, 5L, 5L, 5L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, > 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, > 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, > 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 16L, 16L, > 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 18L, 18L, 18L, 18L, > 18L, 18L, 18L, 18L, 18L, 18L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, > 17L, 17L, 17L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, > 19L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 20L, 20L, 20L, > 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 4L, 4L, 4L, 4L, 4L, 4L, > 4L, 4L, 4L, 4L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, > 11L, 11L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L > ), .Label = c("AUS", "BEL", "CAN", "CHE", "DEU", "DNK", "ESP", > "EU28", "FIN", "FRA", "GBR", "ISR", "ITA", "JPN", "KOR", "NLD", > "NOR", "NZL", "PRT", "SWE", "USA"), class = "factor"), Country > structure(c(1L, > 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, > 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, > 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, > 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, > 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, > 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, > 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, > 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, > 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, > 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, > 14L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 16L, 16L, > 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, > 17L, 17L, 17L, 17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, > 18L, 18L, 18L, 18L, 18L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, > 19L, 19L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, > 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L), .Label > c("Australia", > "Belgium", "Canada", "Denmark", "European Union (28 countries)", > "Finland", "France", "Germany", "Israel", "Italy", "Japan", "Korea", > "Netherlands", "New Zealand", "Norway", "Portugal", "Spain", > "Sweden", "Switzerland", "United Kingdom", "United States"), class > "factor"), > Value = c(440518, 442141, 445739, 448672, 451302, 455680, > 459697, 461024, 462032, 463907, 106675, 107394, 107828, 108003, > 108744, 109037, 109386, 109676, 110081, 110459, 110680, 493742, > 498719, 504100.5, 505745, 507883, 509758.75, 512958, 515639.25, > 515971.75, 516489.5, 499945, 511319, 505254, 500363, 504837, > 508633, 511901, 513630, 517726, 518368, 3301202.652555, > 3323886.876398, > 3345038.332666, 3367136.027609, 3390431.080785, 3404554.778774, > 3419358.570571, 3430321.169276, 3440915.89772, 3458087.265837, > 3465003.441, 48525, 49368, 49430, 49596, 50153, 50352, 50449, > 50507, 50530, 50822, 551760, 556305, 560160, 563998, 568125, > 569542, 570670, 572387, 574640, 576494, 577905, 716743.4074, > 725268.5864, 729321.5731, 735610.6375, 740991.229, 741969.5787, > 744834.6127, 744065.912, 745603.2305, 748468.2276, 747909.2496, > 307789.55, 308323.023, 311759.624, 315651.46, 319056.442, > 322272.592, 323422.356, 325702.534, 329052.641, 332851.725, > 333686.876, 396162.2, 398379, 399893, 401534, 403053.4, 403937.8, > 403977.3, 403434.2, 403190.7, 403697.9, 403794.7, 130406025, > 131558850, 132121450, 133064400, 133475100, 133386850, 133931825, > 133289800, 133836225, 134777725, 135369050, 431473400, 435435200, > 437712100, 444064400, 443599800, 447909300, 450495800, 452561100, > 456769700, 455081000, 459958000, 178453.593134, 179367.793134, > 180964.533134, 182189.893134, 183625.193134, 184793.473134, > 185981.973134, 186425.153134, 187434.343134, 188324.263134, > 189297.773134, 59062, 59348, 59743, 60320, 60737, 61031, > 61655, 61927, 62282, 62800, 784704, 788709, 794220, 798283, > 800232, 803756, 807187, 810942, 815921, 815323, 44303.821, > 44632.068, 44803.721, 45062.631, 45426.14, 45641.37, 45910.934, > 46027.362, 46203.578, 46453.392, 46685.65896, 279431, 281707, > 284169, 285986, 288064, 289861, 291583, 293145, 294768, 296732, > 298147, 1150761, 1151977, 1169243, 1177835, 1181734, 1192111, > 1197931, 1196262, 1209430, 1215583, 1214691, 168268.356822, > 168865.076317, 170078.764694, 171405.16327, 172777.427869, > 174168.535837, 175400.870886, 175089.0314, 175664.228343, > 176651.744992, 496470, 498582, 499885, 502473, 504487, 504785, > 506842, 510346, 511482, 514019, 513029, 4456057.75, 4481314, > 4505262, 4540889.5, 4580616, 4609563.5, 4649533.75, 4683180, > 4695887, 4731820.25, 4755955), GDPgr = c(1, 0.4, 0.8, 0.7, > 0.6, 1, 0.9, 0.3, 0.2, 0.4, 0.3, 0.7, 0.4, 0.2, 0.7, 0.3, > 0.3, 0.3, 0.4, 0.3, 0.2, 0.6, 1, 1.1, 0.3, 0.4, 0.4, 0.6, > 0.5, 0.1, 0.1, 0.9, 2.3, -1.2, -1, 0.9, 0.8, 0.6, 0.3, 0.8, > 0.1, 0.8, 0.7, 0.6, 0.7, 0.7, 0.4, 0.4, 0.3, 0.3, 0.5, 0.2, > 0.2, 1.7, 0.1, 0.3, 1.1, 0.4, 0.2, 0.1, 0, 0.6, 0.6, 0.8, > 0.7, 0.7, 0.7, 0.2, 0.2, 0.3, 0.4, 0.3, 0.2, 0.4, 1.2, 0.6, > 0.9, 0.7, 0.1, 0.4, -0.1, 0.2, 0.4, -0.1, 0.9, 0.2, 1.1, > 1.2, 1.1, 1, 0.4, 0.7, 1, 1.2, 0.3, 0.5, 0.6, 0.4, 0.4, 0.4, > 0.2, 0, -0.1, -0.1, 0.1, 0, 0.2, 0.9, 0.4, 0.7, 0.3, -0.1, > 0.4, -0.5, 0.4, 0.7, 0.4, 0.8, 0.9, 0.5, 1.5, -0.1, 1, 0.6, > 0.5, 0.9, -0.4, 1.1, 0.9, 0.5, 0.9, 0.7, 0.8, 0.6, 0.6, 0.2, > 0.5, 0.5, 0.5, 0.5, 0.5, 0.7, 1, 0.7, 0.5, 1, 0.4, 0.6, 0.8, > 2, 0.5, 0.7, 0.5, 0.2, 0.4, 0.4, 0.5, 0.6, -0.1, 0.8, 0.7, > 0.4, 0.6, 0.8, 0.5, 0.6, 0.3, 0.4, 0.5, 0.5, 0.6, 0.8, 0.9, > 0.6, 0.7, 0.6, 0.6, 0.5, 0.6, 0.7, 0.5, 0.4, 0.1, 1.5, 0.7, > 0.3, 0.9, 0.5, -0.1, 1.1, 0.5, -0.1, -0.1, 0.4, 0.7, 0.8, > 0.8, 0.8, 0.7, -0.2, 0.3, 0.6, 0.7, 0.4, 0.3, 0.5, 0.4, 0.1, > 0.4, 0.7, 0.2, 0.5, -0.2, 0.5, 0.6, 0.5, 0.8, 0.9, 0.6, 0.9, > 0.7, 0.3, 0.8, 0.5)), class = "data.frame", row.names = c(NA, > -224L)) > > > > On 2019-08-24 22:39, Eric Berger wrote: > > Hi Phil, > > Please resubmit your question with the data frame contents shown as > > the output from the command > > dput(t1.txt). This will make it easier for people to run your reprex > > and respond to your question. > > > > Best, > > Eric > > > > On Sun, Aug 25, 2019 at 5:26 AM <phil at philipsmith.ca> wrote: > > > >> I am having difficulty with a chart using ggplot. It is a facetted > >> column chart showing GDP growth rates by country. The columns are > >> coloured navyblue, except that I want to colour the most recent > >> columns, > >> for 2019-Q1 and 2019-Q2, red. For some countries data are available > >> up > >> to 2019-Q2 while for others data are only available up to 2019-Q1. > >> My > >> code and data frame are shown below and it almost works, but not > >> quite. > >> For some reason the red bars for Germany, Korea, Norway, Sweden and > >> United Kingdom are slightly off. Any help will be much appreciated. > >> > >> Here is my reprex: > >> > >> library(tidyverse) > >> t1 <- read.table("t1.txt",header=TRUE,sep="\t") > >> col <- rep("navyblue",nrow(t1)) > >> for (i in 1:nrow(t1)) { > >> if((t1$TIME[i]=="2019-Q1" | t1$TIME[i]=="2019-Q2")) { > >> col[i] <- "red"} > >> } > >> ggplot(t1) + > >> geom_col(aes(x=TIME,y=GDPgr),fill=col) + > >> facet_wrap(~Country,ncol=3) > >> > >> Here is my data frame, called "t1.txt": > >> > >> "TIME" "LOCATION" "Country" "Value" "GDPgr" > >> "2016-Q4" "AUS" "Australia" 440518 1 > >> "2017-Q1" "AUS" "Australia" 442141 0.4 > >> "2017-Q2" "AUS" "Australia" 445739 0.8 > >> "2017-Q3" "AUS" "Australia" 448672 0.7 > >> "2017-Q4" "AUS" "Australia" 451302 0.6 > >> "2018-Q1" "AUS" "Australia" 455680 1 > >> "2018-Q2" "AUS" "Australia" 459697 0.9 > >> "2018-Q3" "AUS" "Australia" 461024 0.3 > >> "2018-Q4" "AUS" "Australia" 462032 0.2 > >> "2019-Q1" "AUS" "Australia" 463907 0.4 > >> "2016-Q4" "BEL" "Belgium" 106675 0.3 > >> "2017-Q1" "BEL" "Belgium" 107394 0.7 > >> "2017-Q2" "BEL" "Belgium" 107828 0.4 > >> "2017-Q3" "BEL" "Belgium" 108003 0.2 > >> "2017-Q4" "BEL" "Belgium" 108744 0.7 > >> "2018-Q1" "BEL" "Belgium" 109037 0.3 > >> "2018-Q2" "BEL" "Belgium" 109386 0.3 > >> "2018-Q3" "BEL" "Belgium" 109676 0.3 > >> "2018-Q4" "BEL" "Belgium" 110081 0.4 > >> "2019-Q1" "BEL" "Belgium" 110459 0.3 > >> "2019-Q2" "BEL" "Belgium" 110680 0.2 > >> "2016-Q4" "CAN" "Canada" 493742 0.6 > >> "2017-Q1" "CAN" "Canada" 498719 1 > >> "2017-Q2" "CAN" "Canada" 504100.5 1.1 > >> "2017-Q3" "CAN" "Canada" 505745 0.3 > >> "2017-Q4" "CAN" "Canada" 507883 0.4 > >> "2018-Q1" "CAN" "Canada" 509758.75 0.4 > >> "2018-Q2" "CAN" "Canada" 512958 0.6 > >> "2018-Q3" "CAN" "Canada" 515639.25 0.5 > >> "2018-Q4" "CAN" "Canada" 515971.75 0.1 > >> "2019-Q1" "CAN" "Canada" 516489.5 0.1 > >> "2016-Q4" "DNK" "Denmark" 499945 0.9 > >> "2017-Q1" "DNK" "Denmark" 511319 2.3 > >> "2017-Q2" "DNK" "Denmark" 505254 -1.2 > >> "2017-Q3" "DNK" "Denmark" 500363 -1 > >> "2017-Q4" "DNK" "Denmark" 504837 0.9 > >> "2018-Q1" "DNK" "Denmark" 508633 0.8 > >> "2018-Q2" "DNK" "Denmark" 511901 0.6 > >> "2018-Q3" "DNK" "Denmark" 513630 0.3 > >> "2018-Q4" "DNK" "Denmark" 517726 0.8 > >> "2019-Q1" "DNK" "Denmark" 518368 0.1 > >> "2016-Q4" "EU28" "European Union (28 countries)" > >> 3301202.652555 0.8 > >> "2017-Q1" "EU28" "European Union (28 countries)" > >> 3323886.876398 0.7 > >> "2017-Q2" "EU28" "European Union (28 countries)" > >> 3345038.332666 0.6 > >> "2017-Q3" "EU28" "European Union (28 countries)" > >> 3367136.027609 0.7 > >> "2017-Q4" "EU28" "European Union (28 countries)" > >> 3390431.080785 0.7 > >> "2018-Q1" "EU28" "European Union (28 countries)" > >> 3404554.778774 0.4 > >> "2018-Q2" "EU28" "European Union (28 countries)" > >> 3419358.570571 0.4 > >> "2018-Q3" "EU28" "European Union (28 countries)" > >> 3430321.169276 0.3 > >> "2018-Q4" "EU28" "European Union (28 countries)" > >> 3440915.89772 0.3 > >> "2019-Q1" "EU28" "European Union (28 countries)" > >> 3458087.265837 0.5 > >> "2019-Q2" "EU28" "European Union (28 countries)" 3465003.441 > >> 0.2 > >> "2016-Q4" "FIN" "Finland" 48525 0.2 > >> "2017-Q1" "FIN" "Finland" 49368 1.7 > >> "2017-Q2" "FIN" "Finland" 49430 0.1 > >> "2017-Q3" "FIN" "Finland" 49596 0.3 > >> "2017-Q4" "FIN" "Finland" 50153 1.1 > >> "2018-Q1" "FIN" "Finland" 50352 0.4 > >> "2018-Q2" "FIN" "Finland" 50449 0.2 > >> "2018-Q3" "FIN" "Finland" 50507 0.1 > >> "2018-Q4" "FIN" "Finland" 50530 0 > >> "2019-Q1" "FIN" "Finland" 50822 0.6 > >> "2016-Q4" "FRA" "France" 551760 0.6 > >> "2017-Q1" "FRA" "France" 556305 0.8 > >> "2017-Q2" "FRA" "France" 560160 0.7 > >> "2017-Q3" "FRA" "France" 563998 0.7 > >> "2017-Q4" "FRA" "France" 568125 0.7 > >> "2018-Q1" "FRA" "France" 569542 0.2 > >> "2018-Q2" "FRA" "France" 570670 0.2 > >> "2018-Q3" "FRA" "France" 572387 0.3 > >> "2018-Q4" "FRA" "France" 574640 0.4 > >> "2019-Q1" "FRA" "France" 576494 0.3 > >> "2019-Q2" "FRA" "France" 577905 0.2 > >> "2016-Q4" "DEU" "Germany" 716743.4074 0.4 > >> "2017-Q1" "DEU" "Germany" 725268.5864 1.2 > >> "2017-Q2" "DEU" "Germany" 729321.5731 0.6 > >> "2017-Q3" "DEU" "Germany" 735610.6375 0.9 > >> "2017-Q4" "DEU" "Germany" 740991.229 0.7 > >> "2018-Q1" "DEU" "Germany" 741969.5787 0.1 > >> "2018-Q2" "DEU" "Germany" 744834.6127 0.4 > >> "2018-Q3" "DEU" "Germany" 744065.912 -0.1 > >> "2018-Q4" "DEU" "Germany" 745603.2305 0.2 > >> "2019-Q1" "DEU" "Germany" 748468.2276 0.4 > >> "2019-Q2" "DEU" "Germany" 747909.2496 -0.1 > >> "2016-Q4" "ISR" "Israel" 307789.55 0.9 > >> "2017-Q1" "ISR" "Israel" 308323.023 0.2 > >> "2017-Q2" "ISR" "Israel" 311759.624 1.1 > >> "2017-Q3" "ISR" "Israel" 315651.46 1.2 > >> "2017-Q4" "ISR" "Israel" 319056.442 1.1 > >> "2018-Q1" "ISR" "Israel" 322272.592 1 > >> "2018-Q2" "ISR" "Israel" 323422.356 0.4 > >> "2018-Q3" "ISR" "Israel" 325702.534 0.7 > >> "2018-Q4" "ISR" "Israel" 329052.641 1 > >> "2019-Q1" "ISR" "Israel" 332851.725 1.2 > >> "2019-Q2" "ISR" "Israel" 333686.876 0.3 > >> "2016-Q4" "ITA" "Italy" 396162.2 0.5 > >> "2017-Q1" "ITA" "Italy" 398379 0.6 > >> "2017-Q2" "ITA" "Italy" 399893 0.4 > >> "2017-Q3" "ITA" "Italy" 401534 0.4 > >> "2017-Q4" "ITA" "Italy" 403053.4 0.4 > >> "2018-Q1" "ITA" "Italy" 403937.8 0.2 > >> "2018-Q2" "ITA" "Italy" 403977.3 0 > >> "2018-Q3" "ITA" "Italy" 403434.2 -0.1 > >> "2018-Q4" "ITA" "Italy" 403190.7 -0.1 > >> "2019-Q1" "ITA" "Italy" 403697.9 0.1 > >> "2019-Q2" "ITA" "Italy" 403794.7 0 > >> "2016-Q4" "JPN" "Japan" 130406025 0.2 > >> "2017-Q1" "JPN" "Japan" 131558850 0.9 > >> "2017-Q2" "JPN" "Japan" 132121450 0.4 > >> "2017-Q3" "JPN" "Japan" 133064400 0.7 > >> "2017-Q4" "JPN" "Japan" 133475100 0.3 > >> "2018-Q1" "JPN" "Japan" 133386850 -0.1 > >> "2018-Q2" "JPN" "Japan" 133931825 0.4 > >> "2018-Q3" "JPN" "Japan" 133289800 -0.5 > >> "2018-Q4" "JPN" "Japan" 133836225 0.4 > >> "2019-Q1" "JPN" "Japan" 134777725 0.7 > >> "2019-Q2" "JPN" "Japan" 135369050 0.4 > >> "2016-Q4" "KOR" "Korea" 431473400 0.8 > >> "2017-Q1" "KOR" "Korea" 435435200 0.9 > >> "2017-Q2" "KOR" "Korea" 437712100 0.5 > >> "2017-Q3" "KOR" "Korea" 444064400 1.5 > >> "2017-Q4" "KOR" "Korea" 443599800 -0.1 > >> "2018-Q1" "KOR" "Korea" 447909300 1 > >> "2018-Q2" "KOR" "Korea" 450495800 0.6 > >> "2018-Q3" "KOR" "Korea" 452561100 0.5 > >> "2018-Q4" "KOR" "Korea" 456769700 0.9 > >> "2019-Q1" "KOR" "Korea" 455081000 -0.4 > >> "2019-Q2" "KOR" "Korea" 459958000 1.1 > >> "2016-Q4" "NLD" "Netherlands" 178453.593134 0.9 > >> "2017-Q1" "NLD" "Netherlands" 179367.793134 0.5 > >> "2017-Q2" "NLD" "Netherlands" 180964.533134 0.9 > >> "2017-Q3" "NLD" "Netherlands" 182189.893134 0.7 > >> "2017-Q4" "NLD" "Netherlands" 183625.193134 0.8 > >> "2018-Q1" "NLD" "Netherlands" 184793.473134 0.6 > >> "2018-Q2" "NLD" "Netherlands" 185981.973134 0.6 > >> "2018-Q3" "NLD" "Netherlands" 186425.153134 0.2 > >> "2018-Q4" "NLD" "Netherlands" 187434.343134 0.5 > >> "2019-Q1" "NLD" "Netherlands" 188324.263134 0.5 > >> "2019-Q2" "NLD" "Netherlands" 189297.773134 0.5 > >> "2016-Q4" "NZL" "New Zealand" 59062 0.5 > >> "2017-Q1" "NZL" "New Zealand" 59348 0.5 > >> "2017-Q2" "NZL" "New Zealand" 59743 0.7 > >> "2017-Q3" "NZL" "New Zealand" 60320 1 > >> "2017-Q4" "NZL" "New Zealand" 60737 0.7 > >> "2018-Q1" "NZL" "New Zealand" 61031 0.5 > >> "2018-Q2" "NZL" "New Zealand" 61655 1 > >> "2018-Q3" "NZL" "New Zealand" 61927 0.4 > >> "2018-Q4" "NZL" "New Zealand" 62282 0.6 > >> "2019-Q1" "NZL" "New Zealand" 62800 0.8 > >> "2016-Q4" "NOR" "Norway" 784704 2 > >> "2017-Q1" "NOR" "Norway" 788709 0.5 > >> "2017-Q2" "NOR" "Norway" 794220 0.7 > >> "2017-Q3" "NOR" "Norway" 798283 0.5 > >> "2017-Q4" "NOR" "Norway" 800232 0.2 > >> "2018-Q1" "NOR" "Norway" 803756 0.4 > >> "2018-Q2" "NOR" "Norway" 807187 0.4 > >> "2018-Q3" "NOR" "Norway" 810942 0.5 > >> "2018-Q4" "NOR" "Norway" 815921 0.6 > >> "2019-Q1" "NOR" "Norway" 815323 -0.1 > >> "2016-Q4" "PRT" "Portugal" 44303.821 0.8 > >> "2017-Q1" "PRT" "Portugal" 44632.068 0.7 > >> "2017-Q2" "PRT" "Portugal" 44803.721 0.4 > >> "2017-Q3" "PRT" "Portugal" 45062.631 0.6 > >> "2017-Q4" "PRT" "Portugal" 45426.14 0.8 > >> "2018-Q1" "PRT" "Portugal" 45641.37 0.5 > >> "2018-Q2" "PRT" "Portugal" 45910.934 0.6 > >> "2018-Q3" "PRT" "Portugal" 46027.362 0.3 > >> "2018-Q4" "PRT" "Portugal" 46203.578 0.4 > >> "2019-Q1" "PRT" "Portugal" 46453.392 0.5 > >> "2019-Q2" "PRT" "Portugal" 46685.65896 0.5 > >> "2016-Q4" "ESP" "Spain" 279431 0.6 > >> "2017-Q1" "ESP" "Spain" 281707 0.8 > >> "2017-Q2" "ESP" "Spain" 284169 0.9 > >> "2017-Q3" "ESP" "Spain" 285986 0.6 > >> "2017-Q4" "ESP" "Spain" 288064 0.7 > >> "2018-Q1" "ESP" "Spain" 289861 0.6 > >> "2018-Q2" "ESP" "Spain" 291583 0.6 > >> "2018-Q3" "ESP" "Spain" 293145 0.5 > >> "2018-Q4" "ESP" "Spain" 294768 0.6 > >> "2019-Q1" "ESP" "Spain" 296732 0.7 > >> "2019-Q2" "ESP" "Spain" 298147 0.5 > >> "2016-Q4" "SWE" "Sweden" 1150761 0.4 > >> "2017-Q1" "SWE" "Sweden" 1151977 0.1 > >> "2017-Q2" "SWE" "Sweden" 1169243 1.5 > >> "2017-Q3" "SWE" "Sweden" 1177835 0.7 > >> "2017-Q4" "SWE" "Sweden" 1181734 0.3 > >> "2018-Q1" "SWE" "Sweden" 1192111 0.9 > >> "2018-Q2" "SWE" "Sweden" 1197931 0.5 > >> "2018-Q3" "SWE" "Sweden" 1196262 -0.1 > >> "2018-Q4" "SWE" "Sweden" 1209430 1.1 > >> "2019-Q1" "SWE" "Sweden" 1215583 0.5 > >> "2019-Q2" "SWE" "Sweden" 1214691 -0.1 > >> "2016-Q4" "CHE" "Switzerland" 168268.356822 -0.1 > >> "2017-Q1" "CHE" "Switzerland" 168865.076317 0.4 > >> "2017-Q2" "CHE" "Switzerland" 170078.764694 0.7 > >> "2017-Q3" "CHE" "Switzerland" 171405.16327 0.8 > >> "2017-Q4" "CHE" "Switzerland" 172777.427869 0.8 > >> "2018-Q1" "CHE" "Switzerland" 174168.535837 0.8 > >> "2018-Q2" "CHE" "Switzerland" 175400.870886 0.7 > >> "2018-Q3" "CHE" "Switzerland" 175089.0314 -0.2 > >> "2018-Q4" "CHE" "Switzerland" 175664.228343 0.3 > >> "2019-Q1" "CHE" "Switzerland" 176651.744992 0.6 > >> "2016-Q4" "GBR" "United Kingdom" 496470 0.7 > >> "2017-Q1" "GBR" "United Kingdom" 498582 0.4 > >> "2017-Q2" "GBR" "United Kingdom" 499885 0.3 > >> "2017-Q3" "GBR" "United Kingdom" 502473 0.5 > >> "2017-Q4" "GBR" "United Kingdom" 504487 0.4 > >> "2018-Q1" "GBR" "United Kingdom" 504785 0.1 > >> "2018-Q2" "GBR" "United Kingdom" 506842 0.4 > >> "2018-Q3" "GBR" "United Kingdom" 510346 0.7 > >> "2018-Q4" "GBR" "United Kingdom" 511482 0.2 > >> "2019-Q1" "GBR" "United Kingdom" 514019 0.5 > >> "2019-Q2" "GBR" "United Kingdom" 513029 -0.2 > >> "2016-Q4" "USA" "United States" 4456057.75 0.5 > >> "2017-Q1" "USA" "United States" 4481314 0.6 > >> "2017-Q2" "USA" "United States" 4505262 0.5 > >> "2017-Q3" "USA" "United States" 4540889.5 0.8 > >> "2017-Q4" "USA" "United States" 4580616 0.9 > >> "2018-Q1" "USA" "United States" 4609563.5 0.6 > >> "2018-Q2" "USA" "United States" 4649533.75 0.9 > >> "2018-Q3" "USA" "United States" 4683180 0.7 > >> "2018-Q4" "USA" "United States" 4695887 0.3 > >> "2019-Q1" "USA" "United States" 4731820.25 0.8 > >> "2019-Q2" "USA" "United States" 4755955 0.5 > >> > >> ______________________________________________ > >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > >> https://stat.ethz.ch/mailman/listinfo/r-help > >> PLEASE do read the posting guide > >> http://www.R-project.org/posting-guide.html > >> and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Rui Barradas
2019-Aug-25 07:54 UTC
[R] Colouring selected columns in a facetted column chart
Hello, The code in Eric's answer works, but maybe it's better to redo the 'col' code. It's much simpler to create a factor with appropriate labels. Then, the values argument in scale_fill_manual can be set more naturally, it can depend on col. (I have also added a theme to make the axis labels more readable, they were over each other. Remove it if not needed.) col <- (t1$TIME %in% c("2019-Q1", "2019-Q2")) + 1L col <- factor(col, labels = c("navyblue", "red")) ggplot(t1) + geom_col(aes(x = TIME, y = GDPgr, fill = col), show.legend = FALSE) + scale_fill_manual(values = levels(col)) + facet_wrap(~ Country, ncol = 3) + theme(axis.text.x = element_text(angle = 50, hjust = 1)) Hope this helps, Rui Barradas ?s 04:21 de 25/08/19, Eric Berger escreveu:> This seems to work > ggplot(t1) + > geom_col(aes(x=TIME,y=GDPgr,fill=col),show.legend=FALSE) + > scale_fill_manual(values=c("navyblue","red")) + > facet_wrap(~Country,ncol=3) > > HTH, > Eric > > > On Sun, Aug 25, 2019 at 5:45 AM <phil at philipsmith.ca> wrote: > >> Resubmitted as recommended: >> >> I am having difficulty with a chart using ggplot. It is a facetted >> column chart showing GDP growth rates by country. The columns are >> coloured navyblue, except that I want to colour the most recent columns, >> for 2019-Q1 and 2019-Q2, red. For some countries data are available up >> to 2019-Q2 while for others data are only available up to 2019-Q1. My >> code and data frame are shown below and it almost works, but not quite. >> For some reason the red bars for Germany, Korea, Norway, Sweden and >> United Kingdom are slightly off. Any help will be much appreciated. >> >> Here is my reprex: >> >> library(tidyverse) >> t1 <- read.table("t1.txt",header=TRUE,sep="\t") >> col <- rep("navyblue",nrow(t1)) >> for (i in 1:nrow(t1)) { >> if((t1$TIME[i]=="2019-Q1" | t1$TIME[i]=="2019-Q2")) { >> col[i] <- "red"} >> } >> ggplot(t1) + >> geom_col(aes(x=TIME,y=GDPgr),fill=col) + >> facet_wrap(~Country,ncol=3) >> >> Here is my data frame, called "t1.txt", output by dput(): >> >> structure(list(TIME = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, >> 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, >> 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, >> 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, >> 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, >> 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, >> 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, >> 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, >> 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, >> 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, >> 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, >> 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, >> 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, >> 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, >> 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, >> 5L, 6L, 7L, 8L, 9L, 10L, 11L), .Label = c("2016-Q4", "2017-Q1", >> "2017-Q2", "2017-Q3", "2017-Q4", "2018-Q1", "2018-Q2", "2018-Q3", >> "2018-Q4", "2019-Q1", "2019-Q2"), class = "factor"), LOCATION >> structure(c(1L, >> 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, >> 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 6L, 6L, >> 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, >> 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, >> 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 5L, 5L, 5L, 5L, >> 5L, 5L, 5L, 5L, 5L, 5L, 5L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, >> 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, >> 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, >> 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 16L, 16L, >> 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 18L, 18L, 18L, 18L, >> 18L, 18L, 18L, 18L, 18L, 18L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, >> 17L, 17L, 17L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, >> 19L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 20L, 20L, 20L, >> 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 4L, 4L, 4L, 4L, 4L, 4L, >> 4L, 4L, 4L, 4L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, >> 11L, 11L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L >> ), .Label = c("AUS", "BEL", "CAN", "CHE", "DEU", "DNK", "ESP", >> "EU28", "FIN", "FRA", "GBR", "ISR", "ITA", "JPN", "KOR", "NLD", >> "NOR", "NZL", "PRT", "SWE", "USA"), class = "factor"), Country >> structure(c(1L, >> 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, >> 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, >> 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, >> 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, >> 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, >> 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, >> 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, >> 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, >> 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, >> 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, >> 14L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 16L, 16L, >> 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, >> 17L, 17L, 17L, 17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, >> 18L, 18L, 18L, 18L, 18L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, >> 19L, 19L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, >> 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L), .Label >> c("Australia", >> "Belgium", "Canada", "Denmark", "European Union (28 countries)", >> "Finland", "France", "Germany", "Israel", "Italy", "Japan", "Korea", >> "Netherlands", "New Zealand", "Norway", "Portugal", "Spain", >> "Sweden", "Switzerland", "United Kingdom", "United States"), class >> "factor"), >> Value = c(440518, 442141, 445739, 448672, 451302, 455680, >> 459697, 461024, 462032, 463907, 106675, 107394, 107828, 108003, >> 108744, 109037, 109386, 109676, 110081, 110459, 110680, 493742, >> 498719, 504100.5, 505745, 507883, 509758.75, 512958, 515639.25, >> 515971.75, 516489.5, 499945, 511319, 505254, 500363, 504837, >> 508633, 511901, 513630, 517726, 518368, 3301202.652555, >> 3323886.876398, >> 3345038.332666, 3367136.027609, 3390431.080785, 3404554.778774, >> 3419358.570571, 3430321.169276, 3440915.89772, 3458087.265837, >> 3465003.441, 48525, 49368, 49430, 49596, 50153, 50352, 50449, >> 50507, 50530, 50822, 551760, 556305, 560160, 563998, 568125, >> 569542, 570670, 572387, 574640, 576494, 577905, 716743.4074, >> 725268.5864, 729321.5731, 735610.6375, 740991.229, 741969.5787, >> 744834.6127, 744065.912, 745603.2305, 748468.2276, 747909.2496, >> 307789.55, 308323.023, 311759.624, 315651.46, 319056.442, >> 322272.592, 323422.356, 325702.534, 329052.641, 332851.725, >> 333686.876, 396162.2, 398379, 399893, 401534, 403053.4, 403937.8, >> 403977.3, 403434.2, 403190.7, 403697.9, 403794.7, 130406025, >> 131558850, 132121450, 133064400, 133475100, 133386850, 133931825, >> 133289800, 133836225, 134777725, 135369050, 431473400, 435435200, >> 437712100, 444064400, 443599800, 447909300, 450495800, 452561100, >> 456769700, 455081000, 459958000, 178453.593134, 179367.793134, >> 180964.533134, 182189.893134, 183625.193134, 184793.473134, >> 185981.973134, 186425.153134, 187434.343134, 188324.263134, >> 189297.773134, 59062, 59348, 59743, 60320, 60737, 61031, >> 61655, 61927, 62282, 62800, 784704, 788709, 794220, 798283, >> 800232, 803756, 807187, 810942, 815921, 815323, 44303.821, >> 44632.068, 44803.721, 45062.631, 45426.14, 45641.37, 45910.934, >> 46027.362, 46203.578, 46453.392, 46685.65896, 279431, 281707, >> 284169, 285986, 288064, 289861, 291583, 293145, 294768, 296732, >> 298147, 1150761, 1151977, 1169243, 1177835, 1181734, 1192111, >> 1197931, 1196262, 1209430, 1215583, 1214691, 168268.356822, >> 168865.076317, 170078.764694, 171405.16327, 172777.427869, >> 174168.535837, 175400.870886, 175089.0314, 175664.228343, >> 176651.744992, 496470, 498582, 499885, 502473, 504487, 504785, >> 506842, 510346, 511482, 514019, 513029, 4456057.75, 4481314, >> 4505262, 4540889.5, 4580616, 4609563.5, 4649533.75, 4683180, >> 4695887, 4731820.25, 4755955), GDPgr = c(1, 0.4, 0.8, 0.7, >> 0.6, 1, 0.9, 0.3, 0.2, 0.4, 0.3, 0.7, 0.4, 0.2, 0.7, 0.3, >> 0.3, 0.3, 0.4, 0.3, 0.2, 0.6, 1, 1.1, 0.3, 0.4, 0.4, 0.6, >> 0.5, 0.1, 0.1, 0.9, 2.3, -1.2, -1, 0.9, 0.8, 0.6, 0.3, 0.8, >> 0.1, 0.8, 0.7, 0.6, 0.7, 0.7, 0.4, 0.4, 0.3, 0.3, 0.5, 0.2, >> 0.2, 1.7, 0.1, 0.3, 1.1, 0.4, 0.2, 0.1, 0, 0.6, 0.6, 0.8, >> 0.7, 0.7, 0.7, 0.2, 0.2, 0.3, 0.4, 0.3, 0.2, 0.4, 1.2, 0.6, >> 0.9, 0.7, 0.1, 0.4, -0.1, 0.2, 0.4, -0.1, 0.9, 0.2, 1.1, >> 1.2, 1.1, 1, 0.4, 0.7, 1, 1.2, 0.3, 0.5, 0.6, 0.4, 0.4, 0.4, >> 0.2, 0, -0.1, -0.1, 0.1, 0, 0.2, 0.9, 0.4, 0.7, 0.3, -0.1, >> 0.4, -0.5, 0.4, 0.7, 0.4, 0.8, 0.9, 0.5, 1.5, -0.1, 1, 0.6, >> 0.5, 0.9, -0.4, 1.1, 0.9, 0.5, 0.9, 0.7, 0.8, 0.6, 0.6, 0.2, >> 0.5, 0.5, 0.5, 0.5, 0.5, 0.7, 1, 0.7, 0.5, 1, 0.4, 0.6, 0.8, >> 2, 0.5, 0.7, 0.5, 0.2, 0.4, 0.4, 0.5, 0.6, -0.1, 0.8, 0.7, >> 0.4, 0.6, 0.8, 0.5, 0.6, 0.3, 0.4, 0.5, 0.5, 0.6, 0.8, 0.9, >> 0.6, 0.7, 0.6, 0.6, 0.5, 0.6, 0.7, 0.5, 0.4, 0.1, 1.5, 0.7, >> 0.3, 0.9, 0.5, -0.1, 1.1, 0.5, -0.1, -0.1, 0.4, 0.7, 0.8, >> 0.8, 0.8, 0.7, -0.2, 0.3, 0.6, 0.7, 0.4, 0.3, 0.5, 0.4, 0.1, >> 0.4, 0.7, 0.2, 0.5, -0.2, 0.5, 0.6, 0.5, 0.8, 0.9, 0.6, 0.9, >> 0.7, 0.3, 0.8, 0.5)), class = "data.frame", row.names = c(NA, >> -224L)) >> >> >> >> On 2019-08-24 22:39, Eric Berger wrote: >>> Hi Phil, >>> Please resubmit your question with the data frame contents shown as >>> the output from the command >>> dput(t1.txt). This will make it easier for people to run your reprex >>> and respond to your question. >>> >>> Best, >>> Eric >>> >>> On Sun, Aug 25, 2019 at 5:26 AM <phil at philipsmith.ca> wrote: >>> >>>> I am having difficulty with a chart using ggplot. It is a facetted >>>> column chart showing GDP growth rates by country. The columns are >>>> coloured navyblue, except that I want to colour the most recent >>>> columns, >>>> for 2019-Q1 and 2019-Q2, red. For some countries data are available >>>> up >>>> to 2019-Q2 while for others data are only available up to 2019-Q1. >>>> My >>>> code and data frame are shown below and it almost works, but not >>>> quite. >>>> For some reason the red bars for Germany, Korea, Norway, Sweden and >>>> United Kingdom are slightly off. Any help will be much appreciated. >>>> >>>> Here is my reprex: >>>> >>>> library(tidyverse) >>>> t1 <- read.table("t1.txt",header=TRUE,sep="\t") >>>> col <- rep("navyblue",nrow(t1)) >>>> for (i in 1:nrow(t1)) { >>>> if((t1$TIME[i]=="2019-Q1" | t1$TIME[i]=="2019-Q2")) { >>>> col[i] <- "red"} >>>> } >>>> ggplot(t1) + >>>> geom_col(aes(x=TIME,y=GDPgr),fill=col) + >>>> facet_wrap(~Country,ncol=3) >>>> >>>> Here is my data frame, called "t1.txt": >>>> >>>> "TIME" "LOCATION" "Country" "Value" "GDPgr" >>>> "2016-Q4" "AUS" "Australia" 440518 1 >>>> "2017-Q1" "AUS" "Australia" 442141 0.4 >>>> "2017-Q2" "AUS" "Australia" 445739 0.8 >>>> "2017-Q3" "AUS" "Australia" 448672 0.7 >>>> "2017-Q4" "AUS" "Australia" 451302 0.6 >>>> "2018-Q1" "AUS" "Australia" 455680 1 >>>> "2018-Q2" "AUS" "Australia" 459697 0.9 >>>> "2018-Q3" "AUS" "Australia" 461024 0.3 >>>> "2018-Q4" "AUS" "Australia" 462032 0.2 >>>> "2019-Q1" "AUS" "Australia" 463907 0.4 >>>> "2016-Q4" "BEL" "Belgium" 106675 0.3 >>>> "2017-Q1" "BEL" "Belgium" 107394 0.7 >>>> "2017-Q2" "BEL" "Belgium" 107828 0.4 >>>> "2017-Q3" "BEL" "Belgium" 108003 0.2 >>>> "2017-Q4" "BEL" "Belgium" 108744 0.7 >>>> "2018-Q1" "BEL" "Belgium" 109037 0.3 >>>> "2018-Q2" "BEL" "Belgium" 109386 0.3 >>>> "2018-Q3" "BEL" "Belgium" 109676 0.3 >>>> "2018-Q4" "BEL" "Belgium" 110081 0.4 >>>> "2019-Q1" "BEL" "Belgium" 110459 0.3 >>>> "2019-Q2" "BEL" "Belgium" 110680 0.2 >>>> "2016-Q4" "CAN" "Canada" 493742 0.6 >>>> "2017-Q1" "CAN" "Canada" 498719 1 >>>> "2017-Q2" "CAN" "Canada" 504100.5 1.1 >>>> "2017-Q3" "CAN" "Canada" 505745 0.3 >>>> "2017-Q4" "CAN" "Canada" 507883 0.4 >>>> "2018-Q1" "CAN" "Canada" 509758.75 0.4 >>>> "2018-Q2" "CAN" "Canada" 512958 0.6 >>>> "2018-Q3" "CAN" "Canada" 515639.25 0.5 >>>> "2018-Q4" "CAN" "Canada" 515971.75 0.1 >>>> "2019-Q1" "CAN" "Canada" 516489.5 0.1 >>>> "2016-Q4" "DNK" "Denmark" 499945 0.9 >>>> "2017-Q1" "DNK" "Denmark" 511319 2.3 >>>> "2017-Q2" "DNK" "Denmark" 505254 -1.2 >>>> "2017-Q3" "DNK" "Denmark" 500363 -1 >>>> "2017-Q4" "DNK" "Denmark" 504837 0.9 >>>> "2018-Q1" "DNK" "Denmark" 508633 0.8 >>>> "2018-Q2" "DNK" "Denmark" 511901 0.6 >>>> "2018-Q3" "DNK" "Denmark" 513630 0.3 >>>> "2018-Q4" "DNK" "Denmark" 517726 0.8 >>>> "2019-Q1" "DNK" "Denmark" 518368 0.1 >>>> "2016-Q4" "EU28" "European Union (28 countries)" >>>> 3301202.652555 0.8 >>>> "2017-Q1" "EU28" "European Union (28 countries)" >>>> 3323886.876398 0.7 >>>> "2017-Q2" "EU28" "European Union (28 countries)" >>>> 3345038.332666 0.6 >>>> "2017-Q3" "EU28" "European Union (28 countries)" >>>> 3367136.027609 0.7 >>>> "2017-Q4" "EU28" "European Union (28 countries)" >>>> 3390431.080785 0.7 >>>> "2018-Q1" "EU28" "European Union (28 countries)" >>>> 3404554.778774 0.4 >>>> "2018-Q2" "EU28" "European Union (28 countries)" >>>> 3419358.570571 0.4 >>>> "2018-Q3" "EU28" "European Union (28 countries)" >>>> 3430321.169276 0.3 >>>> "2018-Q4" "EU28" "European Union (28 countries)" >>>> 3440915.89772 0.3 >>>> "2019-Q1" "EU28" "European Union (28 countries)" >>>> 3458087.265837 0.5 >>>> "2019-Q2" "EU28" "European Union (28 countries)" 3465003.441 >>>> 0.2 >>>> "2016-Q4" "FIN" "Finland" 48525 0.2 >>>> "2017-Q1" "FIN" "Finland" 49368 1.7 >>>> "2017-Q2" "FIN" "Finland" 49430 0.1 >>>> "2017-Q3" "FIN" "Finland" 49596 0.3 >>>> "2017-Q4" "FIN" "Finland" 50153 1.1 >>>> "2018-Q1" "FIN" "Finland" 50352 0.4 >>>> "2018-Q2" "FIN" "Finland" 50449 0.2 >>>> "2018-Q3" "FIN" "Finland" 50507 0.1 >>>> "2018-Q4" "FIN" "Finland" 50530 0 >>>> "2019-Q1" "FIN" "Finland" 50822 0.6 >>>> "2016-Q4" "FRA" "France" 551760 0.6 >>>> "2017-Q1" "FRA" "France" 556305 0.8 >>>> "2017-Q2" "FRA" "France" 560160 0.7 >>>> "2017-Q3" "FRA" "France" 563998 0.7 >>>> "2017-Q4" "FRA" "France" 568125 0.7 >>>> "2018-Q1" "FRA" "France" 569542 0.2 >>>> "2018-Q2" "FRA" "France" 570670 0.2 >>>> "2018-Q3" "FRA" "France" 572387 0.3 >>>> "2018-Q4" "FRA" "France" 574640 0.4 >>>> "2019-Q1" "FRA" "France" 576494 0.3 >>>> "2019-Q2" "FRA" "France" 577905 0.2 >>>> "2016-Q4" "DEU" "Germany" 716743.4074 0.4 >>>> "2017-Q1" "DEU" "Germany" 725268.5864 1.2 >>>> "2017-Q2" "DEU" "Germany" 729321.5731 0.6 >>>> "2017-Q3" "DEU" "Germany" 735610.6375 0.9 >>>> "2017-Q4" "DEU" "Germany" 740991.229 0.7 >>>> "2018-Q1" "DEU" "Germany" 741969.5787 0.1 >>>> "2018-Q2" "DEU" "Germany" 744834.6127 0.4 >>>> "2018-Q3" "DEU" "Germany" 744065.912 -0.1 >>>> "2018-Q4" "DEU" "Germany" 745603.2305 0.2 >>>> "2019-Q1" "DEU" "Germany" 748468.2276 0.4 >>>> "2019-Q2" "DEU" "Germany" 747909.2496 -0.1 >>>> "2016-Q4" "ISR" "Israel" 307789.55 0.9 >>>> "2017-Q1" "ISR" "Israel" 308323.023 0.2 >>>> "2017-Q2" "ISR" "Israel" 311759.624 1.1 >>>> "2017-Q3" "ISR" "Israel" 315651.46 1.2 >>>> "2017-Q4" "ISR" "Israel" 319056.442 1.1 >>>> "2018-Q1" "ISR" "Israel" 322272.592 1 >>>> "2018-Q2" "ISR" "Israel" 323422.356 0.4 >>>> "2018-Q3" "ISR" "Israel" 325702.534 0.7 >>>> "2018-Q4" "ISR" "Israel" 329052.641 1 >>>> "2019-Q1" "ISR" "Israel" 332851.725 1.2 >>>> "2019-Q2" "ISR" "Israel" 333686.876 0.3 >>>> "2016-Q4" "ITA" "Italy" 396162.2 0.5 >>>> "2017-Q1" "ITA" "Italy" 398379 0.6 >>>> "2017-Q2" "ITA" "Italy" 399893 0.4 >>>> "2017-Q3" "ITA" "Italy" 401534 0.4 >>>> "2017-Q4" "ITA" "Italy" 403053.4 0.4 >>>> "2018-Q1" "ITA" "Italy" 403937.8 0.2 >>>> "2018-Q2" "ITA" "Italy" 403977.3 0 >>>> "2018-Q3" "ITA" "Italy" 403434.2 -0.1 >>>> "2018-Q4" "ITA" "Italy" 403190.7 -0.1 >>>> "2019-Q1" "ITA" "Italy" 403697.9 0.1 >>>> "2019-Q2" "ITA" "Italy" 403794.7 0 >>>> "2016-Q4" "JPN" "Japan" 130406025 0.2 >>>> "2017-Q1" "JPN" "Japan" 131558850 0.9 >>>> "2017-Q2" "JPN" "Japan" 132121450 0.4 >>>> "2017-Q3" "JPN" "Japan" 133064400 0.7 >>>> "2017-Q4" "JPN" "Japan" 133475100 0.3 >>>> "2018-Q1" "JPN" "Japan" 133386850 -0.1 >>>> "2018-Q2" "JPN" "Japan" 133931825 0.4 >>>> "2018-Q3" "JPN" "Japan" 133289800 -0.5 >>>> "2018-Q4" "JPN" "Japan" 133836225 0.4 >>>> "2019-Q1" "JPN" "Japan" 134777725 0.7 >>>> "2019-Q2" "JPN" "Japan" 135369050 0.4 >>>> "2016-Q4" "KOR" "Korea" 431473400 0.8 >>>> "2017-Q1" "KOR" "Korea" 435435200 0.9 >>>> "2017-Q2" "KOR" "Korea" 437712100 0.5 >>>> "2017-Q3" "KOR" "Korea" 444064400 1.5 >>>> "2017-Q4" "KOR" "Korea" 443599800 -0.1 >>>> "2018-Q1" "KOR" "Korea" 447909300 1 >>>> "2018-Q2" "KOR" "Korea" 450495800 0.6 >>>> "2018-Q3" "KOR" "Korea" 452561100 0.5 >>>> "2018-Q4" "KOR" "Korea" 456769700 0.9 >>>> "2019-Q1" "KOR" "Korea" 455081000 -0.4 >>>> "2019-Q2" "KOR" "Korea" 459958000 1.1 >>>> "2016-Q4" "NLD" "Netherlands" 178453.593134 0.9 >>>> "2017-Q1" "NLD" "Netherlands" 179367.793134 0.5 >>>> "2017-Q2" "NLD" "Netherlands" 180964.533134 0.9 >>>> "2017-Q3" "NLD" "Netherlands" 182189.893134 0.7 >>>> "2017-Q4" "NLD" "Netherlands" 183625.193134 0.8 >>>> "2018-Q1" "NLD" "Netherlands" 184793.473134 0.6 >>>> "2018-Q2" "NLD" "Netherlands" 185981.973134 0.6 >>>> "2018-Q3" "NLD" "Netherlands" 186425.153134 0.2 >>>> "2018-Q4" "NLD" "Netherlands" 187434.343134 0.5 >>>> "2019-Q1" "NLD" "Netherlands" 188324.263134 0.5 >>>> "2019-Q2" "NLD" "Netherlands" 189297.773134 0.5 >>>> "2016-Q4" "NZL" "New Zealand" 59062 0.5 >>>> "2017-Q1" "NZL" "New Zealand" 59348 0.5 >>>> "2017-Q2" "NZL" "New Zealand" 59743 0.7 >>>> "2017-Q3" "NZL" "New Zealand" 60320 1 >>>> "2017-Q4" "NZL" "New Zealand" 60737 0.7 >>>> "2018-Q1" "NZL" "New Zealand" 61031 0.5 >>>> "2018-Q2" "NZL" "New Zealand" 61655 1 >>>> "2018-Q3" "NZL" "New Zealand" 61927 0.4 >>>> "2018-Q4" "NZL" "New Zealand" 62282 0.6 >>>> "2019-Q1" "NZL" "New Zealand" 62800 0.8 >>>> "2016-Q4" "NOR" "Norway" 784704 2 >>>> "2017-Q1" "NOR" "Norway" 788709 0.5 >>>> "2017-Q2" "NOR" "Norway" 794220 0.7 >>>> "2017-Q3" "NOR" "Norway" 798283 0.5 >>>> "2017-Q4" "NOR" "Norway" 800232 0.2 >>>> "2018-Q1" "NOR" "Norway" 803756 0.4 >>>> "2018-Q2" "NOR" "Norway" 807187 0.4 >>>> "2018-Q3" "NOR" "Norway" 810942 0.5 >>>> "2018-Q4" "NOR" "Norway" 815921 0.6 >>>> "2019-Q1" "NOR" "Norway" 815323 -0.1 >>>> "2016-Q4" "PRT" "Portugal" 44303.821 0.8 >>>> "2017-Q1" "PRT" "Portugal" 44632.068 0.7 >>>> "2017-Q2" "PRT" "Portugal" 44803.721 0.4 >>>> "2017-Q3" "PRT" "Portugal" 45062.631 0.6 >>>> "2017-Q4" "PRT" "Portugal" 45426.14 0.8 >>>> "2018-Q1" "PRT" "Portugal" 45641.37 0.5 >>>> "2018-Q2" "PRT" "Portugal" 45910.934 0.6 >>>> "2018-Q3" "PRT" "Portugal" 46027.362 0.3 >>>> "2018-Q4" "PRT" "Portugal" 46203.578 0.4 >>>> "2019-Q1" "PRT" "Portugal" 46453.392 0.5 >>>> "2019-Q2" "PRT" "Portugal" 46685.65896 0.5 >>>> "2016-Q4" "ESP" "Spain" 279431 0.6 >>>> "2017-Q1" "ESP" "Spain" 281707 0.8 >>>> "2017-Q2" "ESP" "Spain" 284169 0.9 >>>> "2017-Q3" "ESP" "Spain" 285986 0.6 >>>> "2017-Q4" "ESP" "Spain" 288064 0.7 >>>> "2018-Q1" "ESP" "Spain" 289861 0.6 >>>> "2018-Q2" "ESP" "Spain" 291583 0.6 >>>> "2018-Q3" "ESP" "Spain" 293145 0.5 >>>> "2018-Q4" "ESP" "Spain" 294768 0.6 >>>> "2019-Q1" "ESP" "Spain" 296732 0.7 >>>> "2019-Q2" "ESP" "Spain" 298147 0.5 >>>> "2016-Q4" "SWE" "Sweden" 1150761 0.4 >>>> "2017-Q1" "SWE" "Sweden" 1151977 0.1 >>>> "2017-Q2" "SWE" "Sweden" 1169243 1.5 >>>> "2017-Q3" "SWE" "Sweden" 1177835 0.7 >>>> "2017-Q4" "SWE" "Sweden" 1181734 0.3 >>>> "2018-Q1" "SWE" "Sweden" 1192111 0.9 >>>> "2018-Q2" "SWE" "Sweden" 1197931 0.5 >>>> "2018-Q3" "SWE" "Sweden" 1196262 -0.1 >>>> "2018-Q4" "SWE" "Sweden" 1209430 1.1 >>>> "2019-Q1" "SWE" "Sweden" 1215583 0.5 >>>> "2019-Q2" "SWE" "Sweden" 1214691 -0.1 >>>> "2016-Q4" "CHE" "Switzerland" 168268.356822 -0.1 >>>> "2017-Q1" "CHE" "Switzerland" 168865.076317 0.4 >>>> "2017-Q2" "CHE" "Switzerland" 170078.764694 0.7 >>>> "2017-Q3" "CHE" "Switzerland" 171405.16327 0.8 >>>> "2017-Q4" "CHE" "Switzerland" 172777.427869 0.8 >>>> "2018-Q1" "CHE" "Switzerland" 174168.535837 0.8 >>>> "2018-Q2" "CHE" "Switzerland" 175400.870886 0.7 >>>> "2018-Q3" "CHE" "Switzerland" 175089.0314 -0.2 >>>> "2018-Q4" "CHE" "Switzerland" 175664.228343 0.3 >>>> "2019-Q1" "CHE" "Switzerland" 176651.744992 0.6 >>>> "2016-Q4" "GBR" "United Kingdom" 496470 0.7 >>>> "2017-Q1" "GBR" "United Kingdom" 498582 0.4 >>>> "2017-Q2" "GBR" "United Kingdom" 499885 0.3 >>>> "2017-Q3" "GBR" "United Kingdom" 502473 0.5 >>>> "2017-Q4" "GBR" "United Kingdom" 504487 0.4 >>>> "2018-Q1" "GBR" "United Kingdom" 504785 0.1 >>>> "2018-Q2" "GBR" "United Kingdom" 506842 0.4 >>>> "2018-Q3" "GBR" "United Kingdom" 510346 0.7 >>>> "2018-Q4" "GBR" "United Kingdom" 511482 0.2 >>>> "2019-Q1" "GBR" "United Kingdom" 514019 0.5 >>>> "2019-Q2" "GBR" "United Kingdom" 513029 -0.2 >>>> "2016-Q4" "USA" "United States" 4456057.75 0.5 >>>> "2017-Q1" "USA" "United States" 4481314 0.6 >>>> "2017-Q2" "USA" "United States" 4505262 0.5 >>>> "2017-Q3" "USA" "United States" 4540889.5 0.8 >>>> "2017-Q4" "USA" "United States" 4580616 0.9 >>>> "2018-Q1" "USA" "United States" 4609563.5 0.6 >>>> "2018-Q2" "USA" "United States" 4649533.75 0.9 >>>> "2018-Q3" "USA" "United States" 4683180 0.7 >>>> "2018-Q4" "USA" "United States" 4695887 0.3 >>>> "2019-Q1" "USA" "United States" 4731820.25 0.8 >>>> "2019-Q2" "USA" "United States" 4755955 0.5 >>>> >>>> ______________________________________________ >>>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >>>> https://stat.ethz.ch/mailman/listinfo/r-help >>>> PLEASE do read the posting guide >>>> http://www.R-project.org/posting-guide.html >>>> and provide commented, minimal, self-contained, reproducible code. >> > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >