search for: findglobals

Displaying 16 results from an estimated 16 matches for "findglobals".

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 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, something like : cleanProg <- function(name){ if(length(findGlobals(name,FALSE)$variable>0){ cat(&q...
2011 Jan 06
2
Global variables
Dear R-users, Is there a way I can prevent global variables to be visible within my functions? Sebastien
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: "=" "{" "+"
2012 Jun 23
1
globalVariables()
...a rough function that I used to compose the globalVariables() command from the package check summary; it's probably not bullet-proof, but perhaps others will find it useful for packages, like the Rcmdr, that currently generate many notes about global variables: ------------- snip ------------ findGlobals <- function(filein="00check.log", fileout="globals.R"){ checklog <- readLines(filein) whichline <- which(grepl("checking R code for possible problems .* NOTE", checklog)) checklog <- checklog[-(1:whichline)] whichline <- which(grepl("checkin...
2011 Mar 24
3
Extract the names of the arguments in an "expression"
Hi everybody: I need to get the names of the arguments in an object of class "expression". I've got the following expression: > x <- expression(rho * cos(omega)) Is there any function or procedure that returns the names of the arguments (in the example: "rho" and "omega")? I tried a rough approach implemented in the function expr.args() shown below. As
2018 Mar 14
0
Possible Improvement to sapply
...n(x) is.logical(x) && length(x) == 1L && !is.na(x) && x isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x and one *reason* this is so fast is that all 6 functions which are called are primitives : > sapply(codetools::findGlobals(isTRUE), function(fn) is.primitive(get(fn))) ! && == is.logical is.na length TRUE TRUE TRUE TRUE TRUE TRUE and a 2nd reason is probably with the many recent improvements of the byte compiler. > That could probably...
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
...ke/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 expression; useful for understanding parsing. This stuff is a by-product of putting together a more solid framework for the byte code compiler I am working on and it's still ve...
2009 Feb 05
0
no visible binding for global variable
Everyone, I know that this has been discussed a few times on the list, but I think that there is a high false positive rate of messages from findGlobals during R CMD check (I know the help page has that "The result is an approximation"). Here are two examples of from the caret package: This function get the message "predictors.gbm: no visible binding for global variable 'rel.inf'" predictors.gbm <- function(x, ...)...
2007 Oct 19
2
Declaring variables in R
Please forgive me if my question is answered in Help FAQ no. 23481739... In language like C every variable must be declared before it can be used. In VBA, if a variable has not been declared it is assumed to be of a special type (Variant). In R (and Matlab) variables do not have to be declared. This is convenient, but in a large program one can make a typo which will be extremely difficult 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 Sep 29
3
Finding inter-function dependencies within a package
Hi, I'd like to know which functions in a package call one specific function. I think I've seen a tool for identifying such dependencies, but now I can't find it :-( Searches of help and R site search for keywords like function, call, tree, depend haven't helped :-( Can anyone point me in the right direction? Thanks in advance, Keith Jewell
2008 Oct 07
3
Automatic code diagramming for R?
Greetings - Is anyone aware of an automatic code diagrammer/flow chart creator that works for the R language (either a contributed package, or external software)? I need to explain some code structure of a package I'm working on to non-R users, and would find it extremely helpful to have such a program similar to, for example, Visustin ( http://www.aivosto.com/visustin.html ). I can do it
2003 Mar 17
2
scoping rules; summary
Hi everyone thanks for the replies. The issue was NOT a font problem; I deliberately chose ll1 and l11 as examples of easily confused variable names (evidently these were too easily confused ;-). The code snippet was written as intended, and increment() contained a deliberate, highlighted, bug. I was asking for guidance on avoiding/finding this sort of coding error. That was why I wrote
2018 Mar 13
2
Possible Improvement to sapply
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 min lq mean median uq max neval identical(FALSE, FALSE) 984 1138 1694.13 1218.0 1337.5 13584 100 isFALSE(FALSE) 713 761 1133.53 809.5 871.5