Re: [R] regression line on boxplots

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Fri, 01 Apr 2011 11:42:02 -0400

On Apr 1, 2011, at 11:24 AM, Yan Jiao wrote:

> boxplot(c(1:3),c(4:6),c(5:8))

  df <- structure(list(grp = c(1, 1, 1, 2, 2, 2, 3, 3, 3, 3),    val = c(1L, 2L, 3L, 4L, 5L, 6L, 5L, 6L, 7L, 8L)),   .Names = c("grp", "val"),
  row.names = c(NA, -10L),
  class = "data.frame")

  boxplot(val~grp,data=df)
  lm(val~grp, data=df)

#Call:
#lm(formula = val ~ grp, data = df)

#Coefficients:
#(Intercept)          grp
#    0.04348      2.21739

  ?abline
  abline(reg=lm(val~grp, data=df) )

-- 

David Winsemius, MD
West Hartford, CT

______________________________________________
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.
Received on Fri 01 Apr 2011 - 15:45:45 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 01 Apr 2011 - 15:50:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive