Error in migrating a ggplot graph to ver. 0.9.3 - r

Trying to migrate a ggplot graph to ver 0.9.3, the commented out line in the code below produces a Discrete value supplied to continuous scale error (which was not a problem before).
Can you help me correct it?
If you need the data to experiment with, I provide it below.
ggplot(mdfr, aes(as.Date(value, "%d/%m/%Y"), name, colour = factor(stadio))) +
geom_line(aes(size=rating)) +
labs(colour="Baseline/Actual :", x = "", y = "") +
scale_colour_brewer(palette="BrBG",breaks = c("1", "3", "6","8"),
labels = c("Label 1", "Label 2", "Label 3","Label 4")) +
scale_size_manual(breaks = levels(mdfr$rating), values = as.integer(levels(mdfr$rating)), guide = "none") +
theme_bw() +
#geom_vline(data=dfrDataDate, aes(xintercept= as.Date(data.date, "%Y-%m-%d")),colour=rgb(215, 25, 28, max = 255),size=1) +
geom_text(data=dfrDataDate, aes(x= as.Date(data.date, "%Y-%m-%d"), label = format(as.Date(data.date),"%d/%m/%Y")), hjust = -0.05, vjust = 1.5, colour = "darkred", size = 3 ) +
geom_text(data=dfrLabels, aes(x= as.Date(diag_date, "%d/%m/%Y"), label = format(as.Date(diag_date, "%d/%m/%Y"),"%d/%m/%Y")), hjust = 0.5, vjust = -1, colour = "black", size = 3 ) +
geom_text(data=dfrYpogr, aes(x= as.Date(ypogr_date, "%d/%m/%Y"), label = format(as.Date(ypogr_date, "%d/%m/%Y"),"%d/%m/%Y")), hjust = 0.5, vjust = -1, colour = "black", size = 3 ) +
scale_y_discrete(breaks=names, labels=new.names) +
ggtitle('New plot title') +
theme(plot.title = element_text(size=16),
legend.position = "top",
legend.title = element_text(size=12),
legend.text = element_text(size=10),
legend.key = element_rect(colour='white'),
axis.text.x = element_text(angle=0,size = 10),
axis.title.x = element_text(size=14),
axis.text.y = element_text(size=10),
axis.title.y = element_text(angle=90,size=14),
axis.ticks.length = unit(.05, "cm")
)
DATA needed to produce the graph:
mdfr <- structure(list(name = structure(c(22L, 22L, 22L, 22L, 20L, 20L,
20L, 20L, 18L, 18L, 18L, 18L, 16L, 16L, 16L, 16L, 14L, 14L, 14L,
14L, 12L, 12L, 12L, 12L, 10L, 10L, 10L, 10L, 8L, 8L, 8L, 8L,
6L, 6L, 6L, 6L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 21L, 21L, 21L,
21L, 19L, 19L, 19L, 19L, 17L, 17L, 17L, 17L, 15L, 15L, 15L, 15L,
13L, 13L, 13L, 13L, 11L, 11L, 11L, 11L, 9L, 9L, 9L, 9L, 7L, 7L,
7L, 7L, 5L, 5L, 5L, 5L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 22L,
22L, 22L, 22L, 20L, 20L, 20L, 20L, 18L, 18L, 18L, 18L, 16L, 16L,
16L, 16L, 14L, 14L, 14L, 14L, 12L, 12L, 12L, 12L, 10L, 10L, 10L,
10L, 8L, 8L, 8L, 8L, 6L, 6L, 6L, 6L, 4L, 4L, 4L, 4L, 2L, 2L,
2L, 2L, 21L, 21L, 21L, 21L, 19L, 19L, 19L, 19L, 17L, 17L, 17L,
17L, 15L, 15L, 15L, 15L, 13L, 13L, 13L, 13L, 11L, 11L, 11L, 11L,
9L, 9L, 9L, 9L, 7L, 7L, 7L, 7L, 5L, 5L, 5L, 5L, 3L, 3L, 3L, 3L,
1L, 1L, 1L, 1L), .Label = c("733 A", "733 B", "725 A", "725 B",
"727 A", "727 B", "558 A", "558 B", "705 A", "705 B", "635 A",
"635 B", "737 A", "737 B", "719 A", "719 B", "700 A", "700 B",
"579 A", "579 B", "541 A", "541 B"), class = "factor"), stadio = c(2,
4, 5, 7, 2, 4, 5, 7, 2, 4, 5, 7, 2, 4, 5, 7, 2, 4, 5, 7, 2, 4,
5, 7, 2, 4, 5, 7, 2, 4, 5, 7, 2, 4, 5, 7, 2, 4, 5, 7, 2, 4, 5,
7, 1, 3, 6, 8, 1, 3, 6, 8, 1, 3, 6, 8, 1, 3, 6, 8, 1, 3, 6, 8,
1, 3, 6, 8, 1, 3, 6, 8, 1, 3, 6, 8, 1, 3, 6, 8, 1, 3, 6, 8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L,
20L, 36L, 2L, 14L, 24L, 38L, 7L, 7L, 7L, 31L, 9L, 15L, 27L, 34L,
4L, 19L, 21L, 37L, 1L, 9L, 23L, 33L, 8L, 13L, 25L, 32L, 10L,
16L, 28L, 29L, 5L, 12L, 26L, 35L, 6L, 17L, 22L, 39L, 11L, 17L,
22L, 30L, 3L, 18L, 20L, 36L, 2L, 14L, 24L, 31L, 50L, 50L, 50L,
56L, 15L, 52L, 55L, 32L, 48L, 49L, 55L, 34L, 1L, 53L, 53L, 57L,
49L, 51L, 54L, 58L, 10L, 16L, 28L, 29L, 5L, 12L, 26L, 35L, 6L,
17L, 22L, 39L, 11L, 17L, 22L, 30L, 18L, 20L, 36L, 45L, 14L, 24L,
38L, 46L, 7L, 7L, 31L, 42L, 15L, 27L, 34L, 44L, 19L, 21L, 37L,
44L, 9L, 23L, 33L, 40L, 13L, 25L, 32L, 44L, 16L, 28L, 29L, 41L,
12L, 26L, 35L, 43L, 17L, 22L, 39L, 47L, 17L, 22L, 30L, 47L, 18L,
20L, 36L, 59L, 14L, 24L, 31L, 64L, 50L, 50L, 56L, 66L, 52L, 55L,
32L, 61L, 49L, 55L, 34L, 63L, 53L, 53L, 57L, 65L, 51L, 54L, 58L,
60L, 16L, 28L, 29L, 63L, 12L, 26L, 35L, 62L, 17L, 22L, 39L, 67L,
17L, 22L, 30L, 61L), .Label = c("03/05/2012", "07/06/2011", "22/02/2011",
"22/06/2012", "23/12/2011", "28/12/2011", "29/02/2012", "29/03/2012",
"29/06/2012", "30/05/2011", "30/12/2011", "03/02/2012", "04/07/2012",
"08/02/2012", "10/07/2012", "17/10/2011", "23/02/2012", "24/05/2011",
"25/07/2012", "01/06/2011", "01/08/2012", "02/03/2012", "05/07/2012",
"09/02/2012", "12/07/2012", "16/02/2012", "19/07/2012", "27/01/2012",
"06/04/2012", "07/06/2012", "08/05/2012", "09/10/2012", "11/09/2012",
"16/10/2012", "18/05/2012", "20/09/2011", "23/10/2012", "24/04/2012",
"31/05/2012", "04/02/2013", "09/09/2012", "12/11/2012", "19/11/2012",
"28/02/2013", "28/09/2012", "29/10/2012", "30/11/2012", "01/07/2012",
"06/07/2012", "22/03/2012", "02/08/2012", "17/07/2012", "31/07/2012",
"06/09/2012", "26/07/2012", "12/06/2012", "13/11/2012", "20/11/2012",
"17/01/2013", "21/05/2013", "21/12/2012", "22/07/2012", "28/12/2012",
"30/03/2013", "30/04/2013", "31/01/2013", "31/12/2012"), class = "factor"),
rating = structure(c(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, 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, 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), .Label = c("3", "5"), class = "factor")), row.names = c(NA,
-176L), .Names = c("name", "stadio", "variable", "value", "rating"
), class = "data.frame")
dfrDataDate <- structure(list(name = structure(1L, .Label = "733 A", class = "factor"),
data.date = structure(1L, .Label = "2013-01-02", class = "factor")), .Names = c("name",
"data.date"), row.names = c(NA, -1L), class = "data.frame")
dfrLabels <- structure(list(name = c("541 A", "579 A", "700 A", "719 A", "737 A",
"635 A", "705 A", "558 A", "727 A", "725 A", "733 A"), diag_date = c("20/09/2011",
"08/05/2012", "12/06/2012", "09/10/2012", "16/10/2012", "13/11/2012",
"20/11/2012", "06/04/2012", "18/05/2012", "31/05/2012", "07/06/2012"
)), .Names = c("name", "diag_date"), row.names = c(135L, 139L,
143L, 147L, 151L, 155L, 159L, 163L, 167L, 171L, 175L), class = "data.frame")
dfrYpogr <- structure(list(name = c("541 A", "579 A", "700 A", "719 A", "737 A",
"635 A", "705 A", "558 A", "727 A", "725 A", "733 A"), ypogr_date = c("17/01/2013",
"30/03/2013", "31/01/2013", "21/12/2012", "28/12/2012", "30/04/2013",
"21/05/2013", "28/12/2012", "22/07/2012", "31/12/2012", "21/12/2012"
)), .Names = c("name", "ypogr_date"), row.names = c(136L, 140L,
144L, 148L, 152L, 156L, 160L, 164L, 168L, 172L, 176L), class = "data.frame")
names <- as.character(unique(mdfr$name))
new.names <- c("No.541", "No.579", "No.700", "No.719", "No.737", "No.635",
"No.705", "No.558", "No.727", "No.725", "No.733", "", "",
"", "", "", "", "", "", "", "", "")

Adding of as.numeric() around as.Date() in call to geom_vline() makes red line to apear.
geom_vline(data=dfrDataDate, aes(xintercept= as.numeric(as.Date(data.date, "%Y-%m-%d"))),colour=rgb(215, 25, 28, max = 255),size=1)

Related

full_join adding extra rows and NA in r

I have two data frames that I am trying to join using full_join, here is a subset of my data:
df1 <- structure(list(Team = structure(c(4L, 3L, 5L, 6L, 7L, 7L, 8L,
8L, 9L, 9L, 10L, 10L, 11L, 11L, 12L, 12L, 14L, 13L, 15L, 15L,
16L, 16L, 17L, 17L, 18L, 18L, 19L, 19L, 20L, 20L, 21L, 22L, 23L,
23L, 24L, 24L, 25L, 25L, 28L, 28L, 29L, 29L, 30L, 30L, 31L, 31L,
32L, 32L, 33L, 33L, 34L, 34L, 2L, 1L, 26L, 27L), .Label = c("76ers",
"76ers ", "Bucks", "Bucks ", "Bull ", "Bulls ", "Cavaliers ",
"Celtics ", "Clippers ", "Grizzlies ", "Hawks ", "Heat ", "Hornets",
"Hornets ", "Jazz ", "Kings ", "Knicks ", "Lakers ", "Magic ",
"Mavericks ", "Net ", "Nets ", "Nuggets ", "Pacers ", "Pelicans ",
"Pistons", "Pistons ", "Raptors ", "Rockets ", "Spurs ", "Thunder ",
"Timberwolves ", "Warriors ", "Wizards "), class = "factor"),
Injury.Count = c(3L, 3L, 1L, 1L, 1L, 2L, 0L, 2L, 1L, 1L,
0L, 2L, 1L, 0L, 5L, 4L, 3L, 2L, 3L, 0L, 3L, 3L, 4L, 6L, 5L,
0L, 2L, 2L, 1L, 2L, 0L, 1L, 3L, 4L, 2L, 6L, 2L, 1L, 1L, 1L,
3L, 3L, 4L, 5L, 1L, 6L, 4L, 2L, 0L, 2L, 2L, 1L, 5L, 6L, 1L,
1L), HomevsAway = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 1L, 2L), .Label = c("0", "1"), class = "factor")), row.names = c(NA,
-56L), class = "data.frame")
df2 <- structure(list(Team = structure(c(1L, 1L, 2L, 2L, 3L, 4L, 4L,
5L, 6L, 7L, 8L, 9L, 9L, 10L, 10L, 11L, 12L, 12L, 13L, 13L, 14L,
15L, 15L, 16L, 16L, 17L, 18L, 18L, 19L, 19L, 20L, 20L, 21L, 21L,
22L, 22L, 23L, 23L, 24L, 24L, 25L, 25L, 26L, 26L, 27L, 28L, 28L,
3L, 5L, 6L, 7L, 8L, 11L, 14L, 17L, 27L), .Label = c("76ers",
"Bucks", "Bulls", "Cavaliers", "Celtics", "Clippers", "Grizzlies",
"Hawks", "Heat", "Hornets", "Jazz", "Kings", "Knicks", "Lakers",
"Magic", "Mavericks", "Nets", "Nuggets", "Pacers", "Pelicans",
"Pistons", "Raptors", "Rockets", "Spurs", "Thunder", "Timberwolves",
"Warriors", "Wizards"), class = "factor"), HomevsAway = structure(c(1L,
2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 1L,
2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L,
1L, 1L, 2L, 2L, 2L, 1L, 1L), .Label = c("0", "1"), class = "factor"),
t_1 = c(55.883, 140.1, 32.2, 37.967, 29.85, 24.317, 57.316,
17.967, 19.05, 36.95, 16.167, 95.317, 86.533, 21.334, 52.567,
40.75, 28.3, 68.15, 97.067, 102.233, 26.866, 71.033, 34.467,
24.233, 42.033, 22.433, 59.033, 41.516, 12.7, 107.996, 6.5,
32.783, 0, 23.217, 13.93, 0, 54.88, 23.617, 83.834, 106.794,
17.56, 27.76, 85.83, 0.017, 35.183, 22.467, 25.033, 0, 0,
0, 0, 0, 0, 0, 0, 0), t_3 = c(197.3164, 388.6827, 126.2663,
111.916, 61.95, 91.55, 167.067, 104.083, 71.067, 135.383,
45.633, 261.317, 267.399, 114.6997, 159.2, 152.034, 84.8337,
204.3003, 351.449, 376.317, 86.333, 213.9, 99.767, 65.1,
131.767, 73.317, 126.416, 129.066, 73.383, 347.0994, 4761,
113.367, 0, 89.933, 59.8, 0, 188.983, 124.384, 215.666, 289.9667,
92, 144.2497, 254.083, 32.0333, 122.1837, 102.533, 82.817,
0, 0, 0, 0, 0, 0, 0, 0, 0)), row.names = c(NA, -56L), groups = structure(list(
Team = structure(1:28, .Label = c("76ers", "Bucks", "Bulls",
"Cavaliers", "Celtics", "Clippers", "Grizzlies", "Hawks",
"Heat", "Hornets", "Jazz", "Kings", "Knicks", "Lakers", "Magic",
"Mavericks", "Nets", "Nuggets", "Pacers", "Pelicans", "Pistons",
"Raptors", "Rockets", "Spurs", "Thunder", "Timberwolves",
"Warriors", "Wizards"), class = "factor"), .rows = structure(list(
1:2, 3:4, c(5L, 48L), 6:7, c(8L, 49L), c(9L, 50L), c(10L,
51L), c(11L, 52L), 12:13, 14:15, c(16L, 53L), 17:18,
19:20, c(21L, 54L), 22:23, 24:25, c(26L, 55L), 27:28,
29:30, 31:32, 33:34, 35:36, 37:38, 39:40, 41:42, 43:44,
c(45L, 56L), 46:47), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), row.names = c(NA, 28L), class = c("tbl_df",
"tbl", "data.frame"), .drop = TRUE), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"))
I have tried to join the data using full_join:
LR <- full_join(df1, df2, by = c("HomevsAway", "Team"))
The output of LR I am receiving is giving me extra rows with random NA's involved. My expected output should be a 56rowx5col table.
The problem is that in your first data.frame the Team names have a trailing space. This means that instead of the string "Bucks" you have the string "Bucks ".
These two strings cannot be joined.
Here is how you can fix your data. First delete leading spaces using sub and then transform the Team into a character vector. Then the full_join works as planned:
df1_new <- df1 %>% as_tibble() %>%
mutate(Team = sub(" +", "", as.character(Team)))
df2_new <- df2 %>%
mutate(Team = as.character(Team))
df1_new %>% full_join(df2_new, by = c("Team", "HomevsAway"))
# A tibble: 58 x 5
Team Injury.Count HomevsAway t_1 t_3
<chr> <int> <fct> <dbl> <dbl>
1 Bucks 3 0 32.2 126.
2 Bucks 3 1 38.0 112.
3 Bull 1 0 NA NA
4 Bulls 1 1 0 0
5 Cavaliers 1 0 24.3 91.6
6 Cavaliers 2 1 57.3 167.
7 Celtics 0 0 0 0
8 Celtics 2 1 18.0 104.
9 Clippers 1 0 0 0
10 Clippers 1 1 19.0 71.1
Note that there are still a few NAs. This is due to some typos: Bull vs Bulls and Net vs Nets.

How to create a faceted boxplot with the significant differences, and 2 measured variables?

I managed to create a faceted boxplot with my 2 quantitative variables;
I know how to run a kruskal-wallis followed by a Wilcoxon test and show the significant differences with letters in the boxplot but only in a simple boxplot, with one variable and without facet. How can I do ?
(If possible, I would like to put the siginificant differences with letters, I wish I would be able to post the pictures of what I already done but apparently I'm not allowed)
Also, I have another question; Which test does the function stat_function_mean execute ? I tried to use this function, but I don't know how to use it... Here is my code without the test, only the facetted boxplot with my two variables :
Code for my facet boxplot with 2 measured variables ( FF and FM)
dat.m2 <- melt(pheno,id.vars=c("fusion","Genotype","Hormone"),
measure.vars=c('FF','MF'))
dat.m2$fusion<-factor(dat.m2$fusion, levels=c("Control", "CK 20 mg/L", "CK 100 mg/L", "CK 500 mg/L", "GA 20 mg/L", "GA 100 mg/L", "GA 500 mg/L"))
levels(dat.m2$fusion)
ggplot(dat.m2) +
geom_boxplot(aes(x=fusion, y=value, colour=variable))+
facet_wrap(~Genotype)+
xlab(" ")+
ylab("Days after sowing")
Code to add significant differences on the graph, with letters, but with only 1 measured variable (FF), without facet
mymat <-tri.to.squ(pp$p.value)
mymat
myletters <- multcompLetters(mymat,compare="<=",threshold=0.05,Letters=letters)
myletters
myletters_df <- data.frame(fusion=names(myletters$Letters),letter = myletters$Letters )
myletters_df
ggplot(pheno, aes(x=fusion, y=FF, colour=fusion))+
geom_boxplot()+
geom_text(data = myletters_df, aes(label = letter, y = 30 ), colour="black", size=5)+
ylab("Days after sowing")+
xlab("")+
labs(title="Days to female flower production")+
theme(plot.title = element_text(hjust = 0.5))+
> dput(pheno)
structure(list(Genotype = structure(c(2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L,
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L,
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c("F1045",
"FF", "M1585", "M1610"), class = "factor"), X = structure(c(1L,
105L, 116L, 127L, 138L, 149L, 160L, 171L, 182L, 2L, 13L, 24L,
35L, 46L, 57L, 68L, 79L, 90L, 101L, 106L, 107L, 108L, 109L, 110L,
111L, 112L, 113L, 114L, 115L, 117L, 118L, 119L, 120L, 121L, 122L,
123L, 124L, 125L, 126L, 128L, 129L, 130L, 131L, 132L, 133L, 134L,
135L, 136L, 137L, 139L, 140L, 141L, 142L, 143L, 144L, 145L, 146L,
147L, 148L, 150L, 151L, 152L, 153L, 154L, 155L, 156L, 157L, 158L,
159L, 161L, 162L, 163L, 164L, 165L, 166L, 167L, 168L, 169L, 170L,
172L, 173L, 174L, 175L, 176L, 177L, 178L, 179L, 180L, 181L, 183L,
184L, 185L, 186L, 187L, 188L, 189L, 190L, 191L, 192L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 14L, 15L, 16L, 17L, 18L, 19L,
20L, 21L, 22L, 23L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
34L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 47L, 48L,
49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 58L, 59L, 60L, 61L, 62L,
63L, 64L, 65L, 66L, 67L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L,
77L, 78L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L, 89L, 91L,
92L, 93L, 94L, 95L, 96L, 97L, 98L, 99L, 100L, 102L, 103L, 104L
), .Label = c("H1", "H10", "H100", "H101", "H102", "H103", "H104",
"H105", "H106", "H107", "H108", "H109", "H11", "H110", "H111",
"H112", "H113", "H114", "H115", "H116", "H117", "H118", "H119",
"H12", "H120", "H121", "H122", "H123", "H124", "H125", "H126",
"H127", "H128", "H129", "H13", "H130", "H131", "H132", "H133",
"H134", "H135", "H136", "H137", "H138", "H139", "H14", "H140",
"H141", "H142", "H143", "H144", "H145", "H146", "H147", "H148",
"H149", "H15", "H150", "H151", "H152", "H153", "H154", "H155",
"H156", "H157", "H158", "H159", "H16", "H160", "H161", "H162",
"H163", "H164", "H165", "H166", "H167", "H168", "H169", "H17",
"H170", "H171", "H172", "H173", "H174", "H175", "H176", "H177",
"H178", "H179", "H18", "H180", "H181", "H182", "H183", "H184",
"H185", "H186", "H187", "H188", "H189", "H19", "H190", "H191",
"H192", "H2", "H20", "H21", "H22", "H23", "H24", "H25", "H26",
"H27", "H28", "H29", "H3", "H30", "H31", "H32", "H33", "H34",
"H35", "H36", "H37", "H38", "H39", "H4", "H40", "H41", "H42",
"H43", "H44", "H45", "H46", "H47", "H48", "H49", "H5", "H50",
"H51", "H52", "H53", "H54", "H55", "H56", "H57", "H58", "H59",
"H6", "H60", "H61", "H62", "H63", "H64", "H65", "H66", "H67",
"H68", "H69", "H7", "H70", "H71", "H72", "H73", "H74", "H75",
"H76", "H77", "H78", "H79", "H8", "H80", "H81", "H82", "H83",
"H84", "H85", "H86", "H87", "H88", "H89", "H9", "H90", "H91",
"H92", "H93", "H94", "H95", "H96", "H97", "H98", "H99"), class = "factor"),
Hormone = structure(c(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, 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, 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, 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), .Label = c("CK", "Control", "GA"), class = "factor"),
Hormone.quantity = structure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3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 4L, 3L, 4L, 3L, 3L, 3L, 4L, 3L, 6L, 6L, 8L, 6L, 4L, 4L,
4L, 8L, 4L, 4L, 2L, 3L, 3L, 3L, 3L, 6L, 3L, 5L, 4L, 5L, 5L,
4L, 3L), .Label = c("16-apr", "17-apr", "18-apr", "19-apr",
"21-mei", "23-apr", "26-apr", "30-apr"), class = "factor"),
ff = structure(c(14L, 20L, 4L, 10L, 20L, 3L, 1L, 14L, 9L,
11L, 20L, 11L, 9L, 9L, 9L, 11L, 12L, 12L, 6L, 12L, 12L, 16L,
12L, 12L, 17L, 17L, 12L, 16L, 17L, 18L, 12L, 6L, 20L, 20L,
15L, 15L, 15L, 20L, 20L, 11L, 11L, 11L, 9L, 9L, 9L, 9L, 20L,
20L, 20L, 4L, 1L, 4L, 4L, 4L, 8L, 20L, 4L, 20L, 12L, 4L,
14L, 14L, 11L, 11L, 15L, 15L, 11L, 11L, 9L, 15L, 9L, 9L,
11L, 11L, 14L, 1L, 5L, 4L, 4L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 15L, 15L, 14L, 13L, 15L, 15L, 11L, 9L, 9L,
11L, 9L, 11L, 1L, 20L, 1L, 20L, 20L, 20L, 20L, 1L, 1L, 4L,
20L, 20L, 20L, 15L, 15L, 14L, 15L, 1L, 15L, 15L, 20L, 11L,
11L, 11L, 11L, 15L, 10L, 10L, 16L, 10L, 12L, 10L, 17L, 8L,
16L, 12L, 8L, 4L, 4L, 8L, 20L, 10L, 1L, 20L, NA, 12L, 10L,
20L, 20L, 20L, 1L, 20L, 1L, 20L, 12L, 16L, 12L, 2L, 8L, 4L,
10L, 4L, 4L, 4L, 10L, 8L, 4L, 8L, 20L, 20L, 20L, NA, 20L,
1L, 20L, 1L, 8L, 20L, 1L, 1L, 7L, 17L, 19L, 19L, 12L, 10L,
12L, 19L, 10L, 10L, 10L, 17L), .Label = c("10-mei", "13-jun",
"14-apr", "14-mei", "17-mei", "18-jun", "21-jun", "21-mei",
"23-apr", "24-mei", "26-apr", "28-mei", "3-apr", "3-mei",
"30-apr", "31-mei", "4-jun", "5-jul", "7-jun", "7-mei"), class = "factor"),
FH = c(3.5, 6, 9, 16, 5.5, 12, 11.5, 4, 4.5, 6, 8, 5, 4.5,
3.5, 4, 5, 20, 42, 14, 40, 27, 42, 27, 26, 16, 18, 35, 17,
20, 28, 15, 20, 33, 32, 14.5, 14.5, 14.5, 35, 32, 12.5, 13.5,
12, 14.5, 12, 15, 14.5, 18, 18, 18.5, 35, 23, 25, 30, 37,
53, 27.5, 37, 25.5, 35, 47, 8.5, 20.5, 13, 14.5, 13.5, 18.5,
10.5, 10, 14.3, 18.5, 15.3, 11.7, 16, 15, 13.5, 26, 36, 30,
43, 23.5, 23.5, 31.5, 29, 30.5, 30, 29, 30, 24.5, 19, 23,
21.5, 26.5, 18.5, 20, 15, 12.3, 17, 12, 15, 13, 43614, 25,
27, 22.5, 35, 23.5, 30, 42, 42, 55, 32.5, 26, 26, 9.5, 4.5,
5.5, 5, 15.5, 10, 4.5, 8.5, 6, 5, 5.5, 5, 4.5, 30, 20, 16,
16, 20, 22, 30, 22, 25, 11, 13.5, 11, 11, 14, 6, NA, 5.5,
7, NA, 12, 14, 7, 9.5, 6.5, 9, 8.5, 12.5, 8, 27, 33, 35,
32, 17, 14, 22, 11, 17, 12, 25, 22, 15, 10, 5, 3, 4, NA,
5, 8, 4.5, 6, 7, 5, 5.5, 7, 42, 23, 23, 21, 14, 21, 17, 22,
19, 18, 17, 17), SRDT = structure(c(2L, 7L, 14L, NA, 7L,
8L, 7L, NA, NA, NA, 3L, NA, 18L, 15L, 17L, 17L, 18L, 18L,
NA, 18L, 15L, 17L, 15L, 20L, 2L, NA, 11L, 17L, 18L, 2L, 2L,
2L, 14L, 12L, 17L, 15L, 12L, 9L, 9L, 6L, 6L, 15L, 15L, 15L,
15L, NA, 17L, 15L, 10L, 11L, 11L, 10L, 11L, 17L, 5L, 21L,
6L, NA, 20L, 5L, 12L, 7L, NA, 17L, 17L, 15L, 15L, 10L, 10L,
6L, 10L, 10L, 21L, NA, 15L, 15L, 5L, 15L, 15L, 11L, 10L,
21L, 1L, 21L, 21L, 21L, 1L, 5L, 18L, 2L, 9L, 9L, NA, 12L,
10L, NA, 16L, 6L, 6L, 15L, 6L, 10L, 10L, 10L, 1L, 10L, 1L,
21L, 21L, 1L, 21L, 5L, 18L, 2L, 17L, 20L, 9L, 14L, 5L, 9L,
9L, 11L, NA, 18L, 10L, 18L, 20L, 4L, 9L, 7L, 2L, 2L, 7L,
5L, 17L, 17L, 11L, 10L, 12L, 2L, 14L, 19L, 19L, 19L, NA,
NA, 2L, 11L, 17L, 14L, 17L, 9L, 10L, 10L, 2L, 7L, 17L, 14L,
2L, 11L, 20L, 2L, 15L, 15L, 11L, 5L, NA, 10L, NA, 2L, 8L,
NA, NA, 14L, 5L, 15L, 15L, NA, 22L, NA, 9L, 9L, 19L, 9L,
9L, 22L, 20L, 13L, 7L, 20L, 15L, 20L), .Label = c("10-mei",
"11-jun", "13-jun", "13-mei", "14-mei", "17-mei", "18-jun",
"2-jul", "21-jun", "21-mei", "24-mei", "25-jun", "26-jun",
"28-jun", "28-mei", "3-mei", "31-mei", "4-jun", "5-jul",
"7-jun", "7-mei", "9-jul"), class = "factor"), MH = c(26,
50, 58, NA, 46, 58, 61, NA, NA, NA, 40, NA, 68, 48, 47, 42,
26, 50, NA, 48, 27, 42, 27, 48, 25, NA, 25, 17, 20, 18, 32,
19, 75, 75, 65, 70, 73, 73, 71, 65, 70, 60, 80, 70, 70, NA,
54, 45, 45, 45, 45, 40, 49, 53, 45, 27.5, 44, NA, NA, 47,
47, 62, NA, 75, 60, 75, 70, 65, 80, 67, 80, 75, 52, NA, 67,
68, 26, 55, 60, 60, 60, 31.5, 39, 30.5, 30, 29, 39, 39, 86,
74, 80, 76, NA, 69, 80, NA, 44, 70, 70, 65, 43, 60, 57, 57,
45, 60, 39, 35, 32.5, 27, 32.5, 43, 70, 75, 60, 66, 58, 48,
41, NA, 44, 42, NA, 44, 39, 40, 48, 53, 50, 50, 45, 45, 50,
13, 25, 11, 21, 20.5, 46, 44, 54, 25, 20, 25, NA, NA, 28,
33, 36, 40, 21, 36, 23.5, 21, 44, 60, 37, 37, 55, 24, 45,
45, 35, 30, 25, 12, 27, 10, NA, 53, 35, NA, NA, 43, 11, 13,
7, NA, 22, NA, 42, 46, NA, 41, 43, 40, 26, 45, 35, 29, 17,
22), SEEDT = structure(c(2L, 4L, 9L, NA, 4L, 5L, 4L, NA,
NA, NA, 4L, NA, 12L, 11L, 11L, 11L, 4L, 3L, NA, 4L, 15L,
4L, 8L, 5L, 7L, NA, 2L, 2L, 8L, 13L, 8L, NA, 13L, 8L, 15L,
15L, 8L, 7L, 7L, 10L, 10L, 11L, 6L, 10L, 10L, NA, 3L, 11L,
12L, 12L, 12L, 12L, 4L, 4L, 12L, 12L, 12L, NA, 9L, 12L, NA,
4L, NA, 2L, 15L, 2L, 15L, 14L, 10L, 12L, 12L, 11L, 11L, NA,
2L, 12L, 8L, 3L, 15L, 11L, 11L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 2L, 2L, 7L, 7L, NA, 8L, 10L, NA, 10L, 10L, 10L,
15L, 10L, 12L, 12L, 10L, 11L, 11L, 10L, 10L, 10L, 11L, 10L,
11L, 12L, 2L, 12L, 4L, 7L, 9L, 10L, 7L, 7L, 10L, NA, 12L,
10L, 15L, 2L, 4L, 8L, 8L, 4L, 4L, 13L, 12L, NA, NA, 4L, 7L,
NA, 7L, 13L, 13L, 13L, NA, NA, NA, 2L, 2L, NA, NA, NA, 8L,
NA, NA, 4L, 4L, 2L, NA, 4L, 2L, 7L, 7L, 7L, 2L, 2L, 15L,
1L, 15L, NA, 2L, 5L, NA, NA, 5L, 13L, NA, NA, NA, NA, NA,
16L, 16L, 13L, 16L, 7L, 1L, 7L, 16L, 7L, 7L, 7L, NA), .Label = c("11-jul",
"11-jun", "13-jun", "18-j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A,
2L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 4L, 5L, NA, NA, 5L, 6L, 1L,
1L, NA, 1L, 1L, 0L, 1L, 1L, 1L, NA, 2L, 1L, 2L, NA, 2L, NA,
4L, 3L, 2L, 2L, 1L, 4L, 5L, 5L, 4L, 5L, 7L, 6L, 1L, 1L, 1L,
1L, NA, 1L, 2L, NA, 1L, 1L, 1L, 1L, 3L, 3L, 1L, 4L, 5L, 2L,
4L, 7L, 5L, 8L, 5L, 2L, 0L, 1L, 1L, 1L, 7L, 1L, 0L, 1L, 1L,
0L, 0L, 0L, 0L, NA, 2L, 3L, 1L, 1L, 2L, 1L, 2L, 6L, 6L, NA,
4L, 4L, NA, 2L, 2L, 1L, 1L, 1L, NA, 1L, 1L, 3L, 1L, 1L, 1L,
1L, NA, NA, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 5L, 5L, 4L,
1L, 4L, NA, 2L, 1L, NA, NA, 2L, 2L, 0L, 0L, NA, 1L, NA, 4L,
2L, 1L, 2L, 1L, 2L, 4L, 1L, 2L, 4L, 3L, NA), FF = c(39L,
43L, 50L, 60L, 43L, 20L, 46L, 39L, 29L, 32L, 43L, 32L, 29L,
29L, 29L, 32L, 64L, 64L, 85L, 64L, 64L, 67L, 64L, 64L, 71L,
71L, 64L, 67L, 71L, 102L, 64L, 85L, 43L, 43L, 36L, 36L, 36L,
43L, 43L, 32L, 32L, 32L, 29L, 29L, 29L, 29L, 43L, 43L, 43L,
50L, 46L, 50L, 50L, 50L, 57L, 43L, 50L, 43L, 64L, 50L, 39L,
39L, 32L, 32L, 36L, 36L, 32L, 32L, 29L, 36L, 29L, 29L, 32L,
32L, 39L, 46L, 53L, 50L, 50L, 43L, 43L, 43L, 43L, 43L, 43L,
43L, 43L, 43L, 36L, 36L, 39L, 9L, 36L, 36L, 32L, 29L, 29L,
32L, 29L, 32L, 46L, 43L, 46L, 43L, 43L, 43L, 43L, 46L, 46L,
50L, 43L, 43L, 43L, 36L, 36L, 39L, 36L, 46L, 36L, 36L, 43L,
32L, 32L, 32L, 32L, 36L, 60L, 60L, 67L, 60L, 64L, 60L, 71L,
57L, 67L, 64L, 57L, 50L, 50L, 57L, 43L, 60L, 46L, 43L, NA,
64L, 60L, 43L, 43L, 43L, 46L, 43L, 46L, 43L, 64L, 67L, 64L,
80L, 57L, 50L, 60L, 50L, 50L, 50L, 60L, 57L, 50L, 57L, 43L,
43L, 43L, NA, 43L, 46L, 43L, 46L, 57L, 43L, 46L, 46L, 88L,
71L, 74L, 74L, 64L, 60L, 64L, 74L, 60L, 60L, 60L, 71L), MF = c(78L,
85L, 95L, NA, 85L, 99L, 85L, NA, NA, NA, 80L, NA, 71L, 64L,
67L, 67L, 71L, 71L, NA, 71L, 64L, 67L, 64L, 74L, 78L, NA,
60L, 67L, 71L, 78L, 78L, 78L, 95L, 92L, 67L, 64L, 92L, 88L,
88L, 53L, 53L, 64L, 64L, 64L, 64L, NA, 67L, 64L, 57L, 60L,
60L, 57L, 60L, 67L, 50L, 43L, 53L, NA, 74L, 50L, 92L, 85L,
NA, 67L, 67L, 64L, 64L, 57L, 57L, 53L, 57L, 57L, 43L, NA,
64L, 64L, 50L, 64L, 64L, 60L, 57L, 43L, 46L, 43L, 43L, 43L,
46L, 50L, 71L, 78L, 88L, 88L, NA, 92L, 57L, NA, 39L, 53L,
53L, 64L, 53L, 57L, 57L, 57L, 46L, 57L, 46L, 43L, 43L, 46L,
43L, 50L, 71L, 78L, 67L, 74L, 88L, 95L, 50L, 88L, 88L, 60L,
NA, 71L, 57L, 71L, 74L, 49L, 88L, 85L, 78L, 78L, 85L, 50L,
67L, 67L, 60L, 57L, 92L, 78L, 95L, 102L, 102L, 102L, NA,
NA, 78L, 60L, 67L, 95L, 67L, 88L, 57L, 57L, 78L, 85L, 67L,
95L, 78L, 60L, 74L, 78L, 64L, 64L, 60L, 50L, NA, 57L, NA,
78L, 99L, NA, NA, 95L, 50L, 64L, 64L, NA, 106L, NA, 88L,
88L, 102L, 88L, 88L, 106L, 74L, 93L, 85L, 74L, 64L, 74L),
speed = c(0.08974359, 0.139534884, 0.18, 0.266666667, 0.127906977,
0.6, 0.25, 0.102564103, 0.155172414, 0.1875, 0.186046512,
0.15625, 0.155172414, 0.120689655, 0.137931034, 0.15625,
0.3125, 0.65625, 0.164705882, 0.625, 0.421875, 0.626865672,
0.421875, 0.40625, 0.225352113, 0.253521127, 0.546875, 0.253731343,
0.281690141, 0.274509804, 0.234375, 0.235294118, 0.76744186,
0.744186047, 0.402777778, 0.402777778, 0.402777778, 0.813953488,
0.744186047, 0.390625, 0.421875, 0.375, 0.5, 0.413793103,
0.517241379, 0.5, 0.418604651, 0.418604651, 0.430232558,
0.7, 0.5, 0.5, 0.6, 0.74, 0.929824561, 0.639534884, 0.74,
0.593023256, 0.546875, 0.94, 0.217948718, 0.525641026, 0.40625,
0.453125, 0.375, 0.513888889, 0.328125, 0.3125, 0.493103448,
0.513888889, 0.527586207, 0.403448276, 0.5, 0.46875, 0.346153846,
0.565217391, 0.679245283, 0.6, 0.86, 0.546511628, 0.546511628,
0.73255814, 0.674418605, 0.709302326, 0.697674419, 0.674418605,
0.697674419, 0.569767442, 0.527777778, 0.638888889, 0.551282051,
2.944444444, 0.513888889, 0.555555556, 0.46875, 0.424137931,
0.586206897, 0.375, 0.517241379, 0.40625, 948.1304348, 0.581395349,
0.586956522, 0.523255814, 0.813953488, 0.546511628, 0.697674419,
0.913043478, 0.913043478, 1.1, 0.755813953, 0.604651163,
0.604651163, 0.263888889, 0.125, 0.141025641, 0.138888889,
0.336956522, 0.277777778, 0.125, 0.197674419, 0.1875, 0.15625,
0.171875, 0.15625, 0.125, 0.5, 0.333333333, 0.23880597, 0.266666667,
0.3125, 0.366666667, 0.422535211, 0.385964912, 0.373134328,
0.171875, 0.236842105, 0.22, 0.22, 0.245614035, 0.139534884,
NA, 0.119565217, 0.162790698, NA, 0.1875, 0.233333333, 0.162790698,
0.220930233, 0.151162791, 0.195652174, 0.197674419, 0.27173913,
0.186046512, 0.421875, 0.492537313, 0.546875, 0.4, 0.298245614,
0.28, 0.366666667, 0.22, 0.34, 0.24, 0.416666667, 0.385964912,
0.3, 0.175438596, 0.11627907, 0.069767442, 0.093023256, NA,
0.11627907, 0.173913043, 0.104651163, 0.130434783, 0.122807018,
0.11627907, 0.119565217, 0.152173913, 0.477272727, 0.323943662,
0.310810811, 0.283783784, 0.21875, 0.35, 0.265625, 0.297297297,
0.316666667, 0.3, 0.283333333, 0.23943662), ratiofm = c(7,
4, 8, 7, 8, 8, 8, NA, NA, NA, 5, 3.5, NA, NA, NA, NA, 4,
6, NA, 4, 3, 2, 4, 4, 0.5, NA, 0.4, 0.4, 0.5, 0.2, 0.666666667,
0.5, 8, 6, 6, 6, 7, 7, 7, 3, 3, 3.5, 3.5, 6, 4, NA, 3, 2.5,
3, 5, 2.5, 3, 5, 4, 0.5, 1, NA, NA, 0.8, 0.333333333, 5,
5, NA, 7, 7, NA, 6, 6, 7, NA, 3.5, 7, 3, NA, 2.5, NA, 1,
1.333333333, 3, 3.5, 6, 1, 0.4, 0.4, 0.5, 0.4, 0.285714286,
0.333333333, 8, 7, 7, 7, NA, 7, 3.5, NA, 7, 7, 7, 7, 1.666666667,
1.666666667, 4, 1.25, 1.2, 2, 1.5, 0.285714286, 0.4, 0.25,
1, 2, NA, 6, 8, 7, 0.857142857, 6, NA, 7, 7, NA, NA, NA,
NA, NA, 3.5, 1.666666667, 5, 4, 2, 4, 2, 0.333333333, 0.333333333,
NA, 0.75, 0.5, NA, 1.5, 3, 5, 5, 6, NA, 6, 4, 2, 5, 5, 5,
5, NA, NA, 4, 4, 3, 2.5, 3, 2.5, 2.333333333, 3.5, 3.5, 0.6,
0.4, 0.75, 3, 1, NA, 2.5, 5, NA, NA, 2.5, 1.5, NA, NA, NA,
4, NA, 1.25, 2, 5, 2.5, 6, 2, 1, 3, 1.5, 1, 1.666666667,
NA)), class = "data.frame", row.names = c(NA, -192L))
It would be more clear with pictures of my graphs, but apparently I'm not allowed yet to include pictures in my posts, sorry
Thanks in advance for your help
you can try
library(tidyverse)
df %>%
as_tibble() %>%
ggplot(aes(x=fusion, y=FF)) +
geom_boxplot(aes(colour=fusion))+
ggsignif::geom_signif(comparisons = combn(levels(df$fusion), 2, simplify = F), step_increase = 0.3) +
ggpubr::stat_compare_means() +
facet_wrap(~Genotype)+
xlab(" ")+
ylab("Days after sowing")

Adding Text to a Facet Grid

I am till having trouble with this, so I have edited my question (below) to include my data.
I would like to add two different labels (the respective sample sizes) to each of the sections of the grid.
I know I need to use geom_text, but I just can't seem to get it to work. Everything I have tried has returned errors. Here is the code I used to make my graph so far:
ggplot(data = Q, mapping = aes(y = Rating, x = week, group= StudentFactor, colour=StudentFactor))+
geom_point()+
geom_line()+
facet_grid(Type ~.)+
geom_smooth(method = 'lm', formula = y ~ poly(x), colour= "black", aes(group=1), se= FALSE)+
theme(legend.position="none") +
labs (x= "Week", y="Rating of Q: Seniors Supportive vs. Supporting First Years")
Someone mentioned that it might be helpful if I included the following:
> dput(Q)
structure(list(StudentFactor = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 6L, 6L, 6L,
6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L,
9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 23L, 23L,
23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 25L, 26L,
26L, 26L, 26L, 26L, 27L, 27L, 27L, 28L, 28L, 29L, 29L, 29L, 29L,
29L, 29L, 29L, 29L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
30L, 31L, 31L, 31L, 32L, 32L, 32L, 32L, 32L, 32L, 33L, 33L, 33L,
33L, 33L, 33L, 33L, 33L, 34L, 34L, 34L, 34L, 35L, 35L, 35L, 35L,
35L, 35L, 35L, 35L, 35L, 35L, 36L, 36L, 36L), .Label = c("789331",
"796882", "805933", "826523", "827911", "830271", "831487", "832929",
"834598", "836364", "838607", "839802", "841903", "843618", "852125",
"855524", "873527", "876406", "879972", "885409", "885650", "888712",
"894218", "903303", "928026", "952797", "955389", "956952", "957206",
"957759", "959200", "962490", "965873", "967416", "968728", "969005"
), class = "factor"), Question = 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,
1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-1, 0, -1, 0, 1, 1, 0, 0, 1, 0, 0, 1,
-1, 1, -1, 0, -2, 2, -1, -1, 1, 0, 0)), class = "data.frame", row.names = c(NA,
-231L), .Names = c("StudentFactor", "Question", "Type", "week",
"Rating"))
Earlier Question:
I have used the following code to make this graph:
ggplot(data = Q, mapping = aes(y = Rating, x = week, group= StudentFactor, colour=StudentFactor))+
geom_point()+
geom_line()+
facet_grid(Q$Type ~.)+
geom_smooth(method = "lm", se=FALSE, color="black", aes(group=1))+
theme(legend.position="none") +
labs (x= "Week", y="Rating of Q: Seniors Supportive vs. Supporting First Years")
However, as soon as I try to add an annotation to include the sample size for each cohort, I get the following error:
Error in `$<-.data.frame`(`*tmp*`, "PANEL", value = c(2L, 2L, 2L, 2L, :
replacement has 231 rows, data has 1
This is the code I am trying to use:
ggplot(data = Q, mapping = aes(y = Rating, x = week, group= StudentFactor, colour=StudentFactor))+
geom_point()+
geom_line()+
facet_grid(Q$Type ~.)+
geom_smooth(method = "lm", se=FALSE, color="black", aes(group=1))+
theme(legend.position="none") +
labs (x= "Week", y="Rating of Q: Seniors Supportive vs. Supporting First Years")+
annotate("text", x = 1, y=4, label = "N=")
I am a complete beginner at R. Any help would be appreciated! Thank you in advance!
I guess, you would like to label each panel with the respective sample size, or to add the total sample size just in one place. In that case annotate will be of no use (see for example this question), but you can use geom_text instead:
You would create a separate data.frame for your labels, which you then use inside of geom_text:
library(ggplot2)
labels <- tibble::tribble(~mpg, ~hp, ~cyl, ~label,
15, 200, 4, "label 1",
15, 150, 6, "label 2")
ggplot(mtcars, aes(mpg, hp)) +
geom_point() +
facet_wrap(~cyl) +
geom_text(data = labels, aes(label = label))
(Since you didn't provide data which would make it possible to reproduce your graphs, I simply used mtcars to illustrate the problem.)
Edit:
Using your data I adapted the code. First you create a data.frame for your label(s):
labels <- data.frame(
x = 2.5,
y = 3,
Type = "FYS",
label = "mylabel"
)
Then you simply add the following line to your code:
... +
geom_text(data = labels, aes(x = x, y = y, label = label), inherit.aes = FALSE)
This approach is slightly different than what I showed above: Either you supply the coordinates according to your variables, which you use in the rest of the plot, or you give them new names, use inherit.aes = FALSE and set the new variables with aes as demonstrated with your data.
Full code:
labels <- data.frame(
x = 2.5,
y = 3,
Type = "FYS",
label = "mylabel"
)
ggplot(data = Q, mapping = aes(y = Rating, x = week, group= StudentFactor, colour=StudentFactor))+
geom_point()+
geom_line()+
facet_grid(Type ~ .)+
geom_smooth(method = 'lm', formula = y ~ poly(x), colour= "black", aes(group=1), se= FALSE)+
theme(legend.position="none") +
labs (x= "Week", y="Rating of Q: Seniors Supportive vs. Supporting First Years") +
geom_text(data = labels, aes(x = x, y = y, label = label), inherit.aes = FALSE)
Your error is due to using facet_grid incorrectly. Replace your line with facet_grid(Type ~.)+ instead of Q$Type. For example:
ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
geom_point() +
facet_grid(iris$Species ~ .) +
annotate("text", x = 7, y = 4, label = "foo")
Error in '$<-.data.frame'('*tmp*', "PANEL", value = c(1L, 1L, 1L, 1L, :
replacement has 150 rows, data has 1
ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
geom_point() +
facet_grid(Species ~ .) +
annotate("text", x = 7, y = 4, label = "foo")
No error:

plot group and category means with group_by

I am new to R and trying to figure out a way to plot means for individual samples as well as group means with ggplot.
I am following this articles on R-bloggers (last paragraph):
https://www.r-bloggers.com/plotting-individual-observations-and-group-means-with-ggplot2/
This is my code:
gd <- meanplot1 %>%
group_by(treatment, value) %>%
summarise(measurement = mean(measurement))
ggplot(meanplot1, aes(x=value, y=measurement, color=treatment)) +
geom_line(aes(group=sample), alpha=0.3) +
geom_line(data=gd, size=3, alpha=0.9) +
theme_bw()
Whilst the sample means are being shown, the group means arenĀ“t. I get the error
geom_path: Each group consists of only one observation. Do you need
to adjust the group aesthetic?
Upon adding group=1, I get a weirdly mixed category mean, but not what I am looking for..
I scrolled through a lot of articles already, but couldnt find an answer - I would be so happy if somebody could help me out here!! :)
My data (meanplot1) is formatted like this:
treatment sample value measurement
1 control, control 1, initial, 20,
2 control, control 1, 26, NA,
3 control, control 1, 26', 28,
12 control, control 2, initial, 22,
13 control control 2, 26, NA,
14 control control 2, 26', 36,
15 control control 2, 28, 45,
67 stressed, stress 1, initial, 37,
68 stressed, stress 1, 26, NA,
69 stressed, stress 1, 26', 17,
78 stressed, stress 2, initial, 36,
79 stressed, stress 2, 26, NA,
80 stressed, stress 2, 26', 25,
I am hoping to see 6 lines, one mean for stress 1, stress 2, control 1 and control 2, and one mean for all treatment=control, and one for all treatment=stressed
output dput(gd):
structure(list(treatment = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L
), .Label = c("control", "stressed"), class = "factor"), value = structure(c(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L), .Label = c("26", "26'", "28", "28'",
"30", "30'", "32", "32'", "34", "34'", "initial"), class = "factor"),
measurement = c(NA, 32.3333333333333, 39.5, 30.3333333333333,
31.8333333333333, 31.8333333333333, NA, 36, 34.6666666666667,
36, 24.6666666666667, NA, 25.3333333333333, 33.3333333333333,
32, 50.1666666666667, 39.1666666666667, NA, 33.5, 24.3333333333333,
27.3333333333333, 36)), class = c("grouped_df", "tbl_df",
"tbl", "data.frame"), row.names = c(NA, -22L), vars = list(treatment), drop = TRUE, .Names = c("treatment",
"value", "measurement"))
output dput(meanplot1):
structure(list(treatment = 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, 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), .Label = c("control",
"stressed"), class = "factor"), sample = structure(c(1L, 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, 3L, 4L,
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, 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), .Label = c("control 1",
"control 2", "control 3", "control 4", "control 5", "control 6",
"stress 1", "stress 2", "stress 3", "stress 4", "stress 5", "stress 6"
), class = "factor"), value = structure(c(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, 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), .Label = c("26", "26'",
"28", "28'", "30", "30'", "32", "32'", "34", "34'", "initial"
), class = "factor"), measurement = c(20L, NA, 28L, 18L, 17L,
19L, 34L, NA, 23L, 29L, 27L, 22L, NA, 36L, 45L, 31L, 40L, 44L,
NA, 49L, 40L, 39L, 32L, NA, 35L, 57L, 30L, 37L, 29L, NA, 44L,
37L, 46L, 20L, NA, 39L, 27L, 30L, 40L, 25L, NA, 29L, 50L, 30L,
26L, NA, 28L, 45L, 47L, 27L, 35L, NA, 24L, 22L, 35L, 28L, NA,
28L, 45L, 27L, 28L, 24L, NA, 47L, 30L, 39L, 37L, NA, 17L, 29L,
29L, 31L, 29L, NA, 37L, 21L, 27L, 36L, NA, 25L, 41L, 51L, 66L,
50L, NA, 33L, 25L, 22L, 36L, NA, 33L, 45L, 26L, 72L, 59L, NA,
33L, 26L, 25L, 33L, NA, 21L, 33L, 25L, 29L, 21L, NA, 26L, 20L,
16L, 22L, NA, 30L, 27L, 28L, 57L, 41L, NA, 28L, 23L, 17L, 52L,
NA, 26L, 25L, 33L, 46L, 35L, NA, 44L, 31L, 57L)), .Names = c("treatment",
"sample", "value", "measurement"), class = "data.frame", row.names = c(NA,
-132L))
I suppose you are aiming to plot the treatment means.
By default, since you are using a categorical x-axis, the grouping is set to the interaction between x and color. You only want to group by treatment, however. So we'll add the correct grouping to the call.
ggplot(meanplot1, aes(x = value, y = measurement, color=treatment)) +
geom_line(aes(group=sample), alpha=0.3) +
geom_line(aes(group = treatment), gd, size=3, alpha=0.9) +
theme_bw()
Also note that
ggplot(meanplot1, aes(x=value, y=measurement, color=treatment)) +
geom_line(aes(group=sample), alpha=0.3) +
stat_summary(aes(group = treatment), fun.y = mean, geom = 'line', size=3, alpha=0.9) +
theme_bw()
Gives the same plot, without the interruption.

[r]: Interpreting results of a glmer, retransforming estimates

EDIT:
I am currently writing my master thesis on the effect of a certain insecticide on bumble bee colonies. I was for example checking if damaged/diseased appearing bees were more prevalent in colonies that were exposed to the insecticide compared to the control.
The study design is hierarchical. 16 fields were paired according to landscape characteristics. In each pair one field was randomly assigned to be treated with the insecticide, while the other is the control field. In each field there are 2 boxes and in each box are 2 bumble bee hives. From each hive I have up to ten pupae per sex.
This is how my data looks like:
structure(list(pair = 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, 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,
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,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, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 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, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 16L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 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, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 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, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L), .Label = c("VR02", "VR03",
"VR04", "VR05", "VR06", "VR07", "VR09", "VR12", "VR13", "VR14",
"VR16", "VR17", "VR18", "VR20", "VR21", "VR23"), class = "factor"),
treatment = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 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, 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, 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, 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, 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,
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, 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), .Label = c("Clothianidin", "Control"), class = "factor"),
box.nested = c(11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24,
24, 24, 24, 24, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3,
3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 19, 19, 19, 19, 19, 19,
19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
26, 26, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14,
31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 15, 15, 15, 15, 15, 16, 16, 16, 18, 18, 18,
18, 18, 18, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18,
5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
22, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10,
10, 10, 10, 10, 10, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 30, 30, 30, 30, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30,
30, 30, 30, 30, 30, 30, 30, 30, 30), hive.nested = c(21L,
21L, 21L, 21L, 21L, 22L, 22L, 22L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 45L, 45L,
45L, 45L, 45L, 45L, 45L, 45L, 45L, 45L, 45L, 46L, 46L, 48L,
48L, 48L, 48L, 48L, 48L, 48L, 48L, 48L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 3L, 3L, 4L, 4L, 4L, 6L, 6L, 6L, 6L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 37L, 37L, 37L, 37L, 38L, 38L, 38L,
38L, 38L, 39L, 39L, 39L, 39L, 39L, 39L, 39L, 40L, 40L, 40L,
40L, 40L, 40L, 40L, 49L, 49L, 49L, 49L, 49L, 49L, 49L, 49L,
49L, 49L, 49L, 50L, 50L, 51L, 52L, 25L, 25L, 25L, 26L, 26L,
26L, 27L, 27L, 27L, 27L, 28L, 28L, 28L, 61L, 61L, 61L, 61L,
61L, 62L, 62L, 62L, 62L, 64L, 64L, 64L, 64L, 64L, 64L, 64L,
64L, 64L, 64L, 30L, 30L, 30L, 30L, 30L, 32L, 32L, 32L, 36L,
36L, 36L, 36L, 36L, 36L, 34L, 34L, 34L, 34L, 34L, 34L, 34L,
34L, 35L, 35L, 35L, 36L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 41L, 41L,
41L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 43L, 43L,
43L, 43L, 43L, 43L, 44L, 44L, 44L, 44L, 44L, 13L, 14L, 14L,
14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 16L, 16L, 16L, 16L, 16L, 16L, 14L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 19L, 20L, 20L, 20L, 20L, 17L, 17L, 17L, 17L,
17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 19L,
19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L, 53L, 53L, 53L, 53L,
54L, 54L, 54L, 54L, 55L, 55L, 55L, 55L, 55L, 55L, 55L, 56L,
56L, 56L, 60L, 60L, 60L, 60L, 57L, 57L, 57L, 57L, 57L, 57L,
57L, 58L, 58L, 58L, 58L, 58L, 58L, 59L, 59L, 59L, 59L, 59L,
59L, 59L, 59L, 60L, 60L, 60L, 60L, 60L, 60L), stage = structure(c(2L,
1L, 1L, 3L, 1L, 1L, 1L, 1L, 2L, 3L, 2L, 2L, 3L, 2L, 2L, 2L,
1L, 3L, 1L, 2L, 3L, 2L, 1L, 3L, 2L, 2L, 1L, 2L, 3L, 2L, 1L,
3L, 2L, 3L, 1L, 1L, 2L, 3L, 1L, 3L, 3L,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,
1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1,
0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0,
0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1,
1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0)), .Names = c("pair",
"field", "treatment", "box.nested", "hive.nested", "stage", "condition",
"sex", "diseased"), class = "data.frame", row.names = c(5L, 7L,
8L, 9L, 10L, 14L, 15L, 16L, 21L, 23L, 24L, 26L, 28L, 29L, 30L,
31L, 32L, 33L, 34L, 37L, 38L, 39L, 40L, 42L, 45L, 47L, 48L, 49L,
50L, 51L, 52L, 53L, 54L, 55L, 58L, 60L, 66L, 67L, 68L, 72L, 73L,
74L, 77L, 83L, 85L, 87L, 90L, 92L, 95L, 97L, 100L, 104L, 108L,
115L, 117L, 123L, 125L, 133L, 134L, 137L, 144L, 155L, 156L, 157L,
158L, 159L, 160L, 161L, 162L, 163L, 164L, 166L, 169L, 170L, 172L,
175L, 178L, 179L, 180L, 184L, 185L, 189L, 190L, 191L, 192L, 193L,
194L, 195L, 196L, 197L, 199L, 201L, 202L, 203L, 205L, 206L, 207L,
211L, 212L, 213L, 215L, 217L, 221L, 222L, 224L, 226L, 230L, 244L,
247L, 255L, 258L, 262L, 271L, 272L, 274L, 280L, 281L, 284L, 285L,
288L, 289L, 295L, 296L, 297L, 299L, 300L, 305L, 308L, 309L, 312L,
314L, 326L, 327L, 328L, 329L, 330L, 331L, 332L, 333L, 334L, 335L,
356L, 359L, 362L, 364L, 366L, 375L, 378L, 381L, 388L, 389L, 390L,
391L, 392L, 393L, 404L, 405L, 406L, 407L, 408L, 409L, 410L, 412L,
417L, 418L, 420L, 424L, 425L, 426L, 427L, 428L, 429L, 430L, 431L,
432L, 433L, 435L, 436L, 438L, 439L, 440L, 441L, 442L, 443L, 444L,
446L, 447L, 450L, 453L, 454L, 455L, 456L, 458L, 459L, 461L, 462L,
465L, 466L, 468L, 475L, 476L, 477L, 478L, 479L, 480L, 481L, 482L,
483L, 484L, 485L, 486L, 487L, 490L, 491L, 494L, 495L, 496L, 500L,
501L, 508L, 518L, 519L, 521L, 522L, 524L, 525L, 526L, 527L, 528L,
529L, 530L, 531L, 532L, 533L, 534L, 535L, 538L, 540L, 542L, 543L,
544L, 548L, 549L, 551L, 552L, 553L, 554L, 555L, 556L, 557L, 559L,
560L, 563L, 568L, 569L, 571L, 572L, 576L, 577L, 578L, 579L, 580L,
581L, 582L, 583L, 584L, 585L, 587L, 588L, 590L, 594L, 595L, 596L,
600L, 603L, 604L, 605L, 606L, 607L, 608L, 609L, 616L, 618L, 620L,
622L, 626L, 628L, 631L, 632L, 635L, 636L, 638L, 639L, 641L, 646L,
647L, 651L, 652L, 653L, 654L, 655L, 656L, 658L, 659L, 660L, 661L,
663L, 666L, 667L, 668L, 669L, 670L, 673L, 675L, 676L, 678L, 679L,
680L, 681L, 682L, 684L, 685L, 686L, 687L, 688L, 689L, 690L))
I have run binomial glmer models from the lme4 package to test whether the presence of disease/damage signs in bumble bee colonies is affected by the insecticide.
damage.prev <- glmer(diseased ~ treatment + sex + stage
+ (1|pair/field/box.nested/hive.nested)
,data=df.cocoons.white,
family=binomial)
I have been trying to get estimates and confidence intervals. Thanks to #Benjamin
I got a little closer to the solution, but the estimates sill seem too high.
That's how I tried to get a data.frame of CIs and estimates:
fixed <- fixef(damage.prev)
wald <-confint(damage.prev,method="Wald")
estCloth.damage.ratio <- exp(fixed[1])
estCont.damage.ratio <- exp(fixed[1] + fixed[2])
lwrCloth.damage.ratio <- exp(wald[1,1])
lwrCont.damage.ratio <- exp(wald[1,1] + wald[2,1])
uprCloth.damage.ratio <- exp(wald[1,2])
uprCont.damage.ratio <- exp(wald[1,2] + wald[2,2])
estCloth.damage <- estCloth.damage.ratio/ (1+estCloth.damage.ratio)
estCont.damage <- estCont.damage.ratio / (1+ estCont.damage.ratio)
lwrCloth.damage <- lwrCloth.damage.ratio/ (1+ lwrCloth.damage.ratio)
lwrCont.damage <- lwrCont.damage.ratio /(1+ lwrCont.damage.ratio)
uprCloth.damage <- uprCloth.damage.ratio /(1+uprCloth.damage.ratio)
uprCont.damage <- uprCont.damage.ratio /(1+uprCont.damage.ratio )
treat.damage <- data.frame(Treatment,Estimate,lwr,upr)
What still confuses me are the high estimates of beyond 94%, yet
sum(df.cocoons.white$diseased)/length(df.cocoons.white$diseased)
gives me less than 70%. Doesn't seem realistic. Any idea what might be wrong?
Your model is using a logit transformation.
The way I look at generalized linear models is that they really aren't any different than simple linear regression. In simple linear regression, your response variable is continuous on (theoretically) the entire real number line (-Inf, Inf).
In logistic regression, your response is a proportion, which is continuous on the interval [0, 1]. The odds calculates (p / (1-p)) which is continuous over the interval of [0, inf). The log odds log(p / (1-p)) is continuous over the interval (-Inf, Inf).
This complete transformation (log(p / (1-p))) is referred to as the logit transformation and is pretty standard in logistic regression.
The results of your glmer model, which is a random effects version of logistic regression, uses the same transformation and so the estimated coefficients are on the scale of (-Inf, Inf). If you want odds ratios, you can exponentiate the coefficients, which will give you the odds measured on a scale of (0, Inf), with 1.0 being the null value.

Resources