[Rd] readLines() fails on non-blocking connections when encoding="UTF-8" or encoding="ASCII"

2023-06-05 Thread Peter Meilstrup
avior from 2018: https://stat.ethz.ch/pipermail/r-devel/2018-April/075883.html Note that that report did not mention encodings being an issue; perhaps the original bug was fixed for native encoding only? Peter Meilstrup __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

[Rd] How to locate references to an environment?

2023-05-23 Thread Peter Meilstrup
R developers, I am trying to track down a memory leak in my R package. I have a complex object O which comprises a lot of closures and such. Among which, the object uses an environment E to perform computations and keep intermediate values in. When O closes/finishes with its task it nulls out

Re: [Rd] substitute() on arguments in ellipsis ("dot dot dot")?

2018-08-12 Thread Peter Meilstrup
Interestingly, as.list(substitute(...())) also works. On Sun, Aug 12, 2018 at 1:16 PM, Duncan Murdoch wrote: > On 12/08/2018 4:00 PM, Henrik Bengtsson wrote: >> >> Hi. For any number of *known* arguments, we can do: >> >> one <- function(a) list(a = substitute(a)) >> two <- function(a, b)

Re: [Rd] Coping with non-standard evaluation in R program analysis

2018-01-03 Thread Peter Meilstrup
For 2), it is not exposed in R's standard library but it is exposed in the Rinternals API. A promise that is forced in normal evaluation will have PRENV set to NULL. Peter On Tue, Jan 2, 2018 at 4:19 PM, Evan James Patterson wrote: > Hello R experts, > > > I plan to

Re: [Rd] `*tmp*`

2014-08-15 Thread Peter Meilstrup
AFAIK there is not supposed to be any user level code that depends on the existence of *tmp*, but there are knock-on effects (evaluating code in a locked environment can succeed with byte code and fail with the interpreter, for instance) Peter On Aug 14, 2014, at 14:35, Michael Haupt

[Rd] ddFindVar

2014-03-11 Thread Peter Meilstrup
Hi all, Is there any particular reason Rf_ddfindVar is not exposed in Rinternals.h? Peter __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] $new cannot be accessed when running from Rscript and methods package is not loaded

2014-02-10 Thread Peter Meilstrup
Because depends is treated incorrectly (if I may place a value judgement on it). I had an earlier thread on this, not sure if any changes have taken place since then: http://r.789695.n4.nabble.com/Dependencies-of-Imports-not-attached-td4666529.html On Mon, Feb 10, 2014 at 5:53 PM, Kirill Müller

Re: [Rd] Which functions are there to parse a NAMESPACE file (without installing the package)

2014-01-21 Thread Peter Meilstrup
Try the function parseNamespaceFile in base. Not documented but its output should be understandable. Peter On Tue, Jan 21, 2014 at 5:41 AM, Markus Müller markus.mueller@gmail.com wrote: For the purpose of automatic documentation, I want to parse a NAMESPACE file of the package to be

Re: [Rd] How to debug an R package (with C code)

2014-01-17 Thread Peter Meilstrup
On Fri, Jan 17, 2014 at 12:43 AM, Gabriel Becker gmbec...@ucdavis.edu wrote: There were some deeper issues with what you asked, though. Sourcing an R file will have no effect on a package in the namespace at all unless you are using something like ESS's developer mode which sources the file

Re: [Rd] class() on substitute(...) output?

2014-01-02 Thread Peter Meilstrup
I've found 'while', 'for', 'if' and '=' appearing as the class of what would ostensibly be call objects, as well. (Came across this because I was using S3 dispatch to help do code-walking syntax transformations) I can't find where it is happening in R source, but it seems significant that they

[Rd] RHS of assignment is evaluated eagerly?

2013-12-26 Thread Peter Meilstrup
Is this expected behavior, and if so, why? I would have expected neither 'arg' nor 'value' to evaluate until forced. `test-` - function(obj, arg, value) { 1 #force no args } x - 1 test(x, print(evaled arg)) - print(evaluated value) ## [1] evaluated value Peter

Re: [Rd] In-string variable/symbol substitution: What formats/syntax is out there?

2013-12-17 Thread Peter Meilstrup
There's also knit_expand() in knitr, which uses the form pi = {{pi}} with general expressions. Peter On Tue, Dec 17, 2013 at 1:44 PM, Henrik Bengtsson h...@biostat.ucsf.edu wrote: Hi, I'm try to collect a list of methods/packages available in R for doing in-string variable/symbol

Re: [Rd] internal manipulation of ...

2013-12-14 Thread Peter Meilstrup
In R code, get(..., environment()) will retrieve the DOTSXP object. So another way is to write your wrapper functions like someFunc - function(...) { .External(someFunc_extern, get(..., ifnotfound=NULL) ) } If you're trying to mimic what substitute() et al do, you'll sometimes need to follow a

Re: [Rd] on.exit() sys.on.exit(): Calling them via eval() does not work as hoped

2013-11-03 Thread Peter Meilstrup
eval() tends to be able to convince normal functions of where they are executing, but primitive functions use different methods to get their evaluation context and aren't as easily fooled. It turns out do.call() works better on primitive functions, and it will work for on.exit. However I wasn't

Re: [Rd] read.table() with quoted integers

2013-10-04 Thread Peter Meilstrup
I think this is not the right approach -- quoting is a transport-layer feature of the CSV format, not part of the application layer. Quotes should always be interpreted away from column data before any data is handed to the application layer. (CSV does not _have_ any application layer; type

Re: [Rd] read.table() with quoted integers

2013-10-04 Thread Peter Meilstrup
On Fri, Oct 4, 2013 at 9:20 AM, Peter Meilstrup peter.meilst...@gmail.com wrote: I think this is not the right approach -- quoting is a transport-layer feature of the CSV format, not part of the application layer. Quotes should always be interpreted away from column data before any data

Re: [Rd] read.table() with quoted integers

2013-10-01 Thread Peter Meilstrup
On Mon, Sep 30, 2013 at 8:10 AM, Joris Meys jorism...@gmail.com wrote: Regardless of whether stored as character is interpreted the R way or the ASCII way, the point Joshua makes is rather valid. Mainly because read.table has an argument quote with default value \'. This means that at least

Re: [Rd] read.table() with quoted integers

2013-10-01 Thread Peter Meilstrup
On Tue, Oct 1, 2013 at 5:50 AM, Peter Meilstrup peter.meilst...@gmail.com wrote: On Mon, Sep 30, 2013 at 8:10 AM, Joris Meys jorism...@gmail.com wrote: Regardless of whether stored as character is interpreted the R way or the ASCII way, the point Joshua makes is rather valid. Mainly because

[Rd] Why does duplicate() make deep copies?

2013-09-04 Thread Peter Meilstrup
Some experimentation with the below function should convince you that the runtime of the bit inside sys.time is proportional to size*number*times. I think it should only be proportional to number*times. The function is only manipulating a list of references to vectors and not trying to make

Re: [Rd] legitimate use of :::

2013-08-22 Thread Peter Meilstrup
It would be nice if the functionality of importFrom() and import() were available to user level code, rather than just to people building packages for distribution. One most often encounters namespace conflicts at the user level, when loading two packages that have no logical connection other than

[Rd] How does R_UnboundValue and removing variables work?

2013-08-18 Thread Peter Meilstrup
Reading R Internals made me believe that R_UnboundValue was a placeholder that would be skipped over in variable lookup. viz. the section of R Internals Hash tables says items are not actually deleted but have their value set to R_UnboundValue., which seems to align with what I read in envir.c.

Re: [Rd] Inconsistency between eval and withVisible (with patch)

2013-08-15 Thread Peter Meilstrup
I agree that the present behavior of withVisible is the Right Thing, but the documentation is confusing. The documentation claims that withVisible evaluates an expression. This may capture an inside view of how the .Internal function is implemented, but is nonsense from the R user's standpoint,

Re: [Rd] Inconsistency between eval and withVisible (with patch)

2013-08-15 Thread Peter Meilstrup
-project.orgwrote: On Aug 15, 2013, at 3:06 AM, Gabriel Becker wrote: On Wed, Aug 14, 2013 at 11:14 PM, Peter Meilstrup peter.meilst...@gmail.com wrote: I agree that the present behavior of withVisible is the Right Thing, but the documentation is confusing. The documentation claims

Re: [Rd] Inconsistency between eval and withVisible (with patch)

2013-08-15 Thread Peter Meilstrup
On Thu, Aug 15, 2013 at 5:59 AM, Simon Urbanek simon.urba...@r-project.orgwrote: Note that this is documented very explicitly: eval’ evaluates its first argument in the current scope before passing it to the evaluator But the same man page also describes eval like this: 'eval' evaluates

Re: [Rd] local variable assignment: first copies from higher frame?

2013-08-14 Thread Peter Meilstrup
Not anything that complicated -- your answer is in the R language definition under 'Subset assignment' and the part in Function calls that describes assignment functions. Whenever a call is found on the left side of a `-`, it is munged by sticking a - on the function name and pulling out the

Re: [Rd] On the mechanics of function evaluation and argument matching

2013-07-17 Thread Peter Meilstrup
On Wed, Jul 17, 2013 at 10:20 AM, Ben Bolker bbol...@gmail.com wrote: Brian Rowe rowe at muxspace.com writes: Thanks for the lead. Given the example in ?missing though, wouldn't it be safer to explicitly define a default value of NULL: myplot - function(x, y=NULL) {

[Rd] does subset.data.frame need to accept extra arguments?

2013-07-07 Thread Peter Meilstrup
The formal list for subset.data.frame accepts a ... args(subset.data.frame) function (x, subset, select, drop = FALSE, ...) NULL But it appears that subset.data.frame does not actually use the ... or pass it along: ... %in% all.names(body(subset.data.frame)) [1] FALSE Is there any reason why

[Rd] The *tmp* variable

2013-07-06 Thread Peter Meilstrup
When complex assignments are performed, the R interpreter creates, then removes a special variable *tmp*. However, when byte compiling is enabled, it seems that a different mechanism for making compound assignments is used. Would it be possible to eliminate *tmp* from interpreted R code as well?

Re: [Rd] The *tmp* variable

2013-07-06 Thread Peter Meilstrup
in the environment from which f is called. The function does not return x -- it returns a value, which you can assign as you wish. So ??? (and apologies if I'm missing something obvious). Cheers, Bert On Sat, Jul 6, 2013 at 9:11 PM, Peter Meilstrup peter.meilst...@gmail.com wrote: When

Re: [Rd] should the text for RIGHT_ASSIGN be - in getParseData()?

2013-07-05 Thread Peter Meilstrup
For these programs that use GNU readline, hit Alt-Control-J to switch into vi-like bindings. On Jul 5, 2013, at 16:42, Brian Lee Yung Rowe r...@muxspace.com wrote: That is a more accurate statement regarding Ctrl-K. Nonetheless whatever is killed can be yanked back via Ctrl-Y, so the effect

Re: [Rd] Problem with anova and the new abbreviation restrictions

2013-07-01 Thread Peter Meilstrup
On Mon, Jul 1, 2013 at 1:51 PM, Terry Therneau thern...@mayo.edu wrote: afit - anova(lm(conc ~ uptake, CO2)) afit$P [1] 2.905607e-06 NA Warning message: In `$.data.frame`(afit, P) : Name partially matched in data frame afit$Pr(F) Error: unexpected '' in afit$Pr( The second

Re: [Rd] problem with eval(..., parent.frame(1L)) when package is not loaded

2013-06-28 Thread Peter Meilstrup
On Thu, Jun 27, 2013 at 8:49 PM, Ben Bolker bbol...@gmail.com wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 The lmer() function in the lme4 package has some code of the form mc - match.call() mc[[1]] - as.name(lFormula) lmod - eval(mc, parent.frame(1L)) this is a fairly

Re: [Rd] problem with eval(..., parent.frame(1L)) when package is not loaded

2013-06-28 Thread Peter Meilstrup
On Fri, Jun 28, 2013 at 3:07 PM, Ben Bolker bbol...@gmail.com wrote: On 13-06-28 03:57 PM, Peter Meilstrup wrote: Well, once you begin messing with eval.parent(), you _are_ telling R what environment to work in, and things have the potential to go wrong at that point because you're telling

Re: [Rd] Substitute / delayedAssign (was: Substitute unaware when promise objects are evaluated)

2013-05-17 Thread Peter Meilstrup
On Fri, May 17, 2013 at 2:47 AM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 13-05-16 11:17 PM, Peter Meilstrup wrote: On Thu, May 16, 2013 at 6:06 AM, McGehee, Robert Robert.McGehee@geodecapital.**com robert.mcge...@geodecapital.com wrote: Duncan, Thank you for the clarification

Re: [Rd] Substitute / delayedAssign (was: Substitute unaware when promise objects are evaluated)

2013-05-16 Thread Peter Meilstrup
On Thu, May 16, 2013 at 6:06 AM, McGehee, Robert robert.mcge...@geodecapital.com wrote: Duncan, Thank you for the clarification on how delayedAssign works. Should R-level interfaces to promise objects ever become available, I expect they would at time come in handy. On the subject of

[Rd] Dependencies of Imports not attached?

2013-05-07 Thread Peter Meilstrup
Encountered an error in scripting, which can be reproduced using Rscript as follows: $ Rscript -e library(httr); handle('http://cran.r-project.org') Error in getCurlHandle(cookiefile = cookie_path, .defaults = list()) : could not find function getClass Calls: handle - getCurlHandle or by

Re: [Rd] Depreciating partial matching

2013-03-21 Thread Peter Meilstrup
This thread is strange for me to read as I've been getting completion of object names, function arguments names, and whatnot in ESS buffers for as long as I can have been using it. And I'm only on ESS 12.09. Perhaps you need to set `ess-use-R-completion` to non-nil. Or check the value of

Re: [Rd] Mirroring R on a DVCS

2013-03-16 Thread Peter Meilstrup
There is already a mirror on GitHub at https://github.com/wch/r-source . Peter On Mar 16, 2013, at 11:17, Laurent Gautier lgaut...@gmail.com wrote: Hi, I have been looking at mirroring the SVN R repository into a DVCS (Mercurial, Git, bzr, etc...). The idea would be to have that as an

Re: [Rd] quote() vs quote(expr=)

2013-02-19 Thread Peter Meilstrup
It probably shouldn't be, but It's possible to bind a value to the missing symbol: x - environment() eval(substitute(x$y - wat, list(y = quote(expr= ls() eval(quote(expr=)) I don't see a way to remove such a binding though. Peter On Tue, Feb 19, 2013 at 5:03 AM, peter dalgaard

Re: [Rd] Arguments passing through dot-dot-dot lose ability to check for missing()?

2013-02-09 Thread Peter Meilstrup
- function(..., capture) { capture(...) } f1(x=1, q=, capture=capture_subst) f1(x=1, q=, capture=capture_match) On Wed, Jan 23, 2013 at 3:08 PM, Peter Meilstrup peter.meilst...@gmail.comwrote: Hi R-devel. Is the following behavior in g1() and h1() expected? It seems to make ... arguments

[Rd] Arguments passing through dot-dot-dot lose ability to check for missing()?

2013-01-23 Thread Peter Meilstrup
Hi R-devel. Is the following behavior in g1() and h1() expected? It seems to make ... arguments work slightly differently from named arguments. #missing() has the property that it looks up the chain #for example, z can be missing in f3 even if #that argument did have a name (y) in f2 f1 -

[Rd] Prevent serialization of an environment?

2013-01-15 Thread Peter Meilstrup
Within I'm using an environment as a hashtable to cache the results of some repeated computations in a package. The thing is that the contents of the cache will not be valid across R sessions, so I would like to make sure that the cache is cleared if the user saves or restores the workspace (or

Re: [Rd] Prevent serialization of an environment?

2013-01-15 Thread Peter Meilstrup
On Tue, Jan 15, 2013 at 4:55 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 13-01-15 7:39 PM, Peter Meilstrup wrote: Within I'm using an environment as a hashtable to cache the results of some repeated computations in a package. The thing is that the contents of the cache

Re: [Rd] Prevent serialization of an environment?

2013-01-15 Thread Peter Meilstrup
OK. Based on comments in serialize.c, this sort of thing isn't available(yet). However, I also came to the conclusion that for my purposes (caching functions-of existing R objects) I might implement the cache not with an environment but with the weak-reference facility exposed in the C interfaces.

Re: [Rd] How to build a list with missing values? What is missing, anyway?

2012-10-04 Thread Peter Meilstrup
On Thu, Oct 4, 2012 at 6:12 PM, Bert Gunter gunter.ber...@gene.com wrote: The R Language definition manual explains all of this. Read it. I always reread that before I post to this list. The only relevant mention of missing in the R Language Definition that I could find were in section 4.1.2 on

Re: [Rd] Creating functions programmatically

2012-10-03 Thread Peter Meilstrup
On Wed, Oct 3, 2012 at 7:47 AM, Hadley Wickham h.wick...@gmail.com wrote: There is: it is `function`. The parser converts your function definitions into a call to it. (It has 3 arguments: the formals, the body, and the srcref. The environment is added when it is evaluated.) So your

[Rd] How to build a list with missing values? What is missing, anyway?

2012-10-03 Thread Peter Meilstrup
This is tangentially related to Hadley's question. Suppose I'm building a function programmatically; I have assembled an expression for the body and I know the names of the arguments it wants to take. Suppose I have some convenience function such that writing make_function(alist(a=, b=),

Re: [Rd] R 2.14.1 memory management under Windows

2012-03-22 Thread Peter Meilstrup
My guess would be that it's a matter of having swap space be a dedicated partition or fixed-size file (Linux, usually) versus swapping to a regular file that grows as needed (Windows and OS X, usually.) So if you defragmented your drive and set Windows to have a fixedsize swap file, it would