From wdunlap at tibco.com  Mon Mar 30 22:50:35 2015
From: wdunlap at tibco.com (William Dunlap)
Date: Mon, 30 Mar 2015 13:50:35 -0700
Subject: [Rd] Segfault with match()
In-Reply-To: <CABdHhvGoW+p0Rw3Oeg7bWdi-XsXAv-XAbS-Q9rv90StXAtnXKw@mail.gmail.com>
References: <CABdHhvGoW+p0Rw3Oeg7bWdi-XsXAv-XAbS-Q9rv90StXAtnXKw@mail.gmail.com>
Message-ID: <CAF8bMcaO+_La_wU1s7uFpMo2atfxDrcLogWvsHz7HaO8JfESGw@mail.gmail.com>

Did you leave out the warning from "+", which should be an error,
as it produces an illegal ordered factor in this case and factor+factor
is nonsensical?  Or is the warning missing in the current development
version of R?

> x <- factor("A", ordered=FALSE) + factor(c("B","C"), ordered=TRUE)
Warning message:
Incompatible methods ("Ops.factor", "Ops.ordered") for "+"
> str(x) # 2 levels, so integer codes of 3 is illegal
ordered[1:2] w/ 2 levels B<C:  2 3


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Mar 30, 2015 at 1:10 PM, Hadley Wickham <h.wickham at gmail.com> wrote:

> This is admittedly a contrived example, but...
>
> data(housing, package ="MASS")
> x <- housing$Type + housing$Sat
> match(x, unique(x))
>
> Hadley
>
> --
> http://had.co.nz/
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

	[[alternative HTML version deleted]]



[Rd] Segfault with match()
William Dunlap