Hi I have a problem with my geom_text. My code and plot looks like this:
library(tidyverse)
library(reprex)
setwd("C:/Users/mroet/Desktop/reprex")
#Datensätze einlesen ----
Loeffler <- read_delim("Loeffler_Gesamt1.CSV",";", escape_double = FALSE, trim_ws = TRUE)%>% #Unbearbeitete Tabelle einladen
gather(key = Kategorie, value = Anzahl, -Kolonie, -Nestnummer,-Nestteil, -Art, -Probe) #Den Datensatz Tidy machen
#> Warning: Duplicated column names deduplicated: 'Fischkisten' =>
#> 'Fischkisten_1' [86], 'Hummerreusen' => 'Hummerreusen_1' [102]
#> Parsed with column specification:
#> cols(
#> .default = col_double(),
#> Art = col_character(),
#> Kolonie = col_character(),
#> Nestteil = col_character()
#> )
#> See spec(...) for full column specifications.
kormoran <- read_delim("Kormoran_Gesamt1.CSV", ";", escape_double = FALSE, trim_ws = TRUE)%>% #Unbearbeitete Tabelle einladen
gather(key = Kategorie, value = Anzahl, -Nestnummer,-Nestteil, -Art) #Den Datensatz Tidy machen
#> Warning: Duplicated column names deduplicated: 'Fischkisten' =>
#> 'Fischkisten_1' [84], 'Hummerreusen' => 'Hummerreusen_1' [100]
#> Parsed with column specification:
#> cols(
#> .default = col_double(),
#> Art = col_character(),
#> Nestteil = col_character()
#> )
#> See spec(...) for full column specifications.
#Tabellen zusammenfügen ----
Gesamt <- bind_rows(Loeffler, kormoran, .id = NULL)
#Gesamtzahlen vergleichen ----
Vergleich <- Gesamt %>%
group_by(Art, Nestteil, Nestnummer)%>%
summarise(Anzahl = sum(Anzahl))%>%
ungroup(Nestnummer)%>%
group_by(Art, Nestteil)%>%
mutate( Stab = sd(Anzahl), count = n(), se = (Stab/(sqrt(count))))%>%
group_by(Stab, count, se, add=T)%>%
summarise(Gesamt = sum(Anzahl))
plot_vergleich <- ggplot(Vergleich, aes(x = Nestteil, y = Gesamt, fill = Nestteil))+
geom_bar(stat = 'identity', position = 'dodge')+
geom_errorbar(aes( ymin = Gesamt - se, ymax = Gesamt + se ), width = .4)+
geom_text(aes(label = Gesamt), size = 5, position = position_dodge(0.8), vjust = -0.9)+
geom_text(aes(x=3.3, y = 65), label = 'n = 123', size = 6)+
geom_text(x=3.3, y =535, label = 'n = 914', size = 6)+
scale_fill_brewer(name= 'Nestteil', palette = 'Greys')+
labs(x ='', y = expression('Gesamtnanzahl der gefundenen Müllteile'))+
facet_wrap(~Art, scales = 'free')+
theme(panel.background = element_rect(fill = NA),
panel.grid.major.y = element_line(color='grey', linetype = 20, size = 0.5),
axis.line.x = element_line(linetype = 'solid'),
axis.line.y = element_line(linetype = 'solid'),
strip.background = element_blank(),
strip.text = element_text(size = 12, face = 'bold'),
axis.text.x = element_text(size = 19, family = 'sans', colour = 'black'),
axis.title.y = element_text(size = 19, family = 'sans', colour = 'black'),
legend.text = element_text(size = 19,family = 'sans', colour = 'black'),
legend.title = element_text(size = 19,family = 'sans', colour = 'black'))
plot_vergleich
Created on 2019-06-20 by the reprex package (v0.3.0)
My problem is that I don't want the geom_text to appear on both sides. The "n=123" should only be at the left Grid and I don't know how to fix this. Is there an easy way to solve this problem? Thank you very much!