m@dsmh m@iii@g oii gm@ii@com
2021-Aug-18 14:29 UTC
[R] [External] Package for "design graphs"
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 at r-project.org> on behalf of > madsmh at gmail.com <madsmh at gmail.com> > Sent: Tuesday, August 17, 2021 16:02 > To: r-help at 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 at 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%7C00a59081bd66463e433d08d961b9e105%7C716e81efb52244738e3110bd02ccf6e5%7C0%7C0%7C637648273248735184%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=dNwMcJa6okIxlK97dprkVkCk4g5mn6hYsBr1Hez7m%2F8%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%7C00a59081bd66463e433d08d961b9e105%7C716e81efb52244738e3110bd02ccf6e5%7C0%7C0%7C637648273248745142%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=YZlqRVki%2FaQMdaGQgddyLLmAH3bCsnhPTuhlnrSb1PE%3D&reserved=0 > and provide commented, minimal, self-contained, reproducible code.
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. Rich expt1 <- data.frame(from=c(1,1,2,2,3,3,4,4), to=c("A","B","A","B","C","D","C","D")) expt2 <- data.frame(from=c(1,1,2,2,3,3,4,4), to=c("A","B","B","C","C","D","D","A")) 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)) } DesignGraph(expt1) DesignGraph(expt2)> On Aug 18, 2021, at 10:29, madsmh at 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 at r-project.org> on behalf of >> madsmh at gmail.com <madsmh at gmail.com> >> Sent: Tuesday, August 17, 2021 16:02 >> To: r-help at 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 at 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>
The only person who got the image was Richard. The rest of us got the posting from the list server which stripped you image. If it had been a pdf or png I think it might have survived the digital journey rather than being blown to bits. On 8/18/21 7:29 AM, madsmh at 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 at r-project.org> on behalf of >> madsmh at gmail.com <madsmh at gmail.com> >> Sent: Tuesday, August 17, 2021 16:02 >> To: r-help at 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 at 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%7C00a59081bd66463e433d08d961b9e105%7C716e81efb52244738e3110bd02ccf6e5%7C0%7C0%7C637648273248735184%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=dNwMcJa6okIxlK97dprkVkCk4g5mn6hYsBr1Hez7m%2F8%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%7C00a59081bd66463e433d08d961b9e105%7C716e81efb52244738e3110bd02ccf6e5%7C0%7C0%7C637648273248745142%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=YZlqRVki%2FaQMdaGQgddyLLmAH3bCsnhPTuhlnrSb1PE%3D&reserved=0 >> and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.