2017-12-15 23 views
-1

gagplot2の5つのtransectsの値の複数のエラーバー(平均と標準偏差)をプロットしたいとします。私は試しましたが、適切な戦略を見つけられませんでした。値、トランセクトと種の サンプル・コードは、次が含まれます。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 

答えて

0

をここで同じプロット上のそれらすべてを持つ例です。良いものは?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') 

になり geompositionで遊んします
関連する問題