2017-12-15 6 views
-1

Ich möchte einen multiplen Fehlerbalken (Mittelwert und Standardabweichung) von Wert von 5 Arten von 5 Transekten in ggplot2 plotten. Ich habe es versucht, aber ich habe keine passende Strategie gefunden. Beispielcode Wert transect und Arten umfasst folgende:Mehrere Balken (Mittelwert und Standardabweichung) in ggplot

value<-as.integer(runif(1000, min = 0, max = 5)) ## values of 1000 observations) 
    transect <- sample(1:5, 1000, replace=T) ## transect ID 
    x<-c("SpeciesA","SpeciesB","SpeciesC","SpeciesD","SpeciesE") 
    species<-rep(x, 200) 
    data<-data.frame(cbind(value,transect,species)) # species ID 

Antwort

0

Hier ist ein Beispiel mit ihnen allen auf dem gleichen Grundstück. Gute Dinge zu spielen, um mit wäre geom und position in ?stat_summary

value <- as.integer(runif(1000, min = 0, max = 5)) ## values of 1000 observations) 
transect <- sample(1:5, 1000, replace = TRUE) ## transect ID 
x <- c("SpeciesA", "SpeciesB", "SpeciesC", "SpeciesD", "SpeciesE") 
species <- rep(x, 200) 
data <- data.frame(cbind(value, transect, species)) # species ID 

library(ggplot2) 
ggplot(data, aes(species, value, colour = transect, group = transect)) + 
    stat_summary(fun.data = mean_se, geom = 'errorbar', position = 'dodge') 

Verwandte Themen