[Rd] \dots used improperly in ?Rprof examples

2019-05-25 Thread Michael Chirico
\dots is used in the Usage section of the Rprof manual, but it's not
rendered as ...

I'm not sure if this should be \ldots, or just written manually with ...

Also, I think the Rprof() on the first line is intended to be on the second
line? So that the flow looks like

Rprof() # start profiling
## some code to be profiled
Rprof(NULL) # shut off profiling
## some code NOT to be profiled
Rprof(append = TRUE) # turn profiling back on and append output to current
file
## some code to be profiled
Rprof(NULL)
## ... et cetera
## Now post-process the output as described in Details

As it is the first line looks like it's commented out

Michael Chirico

[[alternative HTML version deleted]]

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


Re: [Rd] writing Unicode text to the Windows clipboard

2019-05-25 Thread Jeroen Ooms
On Fri, May 24, 2019 at 12:06 AM Jennifer Bryan  wrote:
>
> Hello,
>
> I'm interested in moving text from and to the clipboard that cannot
> necessarily be represented in the native encoding. So, really, this is
> about Windows.
>
> I can successfully read from the clipboard by specifying the format that
> corresponds to unicode text.
>
> From R >=2.7.0, it seems you should also be able to write unicode text
> to the Windows clipboard.
>
> https://github.com/wch/r-source/blob/5a156a0865362bb8381dcd69ac335f5174a4f60c/src/gnuwin32/CHANGES0#L535-L536

Thanks!

I tested this and can confirm that this patch works. With this change,
any (non ascii) unicode text now properly copies and pastes from/to
the Windows clipboard.

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


[Rd] rbind has confusing result for custom sub-class (possible bug?)

2019-05-25 Thread Michael Chirico
Debugging this issue:

https://github.com/Rdatatable/data.table/issues/2008

We have custom class 'IDate' which inherits from 'Date' (it just forces
integer storage for efficiency, hence, I).

The concatenation done by rbind, however, breaks this and returns a double:

library(data.table)
DF = data.frame(date = as.IDate(Sys.Date()))
storage.mode(rbind(DF, DF)$date)
# [1] "double"

This is specific to base::rbind (data.table's rbind returns an integer as
expected); in ?rbind we see:

The method dispatching is not done via UseMethod(), but by C-internal
dispatching. Therefore there is no need for, e.g., rbind.default.
The dispatch algorithm is described in the source file
(ā€˜.../src/main/bind.c’) as
1. For each argument we get the list of possible class memberships from the
class attribute.
2. *We inspect each class in turn to see if there is an applicable method.*
3. If we find an applicable method we make sure that it is identical to any
method determined for prior arguments. If it is identical, we proceed,
otherwise we immediately drop through to the default code.

It's not clear what #2 means -- an applicable method *for what*? Glancing
at the source code would suggest it's looking for rbind.IDate:

https://github.com/wch/r-source/blob/trunk/src/main/bind.c#L1051-L1063

const char *generic = ((PRIMVAL(op) == 1) ? "cbind" : "rbind"); // should
be rbind here
const char *s = translateChar(STRING_ELT(classlist, i)); // iterating over
the classes, should get to IDate first
sprintf(buf, "%s.%s", generic, s); // should be rbind.IDate

but adding this method (or even exporting it) is no help [ simply defining
rbind.IDate = function(...) as.IDate(NextMethod()) ]

Lastly, it appears that as.Date.IDate is called, which is causing the type
conversion:

debug(data.table:::as.Date.IDate)
rbind(DF, DF) # launches debugger
x
# [1] "2019-05-26" <-- singleton, so apparently applied to DF$date, not
c(DF$date, DF$date)
undebug(data.table:::as.Date.IDate)

I can't really wrap my head around why as.Date is being called here, and
even allowing that, why the end result is still the original class [
class(rbind(DF, DF)$date) == c('IDate', 'Date') ]

So, I'm beginning to think this might be a bug. Am I missing something?

[[alternative HTML version deleted]]

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