plot.tile.list() expects its argument to be of class tile.list, and to have an attribute "rw", both of which are not conserved after subsetting. You can do ... if (!require(deldir)) { install.packages("deldir") library(deldir) } x <- rnorm(10) y <- rnorm(10) del <- deldir(x, y) tl <- tile.list(del) tl2 <- tl[1:4] class(tl2) <- "tile.list" attr(tl2, "rw") <- attr(tl, "rw") plot.tile.list(tl2) # or just plot(tl2) BUT! This doesn't really make sense because you are just "randomly" plotting some tiles from the full triangulation, not plotting a triangulation with less points. That would be: plot(tile.list(deldir(x[1:4], y[1:4]))) Cheers, B. On Jan 14, 2015, at 10:13 AM, Bert Gunter <gunter.berton at gene.com> wrote:> 1. Please in future specify the package (deldir here) that contains > the functions you refer to. > > 2. **Always** first try ?str before posting queries like this, as this > will often reveal the problem. > > str(tl[1:800]) > > 3. I would **guess** (ergo could well be wrong) that "[" is not > preserving the class attribute of tl. Ergo you are getting the basic > plot method and not the plot.tile.list method. > > HTH. > > Cheers, > > Bert > > Bert Gunter > Genentech Nonclinical Biostatistics > (650) 467-7374 > > "Data is not information. Information is not knowledge. And knowledge > is certainly not wisdom." > Clifford Stoll > > > > > On Wed, Jan 14, 2015 at 6:23 AM, Raphael P?bst <raphael.paebst at gmail.com> wrote: >> Hello everybody! >> I feel very stupid right now but suspect it has something to do with >> tiredness. I am trying to drop the last couple of Elements from a list >> and this doesn't work as expected. >> >> My code looks something like this: >> >> del <- deldir(x, y) >> tl <- tile.list(del) >> plot(tl) >> >> Now, I only want to plot the first 800 elements of tl and can't work >> out how to do this. >> plot(tl[1:800]) >> gives me an error "x is a list but does not have components x and y" >> which somewhat baffles me. I'm sure this is all due to lack of sleep >> but right now I feel very dumb and would welcome any pointers towards >> a solution for my problem. >> >> Many thanks! >> >> Raphael >> >> ______________________________________________ >> 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. > > ______________________________________________ > 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.
Thanks Boris! I know that I am just leaving out some tiles in the plot, but I specifically want to drop those tiles for the plot and not calculate a tesselation without these points. So I'll go with this solution and hope it makes sense in the end. Thanks again! Raphael On 1/14/15, Boris Steipe <boris.steipe at utoronto.ca> wrote:> plot.tile.list() expects its argument to be of class tile.list, and to have > an attribute "rw", both of which are not conserved after subsetting. You can > do ... > > > if (!require(deldir)) { > install.packages("deldir") > library(deldir) > } > x <- rnorm(10) > y <- rnorm(10) > del <- deldir(x, y) > tl <- tile.list(del) > > tl2 <- tl[1:4] > class(tl2) <- "tile.list" > attr(tl2, "rw") <- attr(tl, "rw") > plot.tile.list(tl2) # or just plot(tl2) > > BUT! > This doesn't really make sense because you are just "randomly" plotting some > tiles from the full triangulation, not plotting a triangulation with less > points. That would be: > > plot(tile.list(deldir(x[1:4], y[1:4]))) > > Cheers, > B. > > > > > On Jan 14, 2015, at 10:13 AM, Bert Gunter <gunter.berton at gene.com> wrote: > >> 1. Please in future specify the package (deldir here) that contains >> the functions you refer to. >> >> 2. **Always** first try ?str before posting queries like this, as this >> will often reveal the problem. >> >> str(tl[1:800]) >> >> 3. I would **guess** (ergo could well be wrong) that "[" is not >> preserving the class attribute of tl. Ergo you are getting the basic >> plot method and not the plot.tile.list method. >> >> HTH. >> >> Cheers, >> >> Bert >> >> Bert Gunter >> Genentech Nonclinical Biostatistics >> (650) 467-7374 >> >> "Data is not information. Information is not knowledge. And knowledge >> is certainly not wisdom." >> Clifford Stoll >> >> >> >> >> On Wed, Jan 14, 2015 at 6:23 AM, Raphael P?bst <raphael.paebst at gmail.com> >> wrote: >>> Hello everybody! >>> I feel very stupid right now but suspect it has something to do with >>> tiredness. I am trying to drop the last couple of Elements from a list >>> and this doesn't work as expected. >>> >>> My code looks something like this: >>> >>> del <- deldir(x, y) >>> tl <- tile.list(del) >>> plot(tl) >>> >>> Now, I only want to plot the first 800 elements of tl and can't work >>> out how to do this. >>> plot(tl[1:800]) >>> gives me an error "x is a list but does not have components x and y" >>> which somewhat baffles me. I'm sure this is all due to lack of sleep >>> but right now I feel very dumb and would welcome any pointers towards >>> a solution for my problem. >>> >>> Many thanks! >>> >>> Raphael >>> >>> ______________________________________________ >>> 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. >> >> ______________________________________________ >> 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. > >
I will add a "[.tile.list" method in the next release of deldir so that the appropriate attributes are preserved. This won't happen for a month or so though; I have some other pressures on me at the moment. cheers, Rolf Turner On 15/01/15 04:52, Raphael P?bst wrote:> Thanks Boris! > I know that I am just leaving out some tiles in the plot, but I > specifically want to drop those tiles for the plot and not calculate a > tesselation without these points. So I'll go with this solution and > hope it makes sense in the end. > > Thanks again! > > Raphael > > On 1/14/15, Boris Steipe <boris.steipe at utoronto.ca> wrote: >> plot.tile.list() expects its argument to be of class tile.list, and to have >> an attribute "rw", both of which are not conserved after subsetting. You can >> do ... >> >> >> if (!require(deldir)) { >> install.packages("deldir") >> library(deldir) >> } >> x <- rnorm(10) >> y <- rnorm(10) >> del <- deldir(x, y) >> tl <- tile.list(del) >> >> tl2 <- tl[1:4] >> class(tl2) <- "tile.list" >> attr(tl2, "rw") <- attr(tl, "rw") >> plot.tile.list(tl2) # or just plot(tl2) >> >> BUT! >> This doesn't really make sense because you are just "randomly" plotting some >> tiles from the full triangulation, not plotting a triangulation with less >> points. That would be: >> >> plot(tile.list(deldir(x[1:4], y[1:4])))-- Rolf Turner Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 Home phone: +64-9-480-4619