Displaying 20 results from an estimated 2000 matches similar to: "codetools"
2013 Apr 08
4
checkUsage from codetools shows errors when function uses functions from loaded packages
Dear list members,
I frequently program small scripts and wrap them into functions to be
able to check them with checkUsage. In case these functions (loaded via
source or copy pasted to the R console) use functions from other
packages, I get this error:
no visible global function definition for ?xxxxxxx?
For example:
test = function() {
require(plotrix)
color.legend()
}
2010 Jan 29
1
Question on codetools and parse trees
Dear R Users,
Using codetools I obtained the text representation of the parse tree for this
snippet
z=quote({x[1]<-2})
showTree(z)
> ("{" (<- ([ x 1) 2)) (A)
If I understand correctly, x[1]<-2 ought to be "[<-"(x,1,2), so shouldn't i see
("{" ( [<- x 1 2 ) )
If indeed the parse tree in (A) is correct, the operation ([ x 1)
returns the
2009 Mar 06
0
Bug in codetools ?
Hello,
Is this a bug in codetools:
> codetools::showTree( body( glm) )
("{" (<- call (match.call)) (if (is.character family) (<- family (get
family "function" (parent.frame)))) (if (is.function family) (<-
family(family))) (if (is.null ($ family family)) ("{" (print family)
(stop "'family' not recognized"))) (if (missing data)
2024 Feb 07
1
[EXTERNAL] Re: NOTE: multiple local function definitions for ?fun? with different formal arguments
I put the idea below into a function that gives nicer looking results.
Here's the new code:
dupnames <- function(path = ".") {
Rfiles <- pkgload:::find_code(path)
allnames <- data.frame(names=character(), filename=character(), line
= numeric())
result <- NULL
for (f in Rfiles) {
exprs <- parse(f, keep.source = TRUE)
locs <-
2013 Jan 16
2
Codetools Query (repost)
Sorry for reposting, i keep forgetting this should be plain text.
Will not make this mistake again
Hello,
The following code
moo <- function(a=1){ x=1; x=x+y}
funs <- new.env()
enter <- function(type, v, e, w){
assign(v, TRUE, funs)
}
library(codetools)
collectUsage(moo, enterGlobal = enter)
adds + to the environment funs i.e.
funs: "=" "{" "+"
2008 Apr 07
3
findGlobals on apply
Hi the list,
Considere the following:
f <- function(x){apply(x,2,mean)}
findGlobals(f)
findGlobals consideres mean as a global variable, which it is not.
Is there a way to tell to findGlobals that mean is a function ?
Thanks
Christophe
2011 Feb 03
1
bug in codetools/R CMD check?
Hi Mr Tierney,
I have noticed an error message from R 1.12.x's CMD check for a while (apparently prof Ripley completely rewrote CMD check in R 1.12+)
e.g.:
http://bioconductor.org/checkResults/2.7/bioc-LATEST/snpMatrix/lamb2-checksrc.html
----------------
* checking R code for possible problems ... NOTE
Warning: non-unique value when setting 'row.names': ?new?
Error in
2007 Jul 25
1
codetools really optional for R CMD check?
After upgrading to R 2.5.1 on Debian, R CMD check gives
* checking Rd cross-references ... WARNING
Error in .find.package(package, lib.loc) :
there is no package called 'codetools'
Execution halted
* checking for missing documentation entries ... WARNING
etc
The NEWS file says (for 2.5.0; I was on 2.4 before the recent upgrade)
o New recommended package 'codetools' by Luke
2015 Jul 29
0
Mapping parse tree elements to tokens
Both codetools and compiler get by without this. codetools uses source
refs to generate messages; I don't recall if compiler does but it
could easily do so. I would be wary about committing to this sort of
implementation specific stuff -- we might want to go to completely
different parser technology at tome point, which would be harder if we
committed to these sort of details.
Best,
luke
On
2023 Oct 20
0
UseMethod forwarding of local variables
UseMethod has since the beginning had the 'feature' that local
variables in the generic are added to the environment in which the
method body is evaluated. This is documented in ?UseMethod and
R-lang.texi, but use of this 'feature' has been explicitly discouraged
in R-lang.texi for many years.
This is an unfortunate design decision for a number of reasons (see
below), so the plan
2008 Feb 28
0
tutorial on codetools
Hi the list
Is there any tutorial to learn codetools ? It seems to be a very
interesting pacakge, but the help gives not that much detail, and there
is not that much examples provided...
Christophe
2023 Jun 03
3
codetools wrongly complains about lazy evaluation in S4 methods
In a package, I define a method for not-yet-generic function 'qr.X' like so:
> setOldClass("qr")
> setMethod("qr.X", signature(qr = "qr"), function(qr, complete, ncol) NULL)
The formals of the newly generic 'qr.X' are inherited from the non-generic
function in the base namespace. Notably, the inherited default value of
formal
2007 Dec 16
2
clean programming
Hello the list,
I am trying to write a "cleanProgramming" function to test the
procedure I use. For example, I want to be sure that I am not using
globals variables. The function "findGlobals" detect that.
To list the globals used in function "fun", the syntax is :
"findGlobals(fun,FALSE)$variable"
My problem is that I want to use it in a function,
2018 Mar 14
0
Possible Improvement to sapply
>>>>> Henrik Bengtsson <henrik.bengtsson at gmail.com>
>>>>> on Tue, 13 Mar 2018 10:12:55 -0700 writes:
> FYI, in R devel (to become 3.5.0), there's isFALSE() which will cut
> some corners compared to identical():
> > microbenchmark::microbenchmark(identical(FALSE, FALSE), isFALSE(FALSE))
> Unit: nanoseconds
> expr
2007 Nov 22
2
Clean programming with R
Hi all
Is there any compiler for R ? By compiler, I mean something that check
the cleanliness of the code : if we declare all the variables we use, if
we don't use external variable from a function and so on...
For exemple, something that will ring a bell on the following code
(saying "line 4 : 'pp' undefine in function 'power' ")
1. pp <- 3
2. power <-
2024 Feb 06
1
[EXTERNAL] Re: NOTE: multiple local function definitions for ?fun? with different formal arguments
Here's a dummy example that I think illustrates the problem:
toto <- function() {
if (runif(1) < 0.5)
function(a) a
else
function(a,b) a+b
}
> fcn <- toto()
> fcn(1,2)
[1] 3
> fcn <- toto()
> fcn(1,2)
[1] 3
> fcn <- toto()
> fcn(1,2)
Error in fcn(1, 2) : unused argument (2)
How can you use the returned function, if you get different arguments?
2010 Jun 01
0
codetools: Suggestion to detect potentially unassigned variables
This is just a note/wishlist/for the record:
With
foo1 <- function() {
res;
}
foo2 <- function() {
for (i in c()) res <- 1;
res;
}
foo3 <- function() {
while (FALSE) res <- 1;
res;
}
foo4 <- function() {
if (FALSE) res <- 1;
res;
}
we get:
> foo1()
Error in foo1() : object 'res' not found
> foo2()
Error in foo2() : object 'res' not
2011 Mar 16
2
Detecting bad lexical scoping
I've recently hunted down a troublesome bug in my own code, and am
looking for an easy mechanism to detect this kind of error in other R
code. The problem was an undefined variable inside of a function.
Unfortunately, R looked for that variable in the global environment
and found it since there was variable with that name in my testing
scripts (note to self: do not name things "x").
2009 Jul 02
2
Warning when trying to access a variable out of scope?
Hi,
I was wondering if I could get R to warn me, or give me a rude
awakening somehow, if I'm accessing a variable that is out of my
function's scope.
For example, often times I'm creating a function as I'm testing it in
the REPL, copying and pasting between both.
As a simple example, I might end up with a function like:
f <- function(a, b) {
a + b.test
}
Where
2019 Sep 16
0
[External] REprintf could be caught by tryCatch(message)
You can file it as a wishlist item in the bug trackign system. Without
a compelling case or a complete and well tested patch or both I doubt
it will rise to the top of anyone's priority list.
Best,
luke
On Sun, 15 Sep 2019, Jan Gorecki wrote:
> Thank you Luke for prompt reply.
> Is it possible then to request a new function to R C API "message"
> that would equivalent to