[R] [External] Package for "design graphs"

Richard M. Heiberger rmh @end|ng |rom temp|e@edu
Thu Aug 19 02:22:35 CEST 2021

Thank you for the example.

Here is a simple function in base graphics that does what you ask for.

You can turn off the default borders and ticks and tick labels and xlab and ylab,
and add your own x tick labels, and then it will look exactly like the example you sent.


expt1 <- data.frame(from=c(1,1,2,2,3,3,4,4),

expt2 <-  data.frame(from=c(1,1,2,2,3,3,4,4),

DesignGraph <- function(x, pch.from=19, pch.to=19) {
  from <- unique(x$from)
  to <- unique(x$to)

  n.from <- length(from)
  n.to <- length(to)
  Nrows<- max(1:n.from, 1:n.to)

  plot(1 ~ 1, type="n", xlim=c(1-.5, 2+.5), ylim=c(Nrows, 1))

  points(x=rep(1, n.from), y=1:n.from, pch=pch.from)
  text(x=1-.3, y=1:n.from, labels=from)

  points(x=rep(2, n.to), y=1:n.to, pch=pch.to)
  text(x=2+.3, y=1:n.to, labels=to)

  index.from <- which
  index.to <- which

  segments(1, match(x$from, from), 2, match(x$to, to))



> On Aug 18, 2021, at 10:29, madsmh using gmail.com wrote:
> I have attached a photo from our book 
> E. Hansen "Introduktion til matematisk statistik"
> the numbers represent the labels of one factor while the letters
> represent the labels of anothr factor.
> .. Mads
> On Tue, 2021-08-17 at 22:42 +0000, Richard M. Heiberger wrote:
>> can you post an example of the graph?
>> From: R-help <r-help-bounces using r-project.org> on behalf of 
>> madsmh using gmail.com <madsmh using gmail.com>
>> Sent: Tuesday, August 17, 2021 16:02
>> To: r-help using r-project.org
>> Subject: [External] [R] Package for "design graphs"
>> Hi,
>> in our course littrature a "design graph" of two factors R and S with
>> associated maps s : I -> S and f : I -> S where I is some finite
>> index
>> set, is a graph with factor labeles as vertices and lines f(i) to
>> s(i)
>> for all observations i in I. Is there a package on CRAN that can draw
>> graphs like this automatically?
>> I haven't been able to find anyting by searching.
>> Regards, Mads
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=04%7C01%7Crmh%40temple.edu%7Cf18619e1691a4333682a08d962549a74%7C716e81efb52244738e3110bd02ccf6e5%7C0%7C0%7C637648937938659341%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000&sdata=0LTywXuQ5Y%2FymuUTKOQeeozEx4MpAnF9QavJBcd4FNE%3D&reserved=0
>> PLEASE do read the posting guide 
>> https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html&data=04%7C01%7Crmh%40temple.edu%7Cf18619e1691a4333682a08d962549a74%7C716e81efb52244738e3110bd02ccf6e5%7C0%7C0%7C637648937938659341%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000&sdata=GT1zdL3%2BOAuVkXGGRMysbsfucmiIz6Dqozr6xyNbm8s%3D&reserved=0
>> and provide commented, minimal, self-contained, reproducible code.
> <IMG_0665.JPG>

More information about the R-help mailing list