Re: [Rd] Making iconv portable?

2014-12-16 Thread Martin Maechler
> Kurt Hornik 
> on Mon, 15 Dec 2014 18:21:19 +0100 writes:

> Spencer Graves writes:
>> Hello, All: What would it take to make “iconv” portable?


>> I ask, because I want to convert accented characters to
>> vanilla ASCII, thereby converting, e.g., ‘Raúl’ to
>> “Raul”, and Milan Bouchet-Valet suggested on R-help that
>> I use 'iconv(x, “", "ASCII//TRANSLIT”)’.  This worked
>> under Windows but failed on Linux and Mac.  It’s part of
>> the “subNonStandardCharacters” function in the Ecfun
>> package. The development version on R-Forge uses this and
>> returns “Raul” under Windows and NA under Mac OS X (and
>> presumably also Linux).

> Hmm.

R> iconv("Raúl", "", "ASCII//TRANSLIT")
> [1] "Raul"

> seems to work for me on Linux ...

and me:

> iconv("Martin Mächler, Zürich.  ¡España, Olé!", "", "ASCII//TRANSLIT")
[1] "Martin Maechler, Zuerich.  ?Espana, Ole!"


>> The “iconv” R code merely calls compiled code, which I’ve
>> used very little in 30 years.


>> Thanks, Spencer



>>> On Nov 30, 2014, at 2:32 AM, Spencer Graves
>>> >> > wrote:
>>> 
>>> Wonderful.  Thanks very much.  Spencer
>>> 
>>> 
>>> On 11/30/2014 2:25 AM, Milan Bouchet-Valat wrote:

>> [[alternative HTML version deleted]]

>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel

> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] vapply definition question

2014-12-16 Thread Mick Jordan

vapply <- function(X, FUN, FUN.VALUE, ...,  USE.NAMES = TRUE)
{
FUN <- match.fun(FUN)
if(!is.vector(X) || is.object(X)) X <- as.list(X)
.Internal(vapply(X, FUN, FUN.VALUE, USE.NAMES))
}

This is an implementor question. Basically, what happened to the '...' 
args in the call to the .Internal? cf lapply:, where the ... is passed.


lapply <- function (X, FUN, ...)
{
FUN <- match.fun(FUN)
## internal code handles all vector types, including expressions
## However, it would be OK to have attributes which is.vector
## disallows.
if(!is.vector(X) || is.object(X)) X <- as.list(X)
##TODO
## Note ... is not passed down.  Rather the internal code
## evaluates FUN(X[i], ...) in the frame of this function
.Internal(lapply(X, FUN, ...))
}

Now both of these functions work when extra arguments are passed, so 
evidently the implementation can function whether the .Internal "call" 
contains the ... or not. I found other cases, notably in S3 generic 
methods where the ... is not passed down.


So, essentially, my question is whether the vapply code "should" be 
changed or whether a .Internal implementation should always assume an 
implicit ... regardless of the code, if the semantics requires it.


Thanks
Mick

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] vapply definition question

2014-12-16 Thread Martin Morgan

On 12/16/2014 08:20 PM, Mick Jordan wrote:

vapply <- function(X, FUN, FUN.VALUE, ...,  USE.NAMES = TRUE)
{
 FUN <- match.fun(FUN)
 if(!is.vector(X) || is.object(X)) X <- as.list(X)
 .Internal(vapply(X, FUN, FUN.VALUE, USE.NAMES))
}

This is an implementor question. Basically, what happened to the '...' args in
the call to the .Internal? cf lapply:, where the ... is passed.

lapply <- function (X, FUN, ...)
{
 FUN <- match.fun(FUN)
 ## internal code handles all vector types, including expressions
 ## However, it would be OK to have attributes which is.vector
 ## disallows.
 if(!is.vector(X) || is.object(X)) X <- as.list(X)
 ##TODO
 ## Note ... is not passed down.  Rather the internal code
 ## evaluates FUN(X[i], ...) in the frame of this function
 .Internal(lapply(X, FUN, ...))
}

Now both of these functions work when extra arguments are passed, so evidently
the implementation can function whether the .Internal "call" contains the ... or
not. I found other cases, notably in S3 generic methods where the ... is not
passed down.


Hi Mick --

You can see that the source code doesn't contain '...' in the final line

~/src/R-devel/src/library/base/R$ svn annotate lapply.R | grep Internal\(l
 38631 ripley .Internal(lapply(X, FUN))

and that it's been there for a long time (I'd guess 'forever')

~/src/R-devel/src/library/base/R$ svn log -r38631

r38631 | ripley | 2006-07-17 14:30:55 -0700 (Mon, 17 Jul 2006) | 2 lines

another attempt at a faster lapply



so I guess you're looking at a modified version of the function... The 
implementation detail is in the comment -- FUN(X[i], ...) is evaluated in the 
frame of lapply.


Martin Morgan



So, essentially, my question is whether the vapply code "should" be changed or
whether a .Internal implementation should always assume an implicit ...
regardless of the code, if the semantics requires it.

Thanks
Mick

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel



--
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel