Thanks Uwe! And Peter for the correction. I would never have come up with that!
Tim Tim Clark Department of Zoology University of Hawaii --- On Fri, 2/12/10, Uwe Ligges <lig...@statistik.tu-dortmund.de> wrote: > From: Uwe Ligges <lig...@statistik.tu-dortmund.de> > Subject: Re: [R] Formatting question for separate polygons > To: "Peter Ehlers" <ehl...@ucalgary.ca> > Cc: "Tim Clark" <mudiver1...@yahoo.com>, r-help@r-project.org > Date: Friday, February 12, 2010, 1:57 AM > > > On 12.02.2010 12:54, Peter Ehlers wrote: > > Nice, Uwe. > > Small correction: make that nrow=4: > > > > x1 <- as.numeric(rbind(matrix(rep(x, each=2), > nrow=4), NA)) > > > > Whoops, thanks! > > Uwe > > > > -Peter Ehlers > > > > Uwe Ligges wrote: > >> > >> > >> On 11.02.2010 22:38, Tim Clark wrote: > >>> Dear List, > >>> > >>> I am trying to plot several separate polygons > on a graph. I have > >>> figured out how to do it by manually, but have > too much data to use > >>> such a tedious method. I would appreciate your > help. I have made a > >>> simple example to illustrate the problem. How > can I get x into the > >>> proper format (x1)? > >>> > >>> #Sample data > >>> x<-c(1,2,3,4,5,6) > >>> y<-c(1,2,2,1) > >>> > >>> #I need to format the data like this > >>> x1<-c(1,1,2,2,NA,3,3,4,4,NA,5,5,6,6,NA) > >>> y1<-rep(c(1,2,2,1,NA),length(x)/2) > >> > >> > >> > >> x1 <- as.numeric(rbind(matrix(rep(x, each=2), > nrow=2), NA)) > >> > >> Uwe Ligges > >> > >> > >>> #Final plot > >>> plot(c(1,6), 1:2, type="n") > >>> polygon(x1,y1,density=c(40)) > >>> > >>> > >>> Thanks, > >>> > >>> Tim > >>> > >>> > >>> Tim Clark > >>> Department of Zoology > >>> University of Hawaii > >>> > >>> > ______________________________________________ > >>> R-help@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. > >> > >> ______________________________________________ > >> R-help@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. > >> > >> > > > ______________________________________________ R-help@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.