How to create a categorical scattering diagram in R, for example, boxes?

Does anyone know how to create a scatter chart in Rorder to create graphs such as these in the PRISM graphics screen:

enter image description here

I tried using boxplots, but they do not display the data the way I want. These bar graph scatter graphs can generate show me better data.

Any suggestions would be appreciated.

+5
source share
2 answers

As @smillig mentioned, you can achieve this using ggplot2. The code below reproduces the plot, which you then pretty well warn that is pretty complicated. First download the ggplot2 package and create some data:

library(ggplot2)
dd = data.frame(values=runif(21), type = c("Control", "Treated", "Treated + A"))

:

theme_set(theme_bw())

.

  • - :

    g = ggplot(dd, aes(type, values))
    
  • : :

    g = g + geom_jitter(aes(pch=type), position=position_jitter(width=0.1))
    
  • ":" , . . , .

    g = g + stat_summary(fun.y = function(i) mean(i), 
            geom="bar", fill="white", colour="black")
    
  • : / :

    g  = g + stat_summary(
            fun.ymax=function(i) mean(i) + qt(0.975, length(i))*sd(i)/length(i), 
            fun.ymin=function(i) mean(i) - qt(0.975, length(i)) *sd(i)/length(i),
            geom="errorbar", width=0.2)
    
  • g
    

enter image description here

  • R- stat_summary , . geom_errorbar geom_bar.
  • R, question.
+4

ggplot2, geom_boxplot geom_jitter. mtcars:

library(ggplot2)
p <- ggplot(mtcars, aes(factor(cyl), mpg)) 
p + geom_boxplot() + geom_jitter() + theme_bw()

:

enter image description here

: http://had.co.nz/ggplot2/geom_boxplot.html

+3

All Articles