In R-ints section 1.5
https://cran.r-project.org/doc/manuals/r-devel/R-ints.html#Argument-evaluation
it states
> Note that being a special/builtin is separate from being primitive
> or .Internal: quote is a special primitive, + is a builtin primitive,
> cbind is a special .Internal and grep is a
If I call
.S4methods(sd)
I get the error
## Error in getGeneric(generic.function) :
## argument 'f' must be a string, generic function, or primitive:
got an ordinary function
By contrast, methods and .S3methods just state that no methods are found.
methods(sd)
## no methods found
S3methods(s
I seem to recall reading that for primitive generics, S3 will dispatch
on class first, then on mode. Unfortunately, I can't find the place
that I read this, and I don't trust my memory.
1) Is this correct? Or is it dispatch on class, then on typeof? Or
something else?
2) Where is this documente
> A side question, which I do not know the answer to, is how users get
> themselves into this state.
I've fallen over this a few times. It happens when you have multiple
R sessions running, and R tries to update Rcpp while it is loaded in
the other session.
For example, I'm working on one proje
If I want to use with inside a loop, it seems that next gets confused.
To reproduce:
for(lst in list(list(a = 1), list(a = 2), list(a = 3)))
{
with(lst, if(a == 2) next else print(a))
}
I expect 1 and 3 to be printed, but I see
[1] 1
Error in eval(expr, envir, enclos) :
no loop for break/ne
I wondered the same thing a few days ago.
https://stackoverflow.com/questions/36966036/how-to-get-the-last-error
The here's the solution from that discussion:
get_last_error <- function()
{
tr <- .traceback()
if(length(tr) == 0)
{
return(NULL)
}
tryCatch(eval(parse(text = tr[[1]]))
If you set the "digits17" control option in deparse, you get a lot of
unnecessary space in the representation of complex numbers.
> deparse(0 + 0i)
[1] "0+0i"
> deparse(0 + 0i, control = "digits17")
[1] "0 + 0i"
As far as I can tell, the logic for this comes from this piece of
/sr
>From the Details section of ?capture.output:
Messages sent to stderr() (including those from message, warning and stop)
are captured by type = "message". Note that this can be "unsafe" and should
only be used with care.
Capturing messages works as expected:
capture.output(message("!!!"), type =
See \code{\link[originating_pkg]{some_function}}.
#' @name some_function
#' @export
NULL
I borrowed this idea from dplyr's reexporting of magrittr's pipe.
On 17 November 2015 at 00:02, Duncan Murdoch wrote:
> On 16/11/2015 4:00 AM, Richard Cotton wrote:
>>
>> On
On 22 October 2015 at 22:55, Duncan Murdoch wrote:
> I'm planning on adding some new WebGL functionality to the rgl package, but
> it will pull in a very large number of dependencies. Since many people won't
> need it, I'd like to make the new parts optional.
> Can people suggest other packages t
I've just been trying to post-process some R-created heatmaps using
Inkscape, but I can't get them to display correctly in that software.
To reproduce:
library(grid)
r <- as.raster(matrix(runif(25), 5, 5))
pdf("test.pdf")
grid.newpage()
grid.raster(r, interpolate = FALSE)
dev.off()
This figure s
It seems that under Windows, some UTF-8 strings that print OK to
stdout do not print correctly to stderr. To reproduce:
x <- "\ub124"
cat(x, file = stdout())
## 네
cat(x, file = stderr())
##
Original motivating problem here:
https://stackoverflow.com/questions/32696241/how-to-display-a-message-w
Thanks Luke,
On 10 September 2015 at 14:47, wrote:
> Conditions have classes and the condition system is designed around
> the idea that classes would be used for this sort of thing. That is
> already how tryCatch and withCallingHandlers discriminate the
> conditions to handle.
That makes sense
Two solutions:
1. Use the wrapper function is_existing_file in assertive.
2. Use standardize_path in pathological before you call file.exists.
On 27 August 2015 at 17:02, Paul Johnson wrote:
> I'm writing to ask if R Core would make file.exists more Windows
> tolerant when the argument has a
The suppressMessages and suppressWarnings functions currently suppress
all the message or warnings that are generated by the input
expression.
The ability to suppress only specific messages or warnings is
sometimes useful, particularly for cases like file import where there
are lots of things that
One piece of feedback that I received at useR was that the assertive
package is getting too big, and should be broken down into smaller
pieces.
I want to split the functionality into assertive.base,
assertive.types, and a few others, then have the assertive package as
a virtual package (suggestion
deal with it.
>
> Since most of the people who tend to do that generally use systems in UTF-8
> locales where this isn't a problem, or don't use Windows, it is languishing.
Thanks for the link and the explanation of why the bug exists.
>> On May 25, 2015 9:39 AM, "Richard C
Here's a data frame with some Unicode symbols (set intersection and union).
d <- data.frame(x = "A \u222a B \u2229 C")
Printing this data frame under R 3.2.0 patched (r68378) and Windows 7, I see
d
## x
## 1 A B n C
Printing the column itself works fine.
d$x
## [1] A ∪ B ∩ C
Thanks for this. You are right that it's a lowercase "a"; the
documentation on the R.Version help page is incorrect. That describes
status as 'the status of the version (e.g., "Alpha")'.
On 23 March 2015 at 16:36, Duncan Murdoch wrote:
> On 23/03/2015 9
Is there a complete list somewhere of the possible values for R's
status, as returned by version$status?
I know about these values:
Stable: ""
Devel: "Under development (unstable)"
Patched: "Patched"
Release candidate: "RC"
Alpha: "Alpha"
Are there any others that I've missed?
__
On 13 February 2015 at 10:11, Prof Brian Ripley wrote:
> On 11/02/2015 10:46, Richard Cotton wrote:
>
> The 'at a minimum' information required by the posting guide is conspicuous
> by its absence.
>
> At a guess, this is R-devel and Windows.
What I'm running
Today while running update.packages(ask = FALSE), R stopped to ask me
a question:
There are binary versions available but the source versions are later:
binary source needs_compilation
KernSmooth 2.23-13 2.23-14 TRUE
mixture1.2 1.3 TRUE
Do you
g/doc/manuals/r-release/R-lang.html
> http://www.markvanderloo.eu
> ---
> If you cannot quantify it,
> you don't know what you're talking about
>
>
> On Thu, Dec 4, 2014 at 8:00 PM, Richard Cotton wrote:
>&
If I type a character using \U syntax that has more than 4 digits, I
get the wrong character. For example,
"\U1d4d0"
should print a mathematical bold script capital A. See
http://www.fileformat.info/info/unicode/char/1d4d0/index.htm
On my machine, it prints the Hangul character corresponding t
I'm having an issue with occasionally slow-running calls to
normalizePath. If the path is a non-existent UNC path, then
normalizePath sometimes takes 6 or 7 seconds to run, rather than its
usual few microseconds. My big problem is that I can't reliably
reproduce this across machines.
The example
If you set the names in a list, some cat-style processing seems to
happen. For example, backslashes are modified. This behaviour
doesn't happen with atomic vectors. Compare, for example:
setNames(1, "a\\b")
## a\\b
## 1
setNames(list(1), "a\\b")
## $`a\b`
## [1] 1
Notice that the name of the
I recently tried to submit a package to CRAN using the release
function in the devtools package and got the response:
> The policies asked you to use the webform: do so in future.
I think that the relevant line in the policies are:
> When submitting a package to CRAN you should use the submissio
When a PSOCK cluster (maybe other cluster types too) is created by the
parallel package, an Rscript process is spawned for each node. At
least by default, the Rprofile.site file is read for each node that is
created, which can constitute the majority of the time to create a
cluster. See:
http://
The rep function is very versatile, but that versatility comes at a
cost: it takes a bit of effort to learn (and remember) its syntax.
This is a problem, since rep is one of the first functions many
beginners will come across. Of the three main uses of rep, two have
simpler alternatives.
rep(x, t
rian Ripley wrote:
> On 14/10/2012 12:53, Duncan Murdoch wrote:
>>
>> On 12-10-14 7:06 AM, Richard Cotton wrote:
>>>
>>> I started idly wondering how deeply lists could be nested, and
>>> couldn't find an explicit limit in the documentation.
I started idly wondering how deeply lists could be nested, and
couldn't find an explicit limit in the documentation. With this
simple test
a_list <- list()
count <- 0
repeat
{
a_list[[1]] <- a_list
count <- count + 1
}
my (Win7, R-2.16.0 devel) machine threw an error when count got close to
>> is.unsorted(data.frame(1:2))
> [1] FALSE
>> is.unsorted(data.frame(2:1))
> [1] FALSE
>> is.unsorted(data.frame(1:2,3:4))
> [1] TRUE
>> is.unsorted(data.frame(2:1,4:3))
> [1] TRUE
>
> IIUC, is.unsorted is intended for atomic vectors only (description of x in
> ?is.unsorted). Indeed the C source (
I have a roxygen2 documented package with functions for getting and
setting an attribute.
#' Get or set the foo attribute.
#'
#' Dummy function!
#'
#' @param x Object to hold the attribute.
#' @param value Value to set the attribute to.
#' @return The get function returns the "foo" attribute of \c
If I want to assign some variables into an environment, it seems
natural to do something like
e <- new.env()
within(e,
{
x <- 1:5
y <- runif(5)
}
)
This throws an error, since within.environment doesn't exist. I
realise I can work around it using
as.environment(within(as.lis
Even for an extremely simple instance of a reference class
x <- setRefClass("x")
y <- x$new()
calling the internal inspect function
.Internal(inspect(y))
produces enough output that it takes several minutes to print to the
console. (Actually I gave up and terminated the command after ~10
mins.
It seems that there are speed issues when printing to the R console from a
tcl/tk GUI.
Here are functions to write a lot of output, and to display how long it
takes.
printsalot <- function(n)
{
for(i in 1:n) cat(i, fill = TRUE)
}
timings <- function(n = 1e3)
{
print(system.time(printsalot(n)
Notice that
> log(0i)
[1] -Inf+0i
but
> log(0i, )
[1] -Inf+NaNi
To me, it seems that these should be the same value. I'll record this on
the bug tracker if you agree; otherwise please can someone explain why
this is the case.
Regards,
Richie.
Mathematical Sciences Unit
HSL
4D Pie Charts
One tiny thing that would be very nice to have is a default value of n=1 in
the random number generator functions, enabling, e.g., runif() instead of
runif(1). This won't break anyone's existing code and ought to be
relatively straightforward to do.
Is there anyone in the core team who would b
Full_Name: Richard Cotton
Version: 2.9.0
OS: Windows XP, SP2, 32 bit
Submission from: (NULL) (87.102.99.18)
To reproduce the crash:
1. Create an RConsole file for your user account.
2. Close R.
3. Manually edit the font line to include a font that is not on the standard
list of available
I am using R2.9.0 under Windows XP SP 2 (32-bit).
I just discovered a rather excellent programming font
(http://www.dafont.com/bitstream-vera-mono.font). Since it isn't one of
the fonts listed as an option in the RGui Configuration Editor, I manually
editted my RConsole file font line to
font
I'm going to take your second example first.
> The base graphics "image" function has zlim arguments which let you do:
>
> z=outer(1:10,1:10,"*")
> image(z)
> image(z/2, zlim=range(z))
>
> but again, not obvious, and complex/impossible when using more
> sophisticated colour mappings.
The w
> I've been thinking hard about generating colour schemes for data.
> There's quite a bit of existing code scattered in various packages for
> playing with colours and colour palettes, but I can't find the sort of
> thing I'm after for applying colours to data...
>
> To my mind a colour scheme is
> If you send these lines of code:
>
> outdir="c:/pippo"
> file.path(outdir,"pluto.html")
>
> R replies correctly:
>
> [1] "c:/pippo/pluto.html"
>
> But if you change the first steps to:
>
> outdir=""
> file.path(outdir,"pluto.html")
>
> R replies (uncorrectly, I think)
>
> [1] "/c:/pippo/pl
In R2.7.1, the first line of the body of png() reads:
checkIntFormat(filename)
This should really be:
if (!checkIntFormat(file))
stop("invalid 'file'")
Otherwise a command such as png("foo%s.png") causes R to crash (see bug
#10571).
-
Regards,
Richie.
Mathematical Sciences Unit
H
guox wrote:
>
> I would like to call functions/objects of R from
> C#.NET environment. I was wondering whether or not
> it is possible. If yes, could you please give me some suggestions
> on how to approach it (any examples/documentation on this)? Thanks!
>
Here are some instructions on callin
Prof Brian Ripley wrote:
>
>> Yes. The problem is of course that we do want a sprintf() format there
>> for "Rplot%03d.pdf" et al. One option would be to escape "%" except
>> when in (regexp) "%[0-9]*d", which seems nontrivial, but not impossible.
>
> But there are other integer formats (%i,
> > Using %s in a filename when opening a device causes R to crash, e.g.,
> >
> > pdf("foo%s.pdf")
> > win.metafile("foo%s.wmf")
> > postscript("foo%s.ps")
>
> Do you have a workaround for this? Since that is done at C level, we
> can't easily trap this (especially on Windows), and the list of p
Full_Name: Richard Cotton
Version: 2.6.1
OS: Windows XP (32bit)
Submission from: (NULL) (193.119.236.82)
Using %s in a filename when opening a device causes R to crash, e.g.,
pdf("foo%s.pdf")
win.metafile("foo%s.wmf")
postscript("foo%s.ps")
__
48 matches
Mail list logo