Bubble Plot of Negative and Positive values in space ggplot2 R - r

I would like to make a bubble plot using ggplot2 in R. My code and data are found below.
Please leave the colors as they are. I am having difficulties in scaling positive and negative values equally. For example, -3 is scaled smaller than +3. I would like negatives and positives to be scaled proportionately irrespective of sign.
Identify negative from positive values using some kind of outline linetype for bubbles and include it in the legend.
Also remove the "Mean" part of the legend.
Thanks very much for your great help.
#=====================================================================
library(ggplot2)
if (dev.cur() == 1) x11(width=8,height=6)
par(mfcol=c(1,1))
p<-ggplot(site.resiudal, aes(x=Eastings, y=Northings, size=Mean,label=site.resiudal$Site,legend = FALSE))+
#theme(legend.position="none")+
geom_point(shape=21)+
geom_point(aes(colour = factor(Region)))+
scale_area(range=c(1,15))+
scale_alpha(guide = 'none')+
scale_x_continuous(name="Longitude", limits=c(-120,-95))+
scale_y_continuous(name="Latitude", limits=c(48,61))+
geom_text(size=4)+
scale_colour_manual(name="Region",labels = c("A", "B","C","D", "E"),values = c("1" = "firebrick3","2" = "palegreen4","3" = "sandybrown","4" = "red","5" = "gray0"))+
theme(legend.title = element_text(colour="black", size=16, face="plain"))+
theme(legend.text = element_text(colour="black", size = 16, face = "plain"))
p
#Data[["sign"]] = ifelse(Data[["Mean"]] >= 0, "positive", "negative")
#=================================================
structure(list(Site = structure(c(101L, 102L, 105L, 107L, 108L,
110L, 111L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L,
13L, 14L, 16L, 20L, 47L, 52L, 53L, 55L, 91L, 92L, 93L, 94L, 95L,
96L, 99L, 15L, 17L, 18L, 19L, 21L, 114L, 23L, 26L, 36L, 59L,
60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L,
73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L,
86L, 87L, 88L, 89L, 98L, 100L, 103L, 104L, 106L, 109L, 112L,
113L, 115L, 116L, 117L, 119L, 42L, 44L, 46L, 48L, 49L, 50L, 51L,
54L, 56L, 57L, 58L, 90L, 97L, 118L, 120L, 22L, 24L, 25L, 27L,
28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 37L, 38L, 39L, 40L, 41L,
43L, 45L), .Label = c("G100", "G101", "G102", "G103", "G104",
"G105", "G106", "G107", "G108", "G109", "G110", "G111", "G112",
"G113", "G114", "G115", "G116", "G117", "G118", "G119", "G120",
"GG10", "GG11", "GG12", "GG13", "GG14", "GG15", "GG16", "GG17",
"GG18", "GG19", "GG20", "GG21", "GG22", "GG23", "GG24", "GG25",
"GG26", "GG27", "GG28", "GG29", "GG30", "GG31", "GG32", "GG33",
"GG34", "GG35", "GG36", "GG37", "GG38", "GG39", "GG40", "GG41",
"GG42", "GG43", "GG44", "GG45", "GG46", "GG47", "GG48", "GG49",
"GG50", "GG51", "GG52", "GG53", "GG54", "GG55", "GG56", "GG57",
"GG58", "GG59", "GG60", "GG61", "GG62", "GG63", "GG64", "GG65",
"GG66", "GG67", "GG68", "GG69", "GG70", "GG71", "GG72", "GG73",
"GG74", "GG75", "GG76", "GG77", "GG78", "GG79", "GG80", "GG81",
"GG82", "GG83", "GG84", "GG85", "GG86", "GG87", "GG88", "GG89",
"GG90", "GG91", "GG92", "GG93", "GG94", "GG95", "GG96", "GG97",
"GG98", "GG99", "GGG1", "GGG2", "GGG3", "GGG4", "GGG5", "GGG6",
"GGG7", "GGG8", "GGG9"), class = "factor"), Name = structure(c(53L,
87L, 29L, 92L, 36L, 76L, 102L, 103L, 119L, 2L, 9L, 11L, 45L,
47L, 49L, 54L, 90L, 30L, 105L, 66L, 78L, 107L, 81L, 42L, 41L,
43L, 59L, 110L, 24L, 27L, 56L, 61L, 64L, 118L, 40L, 21L, 44L,
70L, 108L, 25L, 58L, 98L, 83L, 5L, 19L, 26L, 31L, 38L, 55L, 60L,
71L, 74L, 75L, 85L, 95L, 120L, 109L, 1L, 67L, 20L, 50L, 63L,
106L, 111L, 116L, 62L, 6L, 99L, 114L, 73L, 84L, 89L, 93L, 97L,
115L, 80L, 10L, 12L, 88L, 79L, 15L, 17L, 33L, 35L, 94L, 100L,
3L, 16L, 37L, 101L, 117L, 8L, 39L, 48L, 86L, 113L, 23L, 13L,
69L, 96L, 104L, 32L, 65L, 82L, 14L, 22L, 18L, 46L, 68L, 72L,
77L, 91L, 112L, 4L, 7L, 28L, 51L, 57L, 52L, 34L), .Label = c("ANEROID",
"ARBORG", "ATHABASCA", "BANFF", "BANGOR", "BATTLEFORD", "BEAVER MINES",
"BEAVERLODGE", "BERENS RIVER", "BIRTLE", "BISSETT", "BRANDON",
"BUFFALO NARROWS", "CALGARY", "CALMAR", "CAMPSIE", "CAMROSE",
"CARWAY", "CEYLON", "CHAPLIN", "CHURCHILL", "CLARESHOLM", "COLD LAKE",
"COLLINS BAY", "CORONATION", "COTE", "CREE LAKE", "CROWSNEST",
"CYPRESS RIVER", "DAUPHIN", "DAVIDSON", "DRUMHELLER", "EDMONTON",
"EDSON", "ELK POINT", "EMERSON AUT", "ENILDA-BERG", "ESTEVAN",
"FAIRVIEW", "FLIN FLON", "FORT CHIPEWYAN", "FORT MCMURRAY", "FORT VERMILION",
"GILLAM", "GIMLI", "GLEICHEN", "GRAND RAPIDS", "GRANDE PRAIRIE",
"GREAT FALLS", "HIGH POINT", "HIGHWOOD", "HINTON VALLEY", "HUDSON BAY",
"INDIAN BAY", "INDIAN HEAD", "ISLAND FALLS", "JASPER WARDEN",
"JENNER", "KEG RIVER RS", "KELLIHER", "KEY LAKE", "KINDERSLEY",
"KLINTONEL", "LA RONGE", "LACOMBE 2", "LANGRUTH WEST", "LEADER",
"LETHBRIDGE", "LOON LAKE", "LYNN LAKE", "MANOR", "MEDICINE HAT",
"MELFORT", "MOOSE JAW", "MOOSOMIN", "MORDEN", "MOUNTAIN VIEW",
"NEEPAWA MURRAY", "NINETTE", "NIPAWIN", "NORWAY HOUSE", "OLDS",
"ONEFOUR", "OUTLOOK", "PASWEGIN", "PEACE RIVER", "PELLY", "PIERSON",
"PILGER", "PINAWA WNRE", "PINCHER CREEK ", "PORTAGE PRAIRIE",
"PRINCE ALBERT", "RANFURLY", "REGINA", "ROCKY MT HOUSE ", "SASKATOON",
"SCOTFIELD", "SCOTT", "SION", "SLAVE LAKE", "SPRAGUE", "STEINBACH",
"STETTLER NORTH", "SWAN RIVER", "SWIFT CURRENT", "THE PAS", "THOMPSON",
"TONKIN", "URANIUM CITY ", "VAL-MARIE", "VAUXHALL", "WABASCA RS",
"WASECA", "WASKESIU LAKE", "WEST POPLAR", "WHITECOURT", "WHITESAND DAM",
"WINNIPEG", "YELLOW GRASS"), class = "factor"), Mean = c(-0.020525899,
0.333863493, 0.210353772, NA, NA, 0.093520458, 0.341295298, NA,
-0.175074657, 0.09834825, 0.075610648, NA, -0.117503802, 0.18309367,
0.25246942, 0.221329766, 0.072167004, -0.094766032, NA, NA, 0.19783711,
-0.166351357, -0.0996169, -0.038555432, -0.028092042, 0.297855371,
0.108263891, 0.002057761, 0.327731415, NA, 0.180100638, 0.193837736,
-0.003306948, 0.178881894, 0.3655509, -0.235975798, -0.176154056,
-0.080433735, -0.110955273, -0.228010105, 0.048103255, -0.116681527,
-0.073042421, NA, NA, 0.035356012, 0.297171565, -0.197834719,
0.036412958, 0.055218077, NA, -0.236229087, 0.265211081, 0.271625885,
-0.293179359, 0.113744571, -0.207770026, 0.100471248, -0.071569464,
NA, NA, NA, -0.052716493, 0.057385851, 0.090340517, -0.30456625,
-0.234420722, 0.082287977, 0.009973663, NA, -0.06405062, 0.074703356,
-0.208329196, -0.272401078, 0.217991554, -0.043619919, -0.208901155,
-0.020022401, 0.111495318, NA, 0.38239749, 0.199136959, -0.177740258,
NA, 0.147515615, 0.309306538, 0.298741467, 0.068170296, NA, -0.02102765,
0.001754313, -0.010196512, 0.108254156, -0.228183063, -0.196261239,
NA, -0.167054722, 0.039949534, 0.154337034, -0.020855461, 0.136010278,
NA, 0.096997744, NA, -0.241963754, 0.660176529, 0.423554314,
0.190305726, -0.210778787, -0.261148915, NA, 0.054264129, -0.098706619,
-0.138776994, NA, NA, NA, -0.113823745, 0.373292721, -0.047060083
), Eastings = c(-102.5800018, -101.8700027, -99.08000183, -98.26999664,
-97.23000336, -98.08000183, -95.59999847, -96.76999664, -97.23000336,
-97.08000183, -97.02999878, -95.69999695, -97.01999664, -99.27999878,
-96, -95.19999695, -96.06999969, -100.0500031, -101.2300034,
-98.80000305, -99.56999969, -101.0999985, -97.84999847, -111.2200012,
-111.1200027, -116.0299988, -117.6200027, -108.4800034, -103.6999969,
-107.1299973, -102.3499985, -105.6200027, -105.2699966, -103.1500015,
-101.8799973, -94.06999969, -94.72000122, -101.0800018, -97.87000275,
-111.4499969, -111.1999969, -111.3499985, -110.4700012, -102.2799988,
-104.6500015, -101.7799988, -105.9800034, -102.9700012, -103.6500015,
-103.75, -102.0999985, -105.5500031, -101.6699982, -103.9199982,
-104.6699982, -104.1800003, -102.2300034, -107.3000031, -109.5,
-106.6500015, -107.9300003, -108.9199982, -107.7300034, -107.8499985,
-106.3799973, -109.1800003, -108.25, -108.8300018, -109.4000015,
-104.5999985, -107.0500031, -105.1500015, -105.6699982, -106.7200012,
-106.0699997, -104, -101.0500031, -99.94999695, -101.2699966,
-99.65000153, -113.8499985, -112.8199997, -113.5800018, -111.0699997,
-111.7300034, -114.1200027, -113.2799988, -114.6800003, -116.3000031,
-114.7799988, -115.7799988, -119.4000015, -118.5299988, -118.8799973,
-117.4499969, -113.8300018, -110.2799988, -108.4300003, -109.0999985,
-114.9199982, -112.7200012, -112.8700027, -113.75, -114.0999985,
-114.0199966, -113.7300034, -113.3799973, -113.0500031, -112.8000031,
-110.7200012, -113.6299973, -113.9800034, -112.1299973, -115.5500031,
-114.1800003, -114.4800034, -114.3700027, -118.0299988, -117.5299988,
-116.4499969), Northings = c(52.88000107, 52.08000183, 49.54999924,
49.95000076, 49, 49.18000031, 49.02000046, 49.52999878, 49.91999817,
50.93000031, 52.34999847, 51.02999878, 50.63000107, 53.15000153,
50.47000122, 49.61999893, 50.18000031, 51.09999847, 52.11999893,
50.41999817, 50.15000153, 53.97000122, 53.97000122, 56.65000153,
58.77000046, 58.38000107, 57.75, 59.56999969, 58.18000031, 57.34999847,
55.52999878, 57.25, 55.15000153, 56.22999954, 54.77000046, 58.72999954,
56.34999847, 56.86999893, 55.79999924, 52.06999969, 50.72000122,
51.58000183, 49.11999893, 50.90000153, 49.38000107, 51.52000046,
51.27000046, 49.22000122, 50.54999924, 51.25, 49.61999893, 50.33000183,
50.13000107, 51.97999954, 50.43000031, 49.81999969, 51.20000076,
49.72000122, 50.90000153, 50.47000122, 50.97999954, 49.68000031,
50.27000046, 49.36999893, 49, 51.52000046, 52.77000046, 52.36999893,
53.13000107, 52.81999969, 51.47999954, 52.41999817, 53.22000122,
52.16999817, 53.91999817, 53.33000183, 50.43000031, 49.91999817,
49.18000031, 49.41999817, 53.27999878, 53.02999878, 53.31999969,
53.88000107, 53.41999817, 53.88000107, 54.72000122, 54.13000107,
55.41999817, 55.27999878, 54.15000153, 55.20000076, 56.08000183,
55.18000031, 56.22999954, 55.97000122, 54.41999817, 55.83000183,
54.04999924, 52.41999817, 52.33000183, 51.47000122, 52.45000076,
51.77999878, 51.11999893, 49.93000031, 49, 50.88000107, 49.63000107,
50.02000046, 49.13000107, 49.52000046, 50.04999924, 51.20000076,
49.47000122, 49.63000107, 50.54999924, 52.93000031, 53.40000153,
53.58000183), Region = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L)), .Names = c("Site",
"Name", "Mean", "Eastings", "Northings", "Region"), class = "data.frame", row.names = c(NA,
-120L))
#============================================

use abs()
eg
instead of size=Mean use size=abs(Mean)
Then, you can track the sign using shape (or some other aesthetic, but color and size are already taken)
replace:
geom_point(shape=21)+
geom_point(aes(colour = factor(Region))) +
with the single line
geom_point(aes(shape=factor(sign(Mean)), colour = factor(Region))) +
If you'd like, you can also add lines such as
scale_shape_discrete(name="Mean Is", breaks=c(-1, 1), labels=c("Negative", "Positive"))
guides(size=FALSE)

Related

Is there a way to produce multiple x-y scatterplots at once based on grouping value, ordered by a third variable?

I have multi-level data. The group level is individual persons, which are designated by id. The variable index indicates different time points. Is there a way to make a separate scatterplot (x vs. y) for each individual, all displayed in the same output, and ordered based on a third variable (z)? If so, can color then be added to indicate degree of third variable (z)? Data below, Thanks.
> dput(dat1.1)
structure(list(id = c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L), index = c(1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L), x = c(7.443917, 7.520429, 7.446833,
8.07893, 8.534033, 8.263931, 7.598647, 6.902987, 7.672617, 7.739256,
7.591341, 8.101125, 7.811751, 6.596834, 6.637652, 8.467165, 7.835399,
6.500149, 7.083198, 7.531798, 6.110208, 6.368534, 5.26318, 6.735778,
5.580152, 5.460161, 5.844303, 6.258181, 7.191627, 5.105033, 6.760193,
5.857215, 5.866264, 6.769086, 6.547294, 5.623804, 4.675815, 6.153901,
6.040519, 6.236045, 8.216397, 6.097841, 5.491311, 5.831432, 6.297337,
6.655688, 5.553445, 6.37449, 6.271961, 6.959645, 7.080341, 6.46092,
6.476955, 7.221111, 6.219023, NA, NA, NA, NA, NA, 8.21752, 7.589581,
8.363739, 8.849697, 7.78645, 7.494006, 7.827766, 9.11352, 7.80884,
6.701855, 6.259061, 5.523358, 6.186617, 6.548538, 6.6937, 7.213297,
5.243428, 7.510827, 7.054297, 7.603241), y = c(106L, 114L, 50L,
50L, 56L, 46L, 50L, 52L, 114L, 50L, 56L, 26L, 48L, 52L, 48L,
54L, 54L, 56L, 52L, 50L, 84L, 86L, 88L, 86L, 82L, 84L, 88L, 84L,
86L, 84L, 86L, 86L, 84L, 84L, 88L, 88L, 88L, 84L, 86L, 120L,
106L, 168L, 116L, 56L, 108L, 68L, 68L, 70L, 74L, 76L, 76L, 76L,
72L, 70L, 118L, NA, NA, NA, NA, NA, 60L, 62L, 52L, 90L, 50L,
50L, 54L, 56L, 52L, 30L, 78L, 30L, 52L, 54L, 52L, 80L, 86L, 46L,
54L, 84L), z = c(33L, 33L, 33L, 33L, 33L, 33L, 33L, 33L, 33L,
33L, 33L, 33L, 33L, 33L, 33L, 33L, 33L, 33L, 33L, 33L, 54L, 54L,
54L, 54L, 54L, 54L, 54L, 54L, 54L, 54L, 54L, 54L, 54L, 54L, 54L,
54L, 54L, 54L, 54L, 54L, 56L, 56L, 56L, 56L, 56L, 56L, 56L, 56L,
56L, 56L, 56L, 56L, 56L, 56L, 56L, 56L, 56L, 56L, 56L, 56L, 50L,
50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L, 50L,
50L, 50L, 50L, 50L, 50L, 50L)), class = "data.frame", row.names = c(NA,
-80L))
Does this come close to giving you what you want?
library(tidyverse)
d %>%
group_by(id) %>%
mutate(z=as.factor(z)) %>%
group_map(
function(.x, .y) {
.x %>%
ggplot() +
geom_point(aes(x=x, y=y, colour=z)) +
facet_wrap(vars(z)) +
scale_colour_manual(drop=FALSE, values=d %>% distinct(z) %>% pull(z)) +
labs(title=.x$id[1])
},
.keep=TRUE
)
Points to note:
group_map applies a function to each group of a grouped data frame. .x refers to the data in the current group, .y is a one row tibble defining the group. .keep requests that the grouping variables are kept in .x.
drop=FALSE in the call to scale_colour_manual() ensures that unused factor levels are retained in the legend (and hence different levels of z are distinguishable between plots).

How to identify (not remove) SETS of data that are duplicated? Dplyr or other solution?

so I have data about Sites, nested in Class. In each Site there is a Time (timepoint) variable. The data of interest is Count1, Total1, Count2, Total2.
I know there are whole duplicate sets within Class, across Sites for the values of Count1, Total1, Count2, Total2 for Time.
Here's what I mean - Let's say we have Class 1, with the first Site:
Class Site Time Count1 Total1 Count2 Total2
1 a0QjvO281o1 1 8 64 4 34
1 a0QjvO281o1 2 16 64 8 34
1 a0QjvO281o1 3 16 64 8 34
1 a0QjvO281o1 4 16 64 8 34
1 a0QjvO281o1 6 8 64 4 34
And, I've noticed there are several other Sites with this EXACT pattern (or other repeated patterns).
Class Site Time Count1 Total1 Count2 Total2
1 zlG1VmpE6QQ 1 8 64 4 34
1 zlG1VmpE6QQ 2 16 64 8 34
1 zlG1VmpE6QQ 3 16 64 8 34
1 zlG1VmpE6QQ 4 16 64 8 34
1 zlG1VmpE6QQ 6 8 64 4 34
I want to identify within Class how many Sites have the same pattern. Either marking them or reducing the data sets to the first unique site pattern, but I would like to be able to say how many Sites fit each found pattern.
So, here's the partial data:
df <-
structure(list(Class = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), Site = structure(c(3L,
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 6L, 6L, 6L, 6L, 6L, 9L, 9L,
9L, 9L, 9L, 17L, 17L, 17L, 17L, 17L, 19L, 19L, 19L, 19L, 19L,
30L, 30L, 30L, 30L, 30L, 49L, 49L, 49L, 49L, 49L, 54L, 54L, 54L,
54L, 54L, 56L, 56L, 56L, 56L, 56L, 62L, 62L, 62L, 62L, 62L, 66L,
66L, 66L, 66L, 66L, 86L, 86L, 86L, 86L, 86L, 88L, 88L, 88L, 88L,
88L, 98L, 98L, 98L, 98L, 98L, 33L, 33L, 33L, 33L, 33L, 128L,
128L, 128L, 128L, 128L, 141L, 141L, 141L, 141L, 141L, 153L, 153L,
153L, 153L, 153L, 154L, 154L, 154L, 154L, 154L, 274L, 274L, 274L,
274L, 274L, 291L, 291L, 291L, 291L, 291L, 306L, 306L, 306L, 306L,
306L, 309L, 309L, 309L, 309L, 309L, 336L, 336L, 336L, 336L, 336L,
342L, 342L, 342L, 342L, 342L, 396L, 396L, 396L, 396L, 396L, 413L,
413L, 413L, 413L, 413L, 418L, 418L, 418L, 418L, 418L, 435L, 435L,
435L, 435L, 435L, 451L), .Label = c("~", "A0e3A15Lh1d", "a0QjvO281o1",
"A0R2gEqRbTv", "A4J3Jp6KNz2", "A757EHpLOya", "A8kkDgEvEZV", "ab5F7MfRxZW",
"AcjfpLUXjwt", "admxsO3fTtq", "aEBm7REs6XS", "AEZgWxwdbd9", "AezXCsZxd2U",
"AFjm1YmnfyO", "AFTwI0xBM6e", "aGw7PyLMEkl", "aHNXoYj7uNJ", "AibLRYCSE4P",
"aitNX6Qxkon", "ajEqsuhE9fV", "aJFDh98Iahb", "AKG4BvCUVsF", "AMtGkXGugJb",
"aNczAtKAJsv", "aoY0wrz6qBF", "aOz3ikxG7qM", "aPWuF0rDfuJ", "aQrGXlhzEJB",
"ARu0wnYDkam", "As7tGowP84e", "AsqolR3dfgv", "atj39UeK8N9", "atmjKVCRnzw",
"aUhP7zZ7LPU", "aUMEQzUKI0K", "AuP8NAgS7Th", "aUyy9i4fwhS", "AVFW2vlGxds",
"awoAlwC06Go", "awxCmxmeea2", "AWYFb5fwcYb", "Ax2Q16uPW55", "AXO6R085bth",
"Ay6W05BTgDV", "aZMeFIlkevS", "B08adcYOEl7", "b5MVFPi1inY", "B7fffQm5omx",
"ba3kFfcKXNk", "bCK7hWM4bnK", "BDlYKSCaOIG", "BE3TZDysXuQ", "bErpy9bSZAV",
"Beu6pmpSDJE", "BgfNJiJlDrF", "bGUeQEEpq7q", "bgWDDBsRLIL", "bHwo17fsILI",
"bifefa8JnfN", "bIQ3gsw51RH", "bisxDvmwluW", "biy6fHoOcZp", "bK7yQP8LNkJ",
"Bke0tWeJyBr", "bKMNhuIYaYW", "blkWvfFDVm6", "bnaDFC8EVAo", "BNDeQ6sJctI",
"Bokks2ESodd", "BoKlS77F7Il", "BqLRDDu69ic", "bqoZAzbsajz", "BRlA0HkkMGM",
"bT501IhkxV9", "BTliRZoJs4i", "bTTf1R7zgRn", "bTZAPQPXgI5", "BUtglXWCjkf",
"BvcJEyVWsGG", "bVHpRZguCL2", "BVymUZcbCuf", "BwkVolONMBn", "bWtq9NnOoCU",
"c2YR2oDyx7t", "c3dhvyZuPum", "c3LYcysugey", "c46Q9ExLocA", "C52gwcl9fmp",
"c5IYnQ3M7dj", "c6yCKEAemfr", "C8uv1qapHmC", "Ca2rjTu7g6A", "cAsHVMiIVHT",
"cB7mNM1MNm0", "Cbboq0XBHn1", "cbUfMWJl9sK", "ccixNtjWLkf", "ccL7Esacksn",
"CgmvbI2pkyK", "cGvhZR5kDxQ", "chFA8wLA953", "cIb00kbYPgm", "cjoj6MxgfxE",
"cJrxpXipqCm", "cMR1ECoHpE4", "CmRKRa25mZu", "cnCuI3VeJKt", "cNUlz8NllVu",
"CoySgwRgeRE", "CpZyeEzz39h", "CqIH5ytvqTS", "cRbK3weaIO6", "cs2MtDT1y17",
"CSVVXoe0xGC", "ctEZrxoEucg", "CxCDdfOd0Nj", "cXzO64qne5O", "CZq12nSSyn9",
"CzTmTRr0krx", "d3F3FBUFtWi", "d3f8P40FxnS", "d3thFMLEOGr", "d3UA2wZLHlM",
"D3wXzwwrBE7", "D4Bb0bZE5eK", "D5BprGY8EIU", "D5F054OKtW4", "D9nOWZAX3yT",
"DAcTRfO0CNG", "DbjU3iBZtGx", "Dd4sp3zIfSJ", "DDC8Dws74Zz", "DEFzmar1QtJ",
"dEoQWkLavTj", "deVhoPko4Bh", "DFBDO1gXQwf", "DfdvXXyNSoV", "dGCqYO3Zi6p",
"DGDkUV76OgX", "Dgt3VcFh8rl", "DHdEugYqcEI", "Dhku9zrZoJe", "dHokR5oLiIl",
"DhPZWGceA1Q", "DiKXevYOYNB", "DJIgnE1QQbB", "dkR7YOB6UT6", "dKy3aHycCap",
"dl9g8UYxk20", "DLmEBtWqO9S", "DLza3NSQYUI", "dmUHnTHgfYg", "dnRXJOdEzdw",
"doRK8OhG0kd", "DQaEryfraV6", "dQk8ubXxXLX", "dQOwWKXxFeq", "DrHlSXIHalR",
"DrLeENdZwxX", "DRUaAOrybxb", "dSJcUkmJWvZ", "dSuHNzaRaSf", "dtDftsTowRA",
"DVF2BNdSzV9", "DW7NajJs9ry", "dw94DZyrpUZ", "Dxa8RiDlXB6", "dXBB3LIqhd8",
"dY1ATXbywBu", "DY3V0E6pUYD", "dYIdx3HoWbL", "DZMyvdZEDeB", "dZrjKdqCi1w",
"e2cMNKCnHOw", "E2g3H9rUdML", "e59NHDOFTWC", "E6KoR8hXk7P", "E6vLBntf9QE",
"E8PnLO9QRcE", "e9NQxtBNruk", "e9QjFd6fZ4I", "EAdX1JPb4Dm", "eCGBeD0uz0D",
"ECHaJeidpTR", "edLdPyMjbaz", "EefeXxr8yDS", "ef6tzAcpMeF", "eFB6BfJ2BTY",
"EjFYleP5G9K", "eLGdmsoRjWn", "ElmgbenqYn7", "EM5PauW0KWg", "EmhBF1JUw3i",
"enR40fiMtoo", "EpxhEmcMVXh", "EQpPsVwWvqz", "EQtHhnAYjJp", "erfgs35WGXU",
"eRNEYF9OfA8", "ERqjIjzKnNm", "EsdcJsyJTJG", "ESNgljw6VvC", "eSZjKIwHPYi",
"etyPfIkrlrM", "Eu1JrO8bBkB", "euFWewBZ5Xr", "EVaNkH5nz1s", "eXgA6Zfn6KQ",
"EXIi96SW1Bm", "eYPdhvwFirr", "eZ2NazTVbb6", "EzN8D82lOTp", "F03oK0VRgyk",
"f0WCSs2fwvv", "F3CHKWYM2Pb", "f3FoF8cpKiH", "F42k81lXXMO", "F8ZvmoAy2bh",
"fd5zuIbL3Qd", "fDN9KAuRv2o", "FdqK3U8rDRX", "fG2ws21A6Lj", "fgDQSAYp5pj",
"FGjbxwib4q5", "FgLXwaIGGbn", "FiqXUXkRHXr", "fiuesJ8f3xw", "fJAqAOFzB2b",
"fJmQ6P38mHh", "fJy2O3xh1fV", "FjZuMxKuYvb", "FKe5fQHbu8l", "FKuw35vjqRz",
"FmAQ159jI3w", "FMGmKkEOmV4", "FmuzZuFFMzD", "FMX7RNQIwYu", "FNUYBvpbWaA",
"fnzDrz05g0T", "FO80di9Jxuk", "FOKfyVchS21", "fP0XmUTTfks", "fpCA3TMnMA3",
"FPkj0JvlmyK", "FPSoejJAWSU", "FqkwtkM7eXB", "FqlQZiGKxpr", "FThJa71HEEs",
"FVaQ3fSHtT5", "FvQrsd2gVeu", "fx7bCRgdYic", "FxrH3E1ge0f", "fYtsyMj84LY",
"G0EID1cpxEB", "g4jJZ1SNP4I", "g7AYmMzlRL5", "G7hnxrBDXd2", "GCQVHCnV25O",
"GcYMteoIkw9", "GDCM1IWa7Zh", "gdsUTJnwdzb", "Ge7oZ5R4iBk", "gEff10Pq35y",
"GFPi9bpW3sN", "ggMEnqgD9kD", "gKR0a28tTp5", "gKRGyOXbpzj", "glEuzcZNWIM",
"GlWdTuycHxs", "glyDmwEFzrr", "gmmjFqs7MFB", "GMWgNQ8JB1r", "gqFwQOY1wSE",
"gqNh2d7WJva", "grKa7EwswRX", "gsIY3JD3iHh", "GSWPAgMxhy2", "gsX0auFXP9m",
"Gtef53Qyxrj", "GTQqEhUUV1F", "guGv3PY445Z", "gUve5bZAut8", "gVZ58EQOH6K",
"GwXv8OX78AT", "GXIQmznIdQe", "GxIVLRDNmVF", "GziA2Vc0HX4", "h0RMK448nhs",
"H0vjaO76Wg8", "H1G7wWYemSm", "H3mOm6sbODE", "h4IQGhyYAQp", "H6LR8zRVQLW",
"hAoSAyLR3I6", "HB6ZBS6kyJ8", "HcKIEHFgpDb", "hCuRPOStRLU", "HdTW2XJg3IO",
"HdxFUpXFp2O", "hFwwNnFm1B8", "hHMHykeQBua", "HI3Z2eSmWYl", "hiRGzSqrLx5",
"hjeei4JLTiF", "HjwC2LDSWHK", "HlElMRh1t6W", "hlIZJlEsd7B", "hLwLFwQgUdb",
"HmIC1eI4aEQ", "HmuBn2Tdutx", "HN6AdgqShbf", "hoSu28MRYPv", "hq6x4qBOYsg",
"HQHoA9YKMAI", "hqvimuJJhKL", "hrpWiEmnynY", "hsLoXTDJDib", "htJFOM9EYmH",
"HU4RdTNlezp", "hWWRAoV26mI", "HXA0U1WlIhx", "hxckGietsww", "Hy4Uo9AjrnA",
"hy52ywnDIAM", "Hy5stTfQzCG", "HZd0k5dqZ9h", "hZV0CekLNni", "i0rzEGmhViY",
"i0UbyVCIMMY", "I21MUYJoVMy", "I2G30Bxw2BX", "I2tQnsS7wn6", "I3n104WlitM",
"i3UCGccuhCZ", "i4KTQ0RGK3T", "i5GWQwiObW1", "I5NWo4ucWB3", "I6v4GYaXpQC",
"i7xMMyJ6A6E", "IAvpgvgrG0f", "iBB477oQopG", "IBhZ0h4Ap4D", "IbltT4i4TK6",
"Icts0NC4qAd", "IesVnrPQeSZ", "IFINQSPg4YM", "IFTZCzzniHQ", "IFvY9G1PHAV",
"igDf6uUnTYe", "iHIs3hIFf0i", "IHWMvXnrYmQ", "Ii0xFlLHHXz", "iI2i5pPbl5B",
"Iiwy3Zv7iLb", "iJax0w1KHEN", "ijl4gbKzr3X", "IJwB2CRmy7D", "IKMMHGYtcDC",
"ikpa1wjF92j", "iL8UKqtpf9G", "ILiQ2JLmcLT", "ILJAF0UeEJj", "in5GYhicsOP",
"INcVgc44sm9", "ioVTytF5utn", "iPY8yPbKyA0", "IQIfv1gEqzC", "iqKq6QyUII5",
"iqopOI7y0N3", "ITafa9GjY9I", "ITzEvGOU2GR", "IuymlqNZCLI", "ivq1Bh0PvUd",
"iwrIeTg1XFz", "iWvqk82htTQ", "IxcUubx1fw5", "j2k93SJevE1", "j2X8kPMcchC",
"j6UnkDFKZc1", "j7218NqxjYe", "j8DdqpZn2qc", "j8FYrPT09Sd", "J9JOpPQB23Y",
"jaDbDaXw0Pc", "JcZ2R7KZzTq", "jdswhtT866l", "JE6sdkvuc9S", "JeSc2hThLHY",
"JEWdR4I9TIm", "jf0RxRXJQD0", "jFFOiUs7WoZ", "jhngb8KdYU1", "jiIV8o3C0qx",
"jJ1tYGFTuaR", "JJD60zjyHFp", "jKg6rpNATKH", "jlaaYySSxTv", "JlEPa3N6EgO",
"jlZ6LAYKEo9", "JMhFN7V0B1r", "JMr6AvPnW1M", "JnJtmnGCY95", "JnsP1SLvvsw",
"jOl9gZtASeV", "Jq4XG5c63t1", "JqfwjhLrHs7", "JrxejHLYDML", "JTNDUJAu3DA",
"jUtaZ7I8azt", "juWqrHQgdew", "jVb0CSg6sIR", "JVHpkK4exDw", "JVk9m9vVA1D",
"jWFefvuCwnA", "jXoQbHS18G7", "JYfu3Ld3AuN", "K2Lh8hkI6ST", "K3RIalye4fw",
"K3rIsFyLwv7", "k6fqIh47UYc", "K7re2lFVRfv", "K9HNTtT80IM", "kAQQIuh4eZr",
"KbEhvcWmvAf", "KBMxpwB6DCO", "KBybjbIp9VK", "kCdAI1b02G6", "KCPICjUZcE4",
"kCQMO6wkkV5", "KCtzRrOqmal", "kdDCRlEWqYr", "kdUL3XxL1bF", "kdXwwhZfS7V",
"kEeOSZheoND", "kEhPOqEXXk0", "kGE4jAoYn5L", "KHXn2gzpI0j", "KjMGcLd3XXd",
"kK6NYM3jZkd", "kKsL2QkNR4K", "kl6QWeL9RDW", "klThMLasoQV", "KmfuUMQ7T93",
"Kn9F1mXO0GV", "KNU8WQL2zSc", "KP6O1BkuoPX", "KPF6QKOADPR", "KpV6xl78isl",
"KqyKD3POUbS", "KQYxmgQNUSD", "KRQ61nuKa1b", "KtDVkM6bDeW", "ktTYjYLEW3v",
"kubDpNzUTG7", "KujnNfVcY2N", "kVJ0jf7P7Wf", "kWBZ1e0JH5h", "Kwts2m2rUUp",
"KxEa3dXzAYv", "kyGz0JzX3Z0", "kzHnYcum1wX", "L3iJ4hZ2ypn", "l7dBO27dhA6",
"l7RKRoGgmlq", "L7xlpOoRnWm", "LaH8j5yWJZ1", "lawU1EpVZVc", "LBEkbl9SzHf",
"lbvPWYrpTPw", "LcWVIO0Jsqj", "LDmpwdWKomn", "leQOMrPQiqf", "LFOfMnjCDvJ",
"lgEnN00o6mZ", "lGgWFnakeII", "LHie5mY8Uj8", "lIEtVHeJ086", "LiLYwGv2WWN",
"lJ41xkkb1jI", "LJFDVm4S9HF", "LJzqA45qmSZ", "llQAyMkWXID", "LmBKIXa2mSL",
"LmwBbNZehh2", "lnkTmWmupfH", "lPAr5SfstTF", "lpCdKHJgyDr", "lQfxQMSOVqP",
"lS1XvFsr6no", "lUDMkJxSxHL", "Lw70k8Wjzp4", "LXWKW1xwmoZ", "lYNYlzUvgos",
"LYZ27cymGw5", "LZ1OWhYhPiZ", "m4ue4ZOdIep", "m6E2SxuEKtc", "m7fmNp4WilZ",
"m8FGZ1tP0UE", "M8kI8XD6qF9", "Ma2YKDqULAr", "MA3CYGbUEaG", "MAk4KZRu1L9",
"MAtmMxsNpeZ", "mC01s0xdGEm", "MCE5Y33BYDN", "MCT0SGxhkuU", "MdmyzozNJ02",
"mDNJnXJ3Bap", "ME541MEplIz", "ME9FWjRMe4e", "mePQU0trYhJ", "MFT0CnzHbgk",
"MFy31o7euAb", "mfZwiJJpZcR", "MgptQftlksp", "mgUgOViogq7", "MI2vOsP8NSo",
"MjCkEceL336", "mJY0L6TiTId", "MkU5WMbgI4U", "mKYg307awDr", "MM5BhvP1qVK",
"MM5CMbf9hxl", "mnshKO7lVDt", "moicbsA41fH", "mOSub2ULY1O", "Mpi4Xzop4kw",
"mPQwmRVhsKK", "mpxTG4BSHvb", "mR9nchmQZXC", "mruhLKuBF86", "mVZB3R5M66F",
"MW1EtjyMl5d", "MXHQSQfyHl2", "My1mHzVMqV6", "Mynld4Vekod", "N1giIHXfzhb",
"N23VxXj21Wv", "N2gVM6xHjXX", "n33C6ztvpqu", "N3LQS3eat8p", "n46vbqoLchh",
"N4rlgJRGUs3", "n5H2FaL7kap", "N5PPLwwES0c", "N6CPQoLRnz6", "N8nfcWXZtit",
"NawPD8q2KC8", "nChFLgqqH0w", "NCqjtm01Y4E", "NdMiR2VVel6", "nfR5nCiNHMC",
"nfwoSSAiWjg", "nfWs6WgmRC2", "nG7qJqJR13Z", "NGHkoHvBwF0", "nH6JZBFhCXs",
"nhfdWznpsqJ", "nhnQpVPQ7zK", "nhsj9HCnhEs", "nHtTsUMZoVG", "nIhIdZmXLXS",
"NIsmtALRuS5", "nj2KML2oqvV", "NJKcpotvrAQ", "nkXtOreJnSJ", "NLBLC0uWFuB",
"nmdSUueCjti", "NP8pgYnty0q", "NQxDKw6jGTj", "NSZxDwLVCeC", "nUanptGavqT",
"Nv5WX50ktwr", "nvJQYEQIFFM", "nvXHNeXXvJ5", "nwbO0NqAg7S", "nWJFiQq1vDL",
"nx2J294i6hk", "nxgu0uT1tLT", "NxKCqlm0eTG", "NYEpdnELJ54", "nYIBsKHueFr",
"nYnOM20f4fb", "NZxaguajfAY", "O1U2KTQp7RW", "O2p0zdfIFmP", "o3nzTkLC1Pl",
"o3pKyi7ckFO", "o4gtcJidna5", "O4slz8eLLn6", "o79rSRM0UlM", "O7qGvpaAt2w",
"oByIGUGsrgx", "od9Sosf2Y0V", "oDTFc2FqImi", "OdyuvCVU9Hz", "oEFK7vjkTU0",
"oEXOZcbaHxA", "OgLIyzin181", "OHtxRBRAzYs", "oJNbeCd6bvb", "oJsgj7WMDkq",
"OLEt9ovMHrz", "OlkZe7ivV0p", "oN0anW8xCpq", "oNDzB1D5as4", "oNfV9ntBJ9u",
"oNttkuJFbwC", "ooElCfPc54o", "OpEVn6IiULE", "OQ3BQRswMx7", "oTB157EY3jY",
"otmVyzT3xRC", "oUWkMygGP2W", "owxf1XoQ3Lu", "oYgWYWUVt2h", "OYjhvD7DqIP",
"oZfnfo46pS4", "p1NV2hE2fCZ", "p25NocgpHkc", "P2eQdjxbuZo", "p3T3oB4tfNN",
"P3Uob5UKAoM", "p4hBFnI8WIp", "p5L7w9Tjay3", "p7C2DczQikw", "P8tFheT6TtS",
"P91Rf8wCj7Z", "p9J64kFu5Fd", "PDOfJJdpbob", "pdRTIO2JqPL", "PDWC7RxX4t9",
"pEAFBcOJIVF", "PEfq6d3TONP", "PeNS8yHqYH1", "pEvaEn24SR1", "pg9F69FU9fh",
"Pi6v7zcA26e", "PibIwh4xKHI", "PicYz4ZaEkF", "PIm96jtkVB5", "pIVjHCsQgJI",
"PJI3sARzQAG", "PK027w8aZ5K", "PKfz9RYfKzF", "pl8h1HdqpFW", "pl9IGnhmOJc",
"PlISiBPN3db", "pMiRPEvyleJ", "pMtEAU5iVTB", "PnB0GLiMdBm", "PPb3XMcCAf3",
"PSdLvfFlDRF", "pthlRKVLgNp", "PTZfXfOkUR1", "pWmPB9No5RJ", "PWXwPbUM2DB",
"pxPQCkuJZrl", "PxXh1I86blw", "Pz198xRjRHD", "q2UUKkPtvll", "q4hyZcb2pgA",
"q6ke2WlwbWr", "Q75pcfnDLwr", "Q86baYhZPOB", "q8fmqtJVDhh", "qBrBhSbFC0d",
"qc9eMgI8Y95", "QCY2lUMpt7f", "QDkCAOGVng6", "QdYKp8ivavV", "qeBFicifeNz",
"QeKGz2D6wNe", "qEt7nmwua6v", "QGJz6Rv3qHU", "Qgzh7S5pLc3", "qHaaYvuNGIB",
"qiBueINJbti", "qimfq5GL5mV", "qJsVouyMqE8", "qlnxDl1BOrw", "Qlt1DOyb7iP",
"qm0fcx7VGOQ", "QMT77ObrHQa", "QOyCdSRSUXL", "Qpj3LVa0kMf", "qQ84fCTxdGh",
"QRaKmOedEZx", "qs9EipoiiBD", "qsPQEZph59z", "QTFJClMfP8c", "QtJyTjN5faU",
"qU7z54bY9jA", "QvByLV2hsHo", "QVFUUfes7vc", "QvQ5bpVOJDj", "Qwzbgh4Flmx",
"qx2DdF2CKFL", "qXdueHJNqcv", "QxSfgx5QfT7", "qxuRrLWQmXL", "Qztk8cjmz1e",
"r0ehsy1jjxa", "r2w7bZu3FsL", "R3ac44RpwRG", "r4mXVpHUWC7", "r6p12UeHOyg",
"r9efDheFtk3", "rakWSnvNhWr", "rbBZoYFr4DM", "rBtlT7YCRKx", "RdbYAXOnm2S",
"RdM4hjZsFRg", "Re2M8SlCc98", "RfmkqgjDUPL", "rgAmPaAHmNU", "rGbQXTyOdmW",
"RHpQbDCZK5O", "rhxxSbYXZRR", "RiIZqF2hfqY", "rIR8cwAz0sf", "rJ3tipUjVQ4",
"rlAmYWNUTnR", "rLiYzJJRiBA", "rLOyzoOdZqC", "RMKAo2HcVkM", "rnGH1Q5IyIU",
"robJRJuEFfM", "RovRnV9RWFd", "rpmWXDmHjsq", "rPPdTvv1QoY", "RqLdtXwHdGO",
"rR1aDWav3z1", "RrjHJQJDQSr", "rrZEwHEjjy8", "rsM3sdDc3Lk", "RsmDQZSmpD7",
"RtK3aS9WP2H", "ru8BHTnYxI3", "RU8DlKBg48x", "rUysfjKrKqk", "Rv3o89GkqWH",
"rVC8KePJHu3", "RvCLp5qbvtz", "RvQqAbOcEfA", "RW617O0UjQJ", "RWvmueaioAl",
"RxADuUq1Ba1", "RxHTSbz8VN5", "RxND5KsxzvW", "RyRJf2UHJL1", "S1Rh4YnCAAZ",
"s28njgt1wYe", "s4eb8Spa5TC", "S6gaiIWGmh9", "S6X4d5WHA1H", "sAnH4cWV41G",
"SATZgjyfpdZ", "sAyk7hwXEbV", "sBu9GwU5IKe", "SdlDgZMNxqX", "SegMIAP4dhw",
"SfB5NwJXaot", "SfPGp94cYZa", "SG0QMcMgRRq", "sG2EfH7UYLQ", "SgK14sd0Fq1",
"sgNOxONNZIv", "sGXcrRdwzAk", "shkTq2LdpXw", "si6qmHhCV9F", "skR6XpFhu3u",
"skuXY545bae", "skVM9VC2v6H", "sLkylFDaonQ", "sLQ3GDMCRSz", "sMVuTESYbpd",
"soMCF3RbHqt", "sQhxc449PV4", "sRbFOoSk7qZ", "srTptJGYtcK", "SSS1hmwqHOR",
"StSjQheznIv", "SvLVieXqQT7", "SVR6pSBhbCb", "sWlH85siDIT", "SWTCBn32M8D",
"sYBdL54a73r", "t0V5NCdjdPi", "T15MpYA7f51", "t3snPDHuVBW", "T5LdflE3Peq",
"T6RUeMH9KP0", "T6VbSgxjG4o", "t9Fl7c8SJbm", "TafeAKXESCA", "TBMPJiR0PKA",
"tcjz9dmJW4y", "tDDh1EjIZkh", "TE62MxBLgne", "TE7dhvcKVwp", "tEiDKptkacd",
"tEr481bYdow", "tfEtbnUgkGv", "TgpNd1eUCH5", "tGV21Z1HgXN", "thQZhxRh887",
"TJp862VOKlS", "TK7P7QXIDOA", "TKb3FP8mXY0", "TL5cvVAN3cA", "TM31sX4CThP",
"tMpwPcDzIfU", "tNf8m963xKK", "tnR9XvFJ5d7", "tNu7AdZ5358", "tOEYJ1EgIkn",
"TqSXqCuyodR", "tRgUTgCKu4J", "troIuBzxemz", "TSQWaAvOer5", "TsSlV9eE7Mz",
"ttKnsfno2BN", "tvoTu4cpYbh", "TWJPFfCeHES", "twyDPmlDNjH", "TyjDUvHkCAx",
"TYYPCGssY7i", "tz00ETYw78Y", "TZ307ap3HvE", "TzPwGs1AcCL", "TZxEGcWjbdk",
"u0ezFwC4OLL", "U3DjjRVyEun", "u45lZujojLF", "U6Mo4GsQKwT", "U7jt55boMwC",
"U8feQBluEhj", "UBe2SLdSmxV", "uBjjsyieqtr", "UccWk7OAtZ2", "uDXFpf8Ko6P",
"uE4KejhmDyk", "uGfkThgxZsI", "Uih0KGtvZeo", "UIyI4hkq7Bx", "UjoXPWJKPXb",
"uKFFT93nPmp", "UKSoohp2vBC", "UL70316n0C2", "UlD5QNXAW40", "uLDFnAy4ro0",
"UNxoCz1KXnW", "uOmh6keHjf6", "uormVxMEerw", "Upe0kYdbeUy", "UPSbASHNQmU",
"UQ1K5VqXqcZ", "uQvg5rWo87I", "usFB6MgBB6t", "uTeZmtXQzSN", "utgv86YyClH",
"UTmdWR44H5x", "uUmAJIXkmsO", "UUsAfkqIPhV", "Uv6Baj6YaG1", "UV9ZR51T6Ts",
"UvVxiC7b1jZ", "UW4ZNlm05Jq", "UxEq7311Xzd", "UXhcOzwv9o5", "UXSSmcXoWR8",
"v15yxuZyGjR", "V1MbBFGqwbB", "V5LD5oYeZys", "v6BprVsEEt2", "V7Hl62C5Wgz",
"Vah8YYh5HI5", "vbDOTEMQjfW", "vBjsjEqsmWL", "vBym1l507tA", "vf1kkxsjkB1",
"vFSbE4W5Kg6", "VfZPt9kXxL9", "vGLQ19KWuBv", "VHK1T5sygmw", "VLuN2iZ9oZp",
"VmwVU8HFDBn", "vnaUuR9C4FH", "vniKeY4S1Ru", "vOu023c0Snx", "vOuGO9bkEUa",
"vrQvRBzXiLv", "vRRoviRJVgX", "VS1mxlo1mVx", "VsFXXXagVmp", "VSHfWQyhzUu",
"vugElbQMtcL", "vvaX4oKLyKo", "vw87QIZ7dhk", "VWLVmvtDCSI", "vxXQe9jxSPE",
"vy0hyVTrTom", "Vy1JFQbsNBB", "vzGc2nPWraO", "vzVRv2jtJxL", "w0aCC4wNNzW",
"W1wtZLbWuY0", "w2yXiR4CyWt", "w539HzekPQh", "w55gRgLikEN", "WBhss2tvLa8",
"WcPEy9epMgd", "WCSGolF5yhy", "wdcS5ORWZte", "WDyq0ryAjpn", "webeuXrveDi",
"WeSJR8GDPmC", "WFApCUf18Lp", "wfFCmvMEGOQ", "WFiPvuGJf9O", "WggRnJplCQI",
"wgqFTVU7Iky", "wIMmZwl1gpX", "WjCGPzMzLVr", "WJfiDULf7ZC", "wkl1yyAzga3",
"wlspYUyDoQM", "wm060hpEM7g", "wMPB6u0GZDL", "Wn07Tbv74qp", "wNha3idA7l6",
"WnZVpXq5XCO", "wOe4JHkqbUm", "Wog7gclb7TJ", "wq4bmXnJK45", "Wq4O1nlYk1C",
"wqUwUpMD2mJ", "wrGYa8E94Yc", "WSAfRmiEJOF", "wSP90pEfCng", "wSW662GVwZP",
"wtoXU3G9YIy", "WtPSqPwjH2f", "wtV2TtEPCCZ", "Wtw2jbyaHz2", "WUChzooYWJ1",
"WUFgPdTN02g", "wUQiuRjZxiO", "Ww9Rq2KLlqV", "WWabB2sc4B7", "wxKEHpSLvib",
"wXnoTA2MDy9", "WYk4A1fVYD7", "WYMXHupBG7P", "wzD83xmvR3b", "WzemydwRD0R",
"X4ZVDdDd2xa", "X6efCWparbb", "X6uv3PName4", "X7deWPhTiIy", "X8TsrtMQFiu",
"X8UmaBiq1yy", "xbJCVaOZWp5", "XbjRzgMPN24", "XbubJh2yjOw", "XcqBCAaLcq5",
"xd8LIlN7N8h", "XdKVljaiZ9j", "xeEUMp35d5m", "XeUDpg1CTKf", "xf9Q4yYDlq5",
"XFEHZnnEGkT", "xFO9GKAXi1n", "xfxtwRZ7Ejp", "xhOpIbHQy8I", "XjBkSXvZLOZ",
"xjfIPJ04cET", "XLt8l1uPicg", "xlYle4v5GZ8", "xmJNiAbmSfe", "XnkRi1jTMKr",
"XPhxWI0fDyq", "XqDQsrhQ7W5", "Xsd3yzbnFOf", "XTF6vymtG8J", "xuovzIjWZUG",
"Xv1I8z1cK76", "XvVmyn071HT", "XxBMueAFsnk", "xxVZKlzMYJJ", "xyr4dO4G3tW",
"y4rr2PbfufS", "yaa2uBLsdRa", "YBG39jGSV17", "yDcnCB4aZEX", "YDuoFIKpONe",
"YdWxRCaQR2D", "yfgSogitBGX", "YFi06xiFHWs", "YFi2V7qfmJf", "yfpM2zJ3Zuc",
"ygTl7hih5qi", "YGtrgJxKWiU", "yIcfnuZhejK", "YIxt0WtezdT", "yJ014QFEqru",
"yJO8QTnBF3o", "yKfdWuLsdDx", "ylMgcLnwgce", "YNy9ymD2A8p", "yONz8gph9A7",
"YowwYq8CIXJ", "YPsxC0bl7T2", "YQP6diqjJAl", "YqR6LoSk2Ed", "yqwh11CvYXU",
"YRemZ3p9bFA", "ySxRSgTOeqD", "yTvx2IJ0w0z", "ytwga9hKjVj", "YtyO06HBaVr",
"YvEkkZlNeCK", "yVFdJkYsLK5", "yvoQHXHGvbT", "YVT9zsaVBzp", "YWbmL6VK8R6",
"Ywm8eA9tZHe", "yXady1QV27H", "yY7MHufA6C9", "yYG52aLO1GK", "yYgG4h097xR",
"YyhPAO5yx22", "Yz5yhyHf7Ul", "z2cGjpx37Mw", "Z42m6cWsI9m", "z4DptoHrJnb",
"z4kLOdnL1Op", "z5tZes2s49Z", "z5WklS85YjT", "z6bId6qlNk4", "Z6ZZLw50mAM",
"z8MwD6T43n2", "z8UkGdr2xNs", "Z90jET09ZrD", "zaeb1Zos2Mu", "ZBkpY2KdibX",
"Zc0BcScQDBU", "zCjn57zZQVN", "ZcrdEBruDka", "ZCT4YbaBFUb", "ZdVIx83rdI7",
"zEQXA689E4a", "ZfjQmCjVKRF", "zfutn6ulVcO", "zFzYdXMnPoP", "zG4JqtM8wHO",
"ZGyAErBl5PS", "ZifoCg4OvIj", "ZJ6MAab9PJE", "ZKVzRmYkKzQ", "zlG1VmpE6QQ",
"zN6xXPgmzqK", "zOfDRrZmbQO", "zOGa9wLHDFE", "zQmuipEUYbz", "zR7UekDUG3X",
"zrs6iFpEtF1", "ZrUjQFzR1gM", "zTnxsAMqHRP", "Zu7gpmcwfqY", "zvOkAI9ewwE",
"zvv07VAowTS", "ZWAdop7zYgJ", "ZWAEE8DrywN", "zxIlF5RwQFi", "ZXONCt7P01p"
), class = "factor"), Time = c(1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L,
4L, 6L, 1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L,
6L, 1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L, 6L,
1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L, 6L, 1L,
2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L, 6L, 1L, 2L,
3L, 4L, 6L, 1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L,
4L, 6L, 1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L,
6L, 1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L, 6L,
1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L, 6L, 1L,
2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L, 6L, 1L, 2L, 3L, 4L, 6L, 1L),
Count1 = c(8L, 16L, 16L, 16L, 8L, 12L, 24L, 24L, 24L, 12L,
8L, 16L, 16L, 16L, 8L, 8L, 16L, 16L, 16L, 8L, 8L, 16L, 16L,
16L, 8L, 8L, 16L, 16L, 16L, 8L, 8L, 16L, 16L, 16L, 8L, 12L,
24L, 24L, 24L, 12L, 8L, 16L, 16L, 16L, 8L, 8L, 16L, 16L,
16L, 8L, 12L, 24L, 24L, 24L, 12L, 8L, 16L, 16L, 16L, 8L,
12L, 24L, 24L, 24L, 12L, 8L, 16L, 16L, 16L, 8L, 8L, 16L,
16L, 16L, 8L, 8L, 16L, 16L, 16L, 8L, 8L, 16L, 16L, 16L, 8L,
8L, 16L, 16L, 16L, 8L, 8L, 16L, 16L, 16L, 8L, 8L, 16L, 16L,
16L, 8L, 8L, 16L, 16L, 16L, 8L, 8L, 16L, 16L, 16L, 8L, 8L,
16L, 16L, 16L, 8L, 8L, 16L, 16L, 16L, 8L, 8L, 16L, 16L, 16L,
8L, 8L, 16L, 16L, 16L, 8L, 8L, 16L, 16L, 16L, 8L, 8L, 16L,
16L, 16L, 8L, 8L, 16L, 16L, 16L, 8L, 8L, 16L, 16L, 16L, 8L,
8L), Total1 = c(64L, 64L, 64L, 64L, 64L, 96L, 96L, 96L, 96L,
96L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 96L, 96L, 96L, 96L, 96L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 96L, 96L, 96L, 96L, 96L, 64L, 64L,
64L, 64L, 64L, 96L, 96L, 96L, 96L, 96L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L, 64L), Count2 = c(4L,
8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 3L, 7L, 8L, 8L, 4L, 4L,
8L, 8L, 8L, 4L, 3L, 8L, 8L, 8L, 4L, 3L, 7L, 8L, 8L, 4L, 2L,
4L, 4L, 4L, 2L, 3L, 5L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 4L,
8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 3L, 6L, 8L, 8L, 4L, 4L,
8L, 8L, 8L, 4L, 3L, 4L, 6L, 6L, 2L, 2L, 4L, 4L, 4L, 2L, 4L,
8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 4L,
8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 4L,
8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 4L,
8L, 8L, 8L, 4L, 3L, 8L, 8L, 8L, 4L, 4L, 8L, 8L, 8L, 4L, 3L,
8L, 8L, 8L, 4L, 3L, 5L, 7L, 8L, 3L, 4L, 8L, 8L, 8L, 4L, 4L
), Total2 = c(34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L,
34L, 32L, 32L, 32L, 32L, 32L, 34L, 34L, 34L, 34L, 34L, 33L,
33L, 33L, 33L, 33L, 32L, 32L, 32L, 32L, 32L, 16L, 16L, 16L,
16L, 16L, 30L, 30L, 30L, 30L, 30L, 34L, 34L, 34L, 34L, 34L,
34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 31L, 31L,
31L, 31L, 31L, 34L, 34L, 34L, 34L, 34L, 22L, 22L, 22L, 22L,
22L, 16L, 16L, 16L, 16L, 16L, 34L, 34L, 34L, 34L, 34L, 34L,
34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L,
34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L,
34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L,
34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 33L, 33L, 33L, 33L,
33L, 34L, 34L, 34L, 34L, 34L, 33L, 33L, 33L, 33L, 33L, 28L,
28L, 28L, 28L, 28L, 34L, 34L, 34L, 34L, 34L, 34L)), row.names = c(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L,
29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L,
42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L,
55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L,
68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 1041L, 1042L, 1043L,
1044L, 1045L, 1046L, 1047L, 1048L, 1049L, 1050L, 1051L, 1052L,
1053L, 1054L, 1055L, 1056L, 1057L, 1058L, 1059L, 1060L, 1061L,
1062L, 1063L, 1064L, 1065L, 1066L, 1067L, 1068L, 1069L, 1070L,
1071L, 1072L, 1073L, 1074L, 1075L, 1076L, 1077L, 1078L, 1079L,
1080L, 1081L, 1082L, 1083L, 1084L, 1085L, 1086L, 1087L, 1088L,
1089L, 1090L, 1091L, 1092L, 1093L, 1094L, 1095L, 1096L, 1097L,
1098L, 1099L, 1100L, 1101L, 1102L, 1103L, 1104L, 1105L, 1106L,
1107L, 1108L, 1109L, 1110L, 1111L, 1112L, 1113L, 1114L, 1115L,
1116L), class = "data.frame")
An option is to group by 'Class', 'Site', paste (str_c) the columns except 'Time' to a single string, then grouped by 'Class', 'Count1', ..., 'Total2', columns, get the group indices to create the 'ind' column and do a left_join with original dataset
library(dplyr)
library(stringr)
df %>%
group_by(Class, Site) %>%
summarise_at(vars(-Time), str_c, collapse="") %>%
group_by(Class, Count1, Total1, Count2, Total2) %>%
mutate(ind = group_indices()) %>%
ungroup %>%
select(Class, Site, ind) %>%
left_join(df)
Or a similar logic with data.table
library(data.table)
setDT(df)[df[, lapply(.SD, paste, collapse=""),
.(Class, Site), .SDcols = patterns('Count|Total')][,
ind := .GRP, by = c('Class', 'Count1', 'Total1', 'Count2', 'Total2')
][, .(Class, Site, ind)], on = .(Class, Site)]

order geom_point by specific facet

I have a ggplot related question, which should be easy but I could not find the answer yet. I am trying to plot a faceted plot with the code below and this dataset (11 kB).
ggplot(plot.dat, aes(x = estimate, y = reorder(countryyear, estimate))) +
geom_point() +
geom_segment(aes(x=conf.low, xend=conf.high, yend=countryyear)) +
facet_grid(. ~ facet) +
xlab("Random Effect Estimate") +
ylab("") + scale_x_continuous(breaks=c(seq(0, 5, 1)), limits=c(0, 5)) +
ggtitle("Random Slopes in Country*Year Groups from Northwestern Europe") +
theme_minimal() + theme(plot.title = element_text(hjust = 0.5))
I would like countryyear to be organized by the values of estimate in the Extreme Right facet. Not quite sure how to order by values of a specific facet. Any ideas are welcome! Thanks.
Update: Here is the dput structure of a random subset of the dataset. It has some missing values, but it should work for the sake of the example. I also updated the download link above, that has the full version.
structure(list(estimate = c(1.41056902925372, 0.854859208455895,
1.16012834593894, 0.871339033194504, 0.803272289946221, 1.17540386134493,
0.996313357490551, 1.49940694539732, 1.33773365908762, 2.7318703090905,
1.19131935418045, 1.12765907711738, 0.746741192261761, 0.985847015192172,
0.912357310925342, 1.11582763712164, 1.21854572824977, 0.675712547978394,
0.566955524699616, 1.32611743759365, 0.519648352294682, 0.591013596394243,
1.30944973684044, 0.613722269599125, 1.13293279727271, 0.950788678552604,
1.1599446923567, 1.11493952112913, 0.95336321045095, 1.39002327097034,
0.794207546872633, 0.788545101449259, 1.01096883872495, 0.897407203907834,
1.38391605229103, 1.35754760293107, 1.0718508539761, 0.542191158958878,
0.757132752456427, 1.44172863221312, 1.04842251986171, 0.77260404885379,
0.879288027642055, 1.09372353598088, 0.745484830381145, 1.21211217249353,
0.628009608902132, 1.34864488674734), countryyear = structure(c(1L,
2L, 4L, 5L, 7L, 9L, 10L, 12L, 13L, 26L, 28L, 29L, 31L, 32L, 34L,
36L, 37L, 39L, 40L, 57L, 59L, 60L, 62L, 63L, 65L, 67L, 68L, 70L,
71L, 73L, 75L, 76L, 89L, 90L, 92L, 94L, 95L, 103L, 104L, 106L,
108L, 109L, 111L, 128L, 130L, 132L, 133L, 135L), .Label = c("AT02",
"AT04", "AT06", "AT14", "AT16", "BE02", "BE04", "BE06", "BE08",
"BE10", "BE12", "BE14", "BE16", "BG06", "BG08", "BG10", "BG12",
"CH14", "CZ02", "CZ04", "CZ08", "CZ10", "CZ12", "CZ14", "CZ16",
"DE02", "DE04", "DE06", "DE08", "DE10", "DE12", "DE14", "DE16",
"DK02", "DK04", "DK06", "DK08", "DK10", "DK12", "DK14", "EE04",
"EE06", "EE08", "EE10", "EE12", "EE14", "EE16", "ES02", "ES04",
"ES06", "ES08", "ES10", "ES12", "ES14", "ES16", "FI02", "FI04",
"FI06", "FI08", "FI10", "FI12", "FI14", "FI16", "FR06", "FR08",
"FR10", "FR12", "FR14", "FR16", "GB02", "GB04", "GB06", "GB08",
"GB10", "GB12", "GB14", "GB16", "GR02", "GR04", "GR08", "GR10",
"HU02", "HU06", "HU08", "HU10", "HU12", "HU14", "HU16", "IE02",
"IE04", "IE06", "IE08", "IE10", "IE12", "IE14", "IE16", "IT04",
"IT12", "IT16", "LT10", "LT12", "LT14", "NL02", "NL04", "NL06",
"NL08", "NL10", "NL12", "NL14", "NL16", "NO14", "PL02", "PL04",
"PL06", "PL08", "PL10", "PL12", "PL14", "PL16", "PT02", "PT04",
"PT06", "PT08", "PT10", "PT12", "PT14", "PT16", "SE02", "SE04",
"SE06", "SE08", "SE10", "SE12", "SE14", "SE16", "SI02", "SI04",
"SI06", "SI08", "SI10", "SI12", "SI14", "SI16", "SK04", "SK06",
"SK08", "SK10", "SK12"), class = "factor"), facet = structure(c(1L,
3L, 1L, 4L, 5L, 3L, 4L, 1L, 1L, 1L, 5L, 5L, 4L, 5L, 3L, 1L, 2L,
4L, 5L, 2L, 1L, 4L, 2L, 5L, 2L, 3L, 4L, 3L, 2L, 5L, 5L, 4L, 2L,
5L, 4L, 5L, 3L, 1L, 4L, 5L, 3L, 5L, 4L, 1L, 5L, 2L, 4L, 1L), .Label = c("Intercept",
"Extreme Left", "Center", "Right", "Extreme Right"), class = "factor"),
conf.low = c(1.16824810706745, 0.686215051613965, 0.910277310292764,
0.591705078386698, 0.37357342399703, 0.947951001435781, 0.663296044193037,
1.18794112232166, 1.06645119085865, 2.33578182814618, 0.580210898576738,
0.564235690522211, 0.530859530342114, 0.516191258265551,
0.730992343373883, 0.862424540370486, 0.827891784352444,
0.427638276259852, 0.275692447335368, 0.829763907986328,
0.370078643492081, 0.321852705445509, 0.83550621863293, 0.289836810427436,
0.847226120408727, 0.780056160572728, 0.873143885861924,
0.869757467125519, 0.615741777890997, 0.649483531741787,
0.349657606457465, 0.523294407847395, 0.670109418373736,
0.36656743494149, 0.952201390937053, 0.777207016700884, 0.888128473009524,
0.397085597526946, 0.479828726362257, 0.614533313431094,
0.813336887981082, 0.3129232351085, 0.61435321820328, 0.854801028643867,
0.346698059397102, 0.805414039007076, 0.434676644041643,
1.07780736338027), conf.high = c(1.70315275860739, 1.06494933995261,
1.47855797769819, 1.28312522319126, 1.7272277157504, 1.45743211956315,
1.49652679976667, 1.8925358720741, 1.67802460909168, 3.19512520208851,
2.44607918797515, 2.25369471581694, 1.05041423643869, 1.8828182806291,
1.13872035780431, 1.44368725318228, 1.79353596677755, 1.06769546329854,
1.16593171156554, 2.11938292490653, 0.729667639003753, 1.08526995489865,
2.05223919950836, 1.29954170985538, 1.51498719434776, 1.15888977865399,
1.54095070825389, 1.4292376699955, 1.47610807594453, 2.97492484321718,
1.80395225460704, 1.18824770090216, 1.52521060717706, 2.19697554354282,
2.01136404338166, 2.37122858469145, 1.29357889999432, 0.740322123703373,
1.19469713534712, 3.38237391450413, 1.35145693795059, 1.90755095606211,
1.25847381058047, 1.39942645489832, 1.60297301142912, 1.82417470710871,
0.907332092210651, 1.68753999308876)), row.names = c(1L,
9L, 17L, 25L, 33L, 41L, 49L, 57L, 65L, 128L, 136L, 144L, 152L,
160L, 168L, 176L, 184L, 192L, 200L, 283L, 291L, 299L, 307L, 315L,
323L, 331L, 339L, 347L, 355L, 363L, 371L, 379L, 442L, 450L, 458L,
466L, 474L, 512L, 520L, 528L, 536L, 544L, 552L, 640L, 648L, 656L,
664L, 672L), class = "data.frame")

ggplot2: Inconsistent color from alpha

I am making several plots that have different x-axis limits, and I want to highlight a region of interest by adding a grey box. Even though I use the same geom_rect() command with the same alpha value in ggplot2, I get results with very different grey colors. I have looked here and here but so far have not figured out how to make these boxes the same level of transparency. Below is a reproducible example (with fake data) and the figures that it produces. Notice the different color of the grey rectangles. I want the grey to be the same across plots.
Data<-structure(list(X = c(34L, 27L, 28L, 47L, 26L, 3L, 13L, 31L, 39L,
16L, 45L, 5L, 49L, 17L, 29L, 43L, 1L, 35L, 41L, 10L, 48L, 24L,
12L, 11L, 30L, 40L, 8L, 4L, 20L, 25L, 50L, 22L, 9L, 21L, 18L,
7L, 15L, 44L, 6L, 36L, 46L, 33L, 2L, 37L, 23L, 14L, 42L, 38L,
19L, 32L, 34L, 27L, 28L, 47L, 26L, 3L, 13L, 31L, 39L, 16L, 45L,
5L, 49L, 17L, 29L, 43L, 1L, 35L, 41L, 10L, 48L, 24L, 12L, 11L,
30L, 40L, 8L, 4L, 20L, 25L, 50L, 22L, 9L, 21L, 18L, 7L, 15L,
44L, 6L, 36L, 46L, 33L, 2L, 37L, 23L, 14L, 42L, 38L, 19L, 32L
), Y = c(130L, 146L, 58L, 110L, 117L, 135L, 133L, 108L, 97L,
61L, 71L, 64L, 103L, 142L, 125L, 104L, 100L, 147L, 111L, 78L,
56L, 145L, 62L, 69L, 70L, 116L, 137L, 79L, 150L, 94L, 91L, 81L,
65L, 118L, 129L, 83L, 98L, 84L, 85L, 148L, 93L, 73L, 59L, 87L,
134L, 88L, 136L, 90L, 140L, 55L, 89L, 115L, 123L, 51L, 132L,
126L, 66L, 80L, 60L, 120L, 109L, 76L, 74L, 57L, 149L, 121L, 138L,
128L, 114L, 127L, 68L, 107L, 67L, 112L, 144L, 119L, 53L, 52L,
54L, 96L, 131L, 106L, 113L, 72L, 95L, 63L, 92L, 86L, 75L, 105L,
82L, 101L, 139L, 143L, 122L, 77L, 99L, 141L, 124L, 102L), B = structure(c(2L,
2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L,
1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L,
1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L,
1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L,
2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L,
2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L,
1L, 1L, 1L), class = "factor", .Label = c("no", "yes"))), .Names = c("X",
"Y", "B"), row.names = c(NA, -100L), class = "data.frame")
Data2<-structure(list(variable = c(2.49676547444708, 0.67359598601097,
0.674751772966082, 0.0317590441796792, 0.485143583939748, 1.08231639527806,
0.0732344181040914, 1.62357048819912, 0.146833215667032, 0.823157103468943,
0.240761579418538, 1.37540376416553), DOY_mid_month = c(15, 46,
75, 106, 136, 167, 197, 228, 259, 289, 320, 350)), .Names = c("variable",
"DOY_mid_month"), row.names = c(NA, -12L), class = "data.frame")
test<-ggplot(data=Data) +
geom_rect(aes(xmin=5, xmax=30, ymin=1, ymax=40), alpha = 0.02) +
geom_point(aes(x = X, y = X, colour= B), data =Data, size=2) +
theme_bw()
test2 <-ggplot(data=Data2) +
geom_rect(aes(xmin=5, xmax=30, ymin=-Inf, ymax=Inf), alpha = 0.02) +
geom_point(aes(x = DOY_mid_month, y = variable), color="black", size=4) +
scale_x_continuous("Day of Year", limits = c(0, 366)) + # Use this to add back X-axis label for the bottom plot in panel
scale_y_continuous(expression(paste("Variable", sep=""))) +
theme_bw()
Plot result from first example:
Plot result from second example:
You are currently drawing one rectangle for each row of the dataset. The more rectangles you overlap, the darker they get, which is why the longer dataset has a darker rectangle. Use annotate instead of geom_rect to draw a single rectangle.
annotate(geom = "rect", xmin=5, xmax=30, ymin=-Inf, ymax=Inf, alpha = 0.2)
If you want to stick with geom_rect you can give a one row data.frame to that layer so that each rectangle is only drawn one time. Here I use a fake dataset, although you could put your rectangle limits in the data.frame, as well.
geom_rect(data = data.frame(fake = 1),
aes(xmin = 5, xmax= 30, ymin = -Inf, ymax = Inf), alpha = 0.2)

Internal ordering of facets ggplot2

I'm trying to plot a facets in ggplot2 but I struggle to get the internal ordering of the different facets right. The data looks like this:
head(THAT_EXT)
ID FILE GENRE NODE
1 CKC_1823_01 CKC Novels better
2 CKC_1824_01 CKC Novels better
3 EW9_192_03 EW9 Popular Science better
4 H0B_265_01 H0B Popular Science sad
5 CS2_231_03 CS2 Academic Prose desirable
6 FED_8_05 FED Academic Prose certain
str(THAT_EXT)
'data.frame': 851 obs. of 4 variables:
$ ID : Factor w/ 851 levels "A05_122_01","A05_277_07",..: 345 346 439 608 402 484 319 395 228 5 ...
$ FILE : Factor w/ 241 levels "A05","A06","A0K",..: 110 110 127 169 120 135 105 119 79 2 ...
$ GENRE: Factor w/ 5 levels "Academic Prose",..: 4 4 5 5 1 1 1 5 1 5 ...
$ NODE : Factor w/ 115 levels "absurd","accepted",..: 14 14 14 89 23 16 59 59 18 66 ...
Part of the problem is that can't get the sorting right. Here is the code for the sorting of NODE that I use:
THAT_EXT <- within(THAT_EXT,
NODE <- factor(NODE,
levels=names(sort(table(NODE),
decreasing=TRUE))))
When I plot this with the code below I get a graphs in which the NODE is not correctly sorted in the individual GENREs since different NODEs are more frequent in different GENREs:
p1 <-
ggplot(THAT_EXT, aes(x=NODE)) +
geom_bar() +
scale_x_discrete("THAT_EXT", breaks=NULL) + # supress tick marks on x axis
facet_wrap(~GENRE)
What I want is for every facet to have NODE sorted in decreasing order for that particular GENRE. Can anyone help with this?
structure(list(ID = structure(c(1L, 2L, 3L, 4L, 10L, 133L, 137L,
138L, 139L, 140L, 141L, 142L, 143L, 144L, 145L, 146L, 147L, 148L,
149L, 150L, 151L, 152L, 153L, 154L, 155L, 156L, 157L, 158L, 159L,
160L, 161L, 162L, 163L, 164L, 165L, 166L, 167L, 168L, 169L, 170L,
171L, 172L, 173L, 174L, 175L, 176L, 177L, 178L, 179L, 180L, 181L,
182L, 183L, 184L, 185L, 186L, 187L, 188L, 189L, 190L, 191L, 192L,
193L, 194L, 195L, 196L, 197L, 198L, 199L, 200L, 201L, 202L, 203L,
204L, 205L, 206L, 207L, 208L, 212L, 213L, 214L, 215L, 216L, 217L,
218L, 219L, 220L, 221L, 222L, 223L, 224L, 225L, 226L, 227L, 228L,
229L, 230L, 231L, 232L, 233L, 234L, 235L, 236L, 237L, 238L, 239L,
240L, 241L, 267L, 268L, 269L, 270L, 271L, 272L, 273L, 274L, 275L,
276L, 277L, 278L, 279L, 280L, 281L, 282L, 283L, 284L, 290L, 291L,
298L, 299L, 300L, 303L, 304L, 305L, 306L, 307L, 308L, 309L, 310L,
313L, 314L, 315L, 316L, 317L, 318L, 319L, 327L, 328L, 329L, 330L,
331L, 332L, 333L, 334L, 335L, 336L, 337L, 338L, 339L, 340L, 341L,
342L, 343L, 344L, 345L, 346L, 347L, 348L, 352L, 353L, 354L, 355L,
356L, 357L, 358L, 359L, 360L, 349L, 350L, 351L, 361L, 362L, 363L,
364L, 365L, 366L, 367L, 368L, 369L, 370L, 371L, 372L, 373L, 374L,
375L, 376L, 377L, 378L, 379L, 380L, 381L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L,
29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 41L, 42L, 43L, 44L, 45L,
46L, 50L, 54L, 72L, 73L, 74L, 75L, 76L, 90L, 91L, 92L, 97L, 98L,
102L, 115L, 125L, 126L, 127L, 128L, 129L, 130L, 131L, 132L, 209L,
210L, 211L, 242L, 243L, 244L, 245L, 246L, 289L, 292L, 293L, 294L,
295L, 296L, 297L, 301L, 302L, 311L, 312L, 320L, 321L, 322L, 323L,
324L, 325L, 326L, 382L, 383L, 384L, 385L, 386L, 387L, 388L, 5L,
6L, 7L, 8L, 9L, 11L, 37L, 38L, 39L, 40L, 47L, 48L, 49L, 51L,
52L, 53L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L,
66L, 67L, 68L, 69L, 70L, 71L, 77L, 78L, 79L, 80L, 81L, 82L, 83L,
84L, 85L, 86L, 87L, 88L, 89L, 93L, 94L, 95L, 96L, 99L, 100L,
101L, 103L, 104L, 105L, 106L, 107L, 108L, 109L, 110L, 111L, 112L,
113L, 114L, 116L, 117L, 118L, 119L, 120L, 121L, 122L, 123L, 124L,
134L, 135L, 136L, 247L, 248L, 249L, 250L, 251L, 252L, 253L, 254L,
255L, 256L, 257L, 258L, 259L, 260L, 261L, 262L, 263L, 264L, 265L,
266L, 285L, 286L, 287L, 288L), .Label = c("A05_122_01", "A05_277_07",
"A05_400_01", "A05_99_01", "A06_1283_02", "A06_1389_01", "A06_1390_01",
"A06_1441_02", "A06_884_03", "A0K_1190_03", "A77_1684_01", "A8K_525_03",
"A8K_582_01", "A8K_645_01", "A8K_799_01", "A90_341_02", "A90_496_01",
"A94_217_01", "A94_472_01", "A94_477_03", "A9M_164_01", "A9M_259_03",
"A9N_199_01", "A9N_489_01", "A9N_591_01", "A9R_173_01", "A9R_425_02",
"A9W_536_02", "AA5_121_01", "AAE_203_01", "AAE_243_01", "AAE_412_01",
"AAW_14_03", "AAW_244_02", "AAW_297_04", "AAW_365_04", "ADG_1398_01",
"ADG_1500_01", "ADG_1507_01", "ADG_1516_01", "AHB_336_01", "AHB_421_01",
"AHJ_1090_02", "AHJ_619_01", "AR3_340_01", "AR3_91_03", "ARF_879_01",
"ARF_985_01", "ARF_991_02", "ARK_1891_01", "ASL_33_04", "ASL_43_01",
"ASL_9_01", "AT7_1031_01", "B09_1162_01", "B09_1475_01", "B09_1493_01",
"B09_1539_01", "B0G_197_01", "B0G_320_01", "B0N_1037_01", "B0N_624_01",
"B0N_645_02", "B0N_683_01", "B3G_313_04", "B3G_320_03", "B3G_398_02",
"B7M_1630_01", "B7M_1913_01", "BNN_746_02", "BNN_895_01", "BP7_2426_01",
"BP7_2777_01", "BP7_2898_01", "BP9_410_01", "BP9_599_01", "BPK_829_01",
"C93_1407_02", "C9A_181_01", "C9A_196_01", "C9A_365_01", "C9A_82_02",
"C9A_9_01", "CB9_306_02", "CB9_63_04", "CB9_86_01", "CBJ_439_01",
"CBJ_702_02", "CBJ_705_01", "CCM_320_01", "CCM_665_01", "CCM_669_02",
"CCN_1036_02", "CCN_1078_01", "CCN_1119_01", "CCN_784_01", "CCW_2284_02",
"CCW_2349_03", "CE7_242_02", "CE7_284_01", "CE7_39_01", "CEB_1675_01",
"CER_145_03", "CER_23_01", "CER_235_02", "CER_378_10", "CET_1056_02",
"CET_680_01", "CET_705_01", "CET_797_01", "CET_838_01", "CET_879_05",
"CET_946_03", "CET_986_01", "CEY_2977_01", "CJ3_107_02", "CJ3_114_03",
"CJ3_20_01", "CJ3_81_01", "CK2_112_01", "CK2_22_01", "CK2_392_01",
"CK2_42_01", "CK2_75_01", "CKC_1776_01", "CKC_1777_01", "CKC_1823_01",
"CKC_1824_01", "CKC_1860_01", "CKC_1883_01", "CKC_1883_02", "CKC_2127_01",
"CMN_1439_02", "CRM_5767_01", "CRM_5770_03", "CRM_5789_01", "CS2_110_01",
"CS2_131_01", "CS2_139_01", "CS2_187_01", "CS2_187_03", "CS2_231_03",
"CS2_249_02", "CS2_301_01", "CS2_35_01", "CS2_58_02", "EV6_16_01",
"EV6_206_02", "EV6_240_01", "EV6_244_02", "EV6_28_01", "EV6_30_01",
"EV6_32_01", "EV6_450_01", "EV6_69_01", "EV6_80_01", "EV6_91_01",
"FAC_1019_01", "FAC_1026_01", "FAC_1027_01", "FAC_1235_01", "FAC_1269_05",
"FAC_1270_05", "FAC_1393_01", "FAC_1406_03", "FAC_933_01", "FAC_950_01",
"FAC_960_01", "FED_105_01", "FED_120_02", "FED_21_02", "FED_281_02",
"FED_302_02", "FED_53_01", "FED_8_05", "FEF_498_03", "FEF_674_03",
"FR2_410_01", "FR2_557_02", "FR2_593_01", "FR2_691_01", "FR4_232_01",
"FR4_331_01", "FR4_346_01", "FS7_818_01", "FS7_919_01", "FU0_368_02",
"FYT_1138_01", "FYT_1183_01", "FYT_901_05", "G08_1336_01", "G1E_385_01",
"G1N_824_01", "G1N_860_01", "G1N_868_01", "G1N_975_01", "GU5_854_01",
"GUJ_423_01", "GUJ_501_01", "GUJ_611_01", "GUJ_629_03", "GUJ_700_01",
"GV0_10_01", "GV0_104_01", "GV0_111_01", "GV0_122_01", "GV0_160_01",
"GV0_232_02", "GV2_1465_01", "GV2_1899_01", "GV6_2683_01", "GW6_297_01",
"GW6_306_05", "GW6_307_01", "GW6_322_01", "GW6_330_02", "GW6_335_01",
"GW6_338_01", "GW6_367_02", "GW6_373_01", "GW6_407_01", "GW6_411_01",
"GW6_413_01", "GW6_421_01", "GW6_423_01", "GW6_424_01", "GW6_428_01",
"GW6_447_01", "GWM_480_01", "GWM_533_02", "GWM_554_02", "GWM_554_03",
"GWM_609_01", "GWM_609_04", "GWM_610_01", "GWM_730_01", "GWM_731_01",
"GWM_738_01", "GWM_804_06", "GWM_815_01", "GWM_832_03", "GVP_179_01",
"GVP_211_01", "GVP_393_02", "GVP_443_02", "GVP_710_01", "H0B_171_04",
"H0B_216_01", "H0B_265_01", "H0B_32_01", "H0B_361_03", "H0B_365_01",
"H0B_369_01", "H0B_74_01", "H0B_93_01", "H10_1002_01", "H10_1032_04",
"H10_653_01", "H10_803_01", "H10_824_01", "H10_825_03", "H10_881_01",
"H10_986_01", "H78_851_04", "H78_891_01", "H78_946_04", "H79_1959_19",
"H7S_110_05", "H7S_130_06", "H7S_131_03", "H7S_131_04", "H7S_146_01",
"H7S_148_01", "H7S_164_01", "H7S_179_01", "H7S_54_01", "H7S_56_05",
"H7S_62_03", "H7S_79_01", "H7S_8_01", "H7S_81_01", "H7S_83_01",
"H7S_87_01", "H7S_92_03", "H7X_1028_02", "H7X_1091_01", "H7X_691_01",
"H7X_695_01", "H8H_2917_01", "H8K_153_01", "H8K_55_01", "H8M_1897_01",
"H8M_2104_02", "H8T_3316_03", "H98_3204_01", "H98_3410_01", "H98_3490_02",
"H9R_130_02", "H9R_39_01", "H9S_1297_01", "HA2_3107_02", "HA2_3284_01",
"HPY_754_04", "HPY_785_09", "HPY_799_03", "HPY_807_04", "HPY_830_04",
"HPY_838_02", "HPY_843_01", "HPY_869_11", "HR7_190_01", "HR7_440_01",
"HTP_540_01", "HTP_585_01", "HTP_588_05", "HTP_593_01", "HTP_601_01",
"HTP_613_01", "HTP_648_02", "HTW_197_01", "HTW_494_01", "HTW_750_01",
"HWL_2770_01", "HWL_2919_01", "HWM_45_01", "HWM_45_02", "HXY_1047_03",
"HXY_701_01", "HXY_781_01", "HXY_783_01", "HXY_784_01", "HXY_836_01",
"HXY_931_01", "HXY_963_01", "HXY_972_01", "HXY_985_03", "HY6_1024_01",
"HY6_1025_01", "HY6_1164_01", "HY6_1223_01", "HY6_988_03", "HY6_989_01",
"HY8_160_01", "HY8_164_01", "HY8_292_03", "HY8_316_01", "HY9_778_03",
"HY9_845_02", "HYX_235_08", "HYX_245_01", "HYX_88_01", "J12_1474_02",
"J12_1492_01", "J12_1571_01", "J12_1845_01", "J14_341_01", "J18_597_04",
"J18_698_02", "J18_759_01", "J18_828_01", "J3R_197_01", "J3R_219_02",
"J3R_277_04", "J3T_267_01", "J3T_269_02", "J3T_57_02", "J41_41_02",
"J41_58_03", "J9B_133_03", "J9B_341_02", "J9B_341_03", "J9D_147_05",
"J9D_218_01", "J9D_411_01", "J9D_616_01", "J9D_616_02", "JNB_563_02",
"JT7_118_01", "JT7_129_02", "JT7_218_02", "JT7_344_02", "JXS_3663_01",
"JXU_407_01", "JXU_468_02", "JXU_559_01", "JXV_1439_04", "JXV_1592_01",
"JY1_100_01"), class = "factor"), GENRE = structure(c(1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L), .Label = c("Academic Prose", "Conversation", "News",
"Novels", "Popular Science"), class = "factor"), NODE = structure(c(9L,
10L, 10L, 10L, 4L, 10L, 71L, 35L, 49L, 6L, 5L, 15L, 28L, 44L,
64L, 64L, 28L, 28L, 18L, 18L, 32L, 18L, 58L, 10L, 72L, 28L, 18L,
10L, 64L, 10L, 35L, 64L, 64L, 69L, 8L, 10L, 50L, 69L, 49L, 49L,
15L, 69L, 10L, 49L, 8L, 64L, 49L, 10L, 69L, 18L, 61L, 67L, 67L,
61L, 57L, 69L, 11L, 10L, 64L, 10L, 59L, 61L, 49L, 10L, 59L, 1L,
61L, 35L, 54L, 54L, 39L, 44L, 61L, 64L, 69L, 1L, 23L, 49L, 49L,
8L, 69L, 49L, 69L, 49L, 49L, 69L, 35L, 49L, 49L, 49L, 35L, 10L,
49L, 48L, 10L, 49L, 11L, 44L, 50L, 11L, 50L, 69L, 49L, 10L, 59L,
68L, 47L, 69L, 49L, 35L, 29L, 8L, 49L, 50L, 35L, 10L, 35L, 8L,
35L, 8L, 10L, 35L, 10L, 10L, 10L, 35L, 44L, 61L, 35L, 44L, 28L,
47L, 39L, 39L, 49L, 61L, 43L, 60L, 19L, 10L, 10L, 10L, 44L, 44L,
62L, 44L, 10L, 59L, 10L, 61L, 1L, 53L, 33L, 10L, 8L, 8L, 64L,
64L, 10L, 57L, 61L, 64L, 66L, 19L, 61L, 64L, 10L, 10L, 8L, 19L,
35L, 28L, 10L, 61L, 35L, 42L, 35L, 28L, 32L, 64L, 10L, 18L, 28L,
25L, 35L, 35L, 10L, 18L, 10L, 22L, 55L, 28L, 10L, 1L, 55L, 51L,
1L, 38L, 28L, 28L, 33L, 10L, 44L, 29L, 16L, 8L, 28L, 69L, 32L,
10L, 61L, 20L, 35L, 10L, 28L, 10L, 32L, 10L, 46L, 59L, 64L, 35L,
66L, 2L, 35L, 28L, 30L, 18L, 69L, 32L, 10L, 28L, 17L, 36L, 64L,
61L, 10L, 64L, 33L, 3L, 37L, 26L, 28L, 64L, 44L, 28L, 64L, 64L,
6L, 6L, 64L, 50L, 32L, 8L, 64L, 50L, 28L, 24L, 18L, 47L, 35L,
40L, 24L, 55L, 44L, 22L, 1L, 49L, 44L, 18L, 45L, 63L, 64L, 35L,
12L, 35L, 10L, 35L, 10L, 10L, 10L, 44L, 44L, 44L, 65L, 44L, 55L,
32L, 49L, 64L, 39L, 69L, 1L, 60L, 7L, 14L, 44L, 33L, 10L, 19L,
10L, 70L, 53L, 8L, 61L, 61L, 44L, 61L, 65L, 28L, 68L, 69L, 27L,
61L, 28L, 72L, 34L, 61L, 32L, 10L, 49L, 35L, 49L, 10L, 10L, 69L,
39L, 40L, 19L, 59L, 53L, 49L, 49L, 44L, 49L, 35L, 49L, 61L, 61L,
1L, 10L, 28L, 49L, 35L, 49L, 61L, 50L, 69L, 35L, 61L, 35L, 50L,
10L, 28L, 69L, 61L, 21L, 69L, 29L, 35L, 35L, 35L, 11L, 69L, 8L,
41L, 56L, 35L, 61L, 69L, 49L, 49L, 49L, 1L, 13L, 64L, 64L, 52L,
44L, 64L, 64L, 50L, 49L, 69L, 11L, 59L, 49L, 31L), .Label = c("apparent",
"appropriate", "awful", "axiomatic", "best", "better", "breathtaking",
"certain", "characteristic", "clear", "conceivable", "convenient",
"crucial", "cruel", "desirable", "disappointing", "emphatic",
"essential", "evident", "expected", "extraordinary", "fair",
"fortunate", "Funny", "good", "great", "imperative", "important",
"impossible", "incredible", "inescapable", "inevitable", "interesting",
"ironic", "likely", "Likely", "lucky", "ludicrous", "natural",
"necessary", "needful", "notable", "noteworthy", "obvious", "odd",
"paradoxical", "plain", "plausible", "possible", "probable",
"proper", "relevant", "remarkable", "revealing", "right", "Sad",
"self-evident", "sensible", "significant", "striking", "surprising",
"symptomatic", "terrible", "true", "typical", "understandable",
"unexpected", "unfortunate", "unlikely", "unreasonable", "untrue",
"vital"), class = "factor")), .Names = c("ID", "GENRE", "NODE"
), class = "data.frame", row.names = c(NA, -388L))
As I mentioned already: facet_wrap is not intended for having individual scales. At least I didn't find a solution. Hence, setting the labels in scale_x_discrete did not bring the desired result.
But this my workaround:
library(plyr)
library(ggplot2)
nodeCount <- ddply( df, c("GENRE", "NODE"), nrow )
nodeCount$factors <- paste( nodeCount$GENRE, nodeCount$NODE, sep ="." )
nodeCount <- nodeCount[ order( nodeCount$GENRE, nodeCount$V1, decreasing=TRUE ), ]
nodeCount$factors <- factor( nodeCount$factors, levels=nodeCount$factors )
head(nodeCount)
GENRE NODE V1 factors
121 Popular Science possible 14 Popular Science.possible
128 Popular Science surprising 11 Popular Science.surprising
116 Popular Science likely 9 Popular Science.likely
132 Popular Science unlikely 9 Popular Science.unlikely
103 Popular Science clear 7 Popular Science.clear
129 Popular Science true 5 Popular Science.true
g <- ggplot( nodeCount, aes( y=V1, x = factors ) ) +
geom_bar() +
scale_x_discrete( breaks=NULL ) + # supress tick marks on x axis
facet_wrap( ~GENRE, scale="free_x" ) +
geom_text( aes( label = NODE, y = V1+2 ), angle = 45, vjust = 0, hjust=0, size=3 )
Which gives:

Resources