[R] Probably dumb question about lists
Boris Steipe
boris.steipe at utoronto.ca
Wed Jan 14 16:34:52 CET 2015
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.
More information about the R-help
mailing list