From m@@nnell @ending from tibco@com  Fri Nov 16 00:13:03 2018
From: m@@nnell @ending from tibco@com (Michael Sannella)
Date: Thu, 15 Nov 2018 15:13:03 -0800
Subject: [Rd] STRING_IS_SORTED claims as.character(1:100) is sorted
Message-ID: <CAHPe-e_81PU8SyN9VNAimsC-PuWx3VYoVrKAyivg_bHe8cLbeg@mail.gmail.com>

If I have loaded the C code:
    SEXP altrep_STRING_IS_SORTED(SEXP x)
    {
        return ScalarInteger(STRING_IS_SORTED(x));
    }
and defined the function:
    issort <- function(x) .Call("altrep_STRING_IS_SORTED",x)

I am seeing the following results in R 3.5.1/Linux:
    > issort(LETTERS)
    [1] NA
    > issort(as.character(1:100))  ## should return NA
    [1] 1
    > issort(as.character(100:1))  ## should return NA
    [1] -1
    > issort(as.character(1:100+1L))
    [1] NA

issort(as.character(1:100)) should return NA, since the string vector
"1","2",..."10",... is not sorted.  I suspect that the problem is that
the Is_sorted method for deferred_string is just calling the Is_sorted
method for the source object 1:100 (which _is_ a sorted integer
vector).  It should probably just return NA for any source object.

  ~~ Michael Sannella

	[[alternative HTML version deleted]]



[Rd] STRING_IS_SORTED claims as.character(1:100) is sorted
Michael Sannella