[R] dotcharts next to boxplots

David Carlson dcarlson at tamu.edu
Mon May 13 19:33:26 CEST 2013


Use dput() to send data to r-help:

dput(Daten)
structure(list(Dosis = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 
1L, 1L), weight = c(6.62, 6.65, 5.78, 5.63, 6.05, 6.48, 5.5, 
5.37, 6.25, 6.95, 5.61), sex = structure(c(1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L), .Label = "m", class = "factor")), .Names =
c("Dosis", 
"weight", "sex"), class = "data.frame", row.names = c("1", "2", 
"3", "4", "5", "6", "7", "8", "9", "10", "11"))

You are very close, but the formula version of points will not allow you to
modify the result of interaction() so you need to switch to the x, y
version:

boxplot( Daten$weight~interaction(Daten$Dosis,Daten$sex, drop=TRUE))
points( as.numeric(interaction(Daten$Dosis, Daten$sex, 
   drop=TRUE))+.5, Daten$weight)

Will put the dotcharts beside the boxplots().

-------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77840-4352





-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of maggy yan
Sent: Monday, May 13, 2013 11:38 AM
To: R-help at r-project.org
Subject: [R] dotcharts next to boxplots

my dataset looks like this in the beginning:

   Dosis weight sex
1      0    6.62          m
2      0    6.65          m
3      0    5.78          m
4      0    5.63          m
5      0    6.05          m
6      0    6.48          m
7      0    5.50          m
8      0    5.37          m
9      1    6.25          m
10     1    6.95          m
11     1    5.61          m

I've got all the box plots:
boxplot( Daten$weight~interaction(Daten$Dosis,Daten$sex, drop=TRUE)

and the points:
points(Daten$weight~interaction(Daten$Dosis,Daten$sex, drop=TRUE))

but the points are overlapping their box plots, so I tried to move all the
points next to the box plots with this:
> points( Daten$weight~interaction(Daten$Dosis,Daten$sex, drop=TRUE) + 
> 0.2)
 but it did not work, is there any other way for this?

	[[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list