search for: checkusag

Displaying 10 results from an estimated 10 matches for "checkusag".

Did you mean: checkusage
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() } library(codetools) checkUsage(test...
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
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 <-
2003 Jul 28
0
codetools
I've put together a package codetools with some tools for examining R source code. It is available at http://www.stat.uiowa.edu/~luke/R/codetools/codetools.tar.gz It requires a reasonably current version of R-devel. The main user functions are: checkUsage, checkUsageEnv, checkUsagePackage: Examine closure, closures in an environment, closures in a package, and report information on possible problems findGlobals: Finds global functions and variables used by a function. showTree: Prints Lisp-style representation of expressio...
2024 Feb 24
1
Clustering Functions used by Reverse-Dependencies
Dear R Users, Are there any tools to extract the function names called by reverse-dependencies? I would like to group these functions using clustering methods based on the co-occurrence in the reverse-dependencies. Utility: It may be possible to split complex packages into modules with fewer reverse-dependencies. Package pkgdepR may offer some of the functionality; but I did not have time to
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").
2011 Apr 09
2
Wish there were a "strict mode" for R interpreter. What about You?
Years ago, I did lots of Perl programming. Perl will let you be lazy and write functions that refer to undefined variables (like R does), but there is also a strict mode so the interpreter will block anything when a variable is mentioned that has not been defined. I wish there were a strict mode for checking R functions. Here's why. We have a lot of students writing R functions around here
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
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?
2024 Feb 07
1
[EXTERNAL] Re: NOTE: multiple local function definitions for ?fun? with different formal arguments
...com> wrote: >>> >>> I went looking and found this in codetools, where it's been for 20 years >>> >>> https://gitlab.com/luke-tierney/codetools/-/blame/master/R/codetools.R?ref_type=heads#L951 >>> >>> I think the call stack in codetools is checkUsagePackage -> checkUsageEnv -> checkUsage, and these are similarly established. The call from the tools package https://github.com/wch/r-source/blame/95146f0f366a36899e4277a6a722964a51b93603/src/library/tools/R/QC.R#L4585 is also quite old. >>> >>> I'm not sure this had bee...