An R script will terminate when one tries to use an undefined variable, with a message such as Error in print(x) : Object "x" not found This run-time error might occur after the script has already been running for some time. In some cases it would be nice to get such warnings before the script is run, just as a syntax error caused by a missing parenthesis is caught. Are there any "static analysis" tools for R? Such a tool would not have to be perfect to be useful. Besides using undefined variables, defining variables that are never used is something I'd like to be warned about.
static analysis tools for R code?
4 messages · Vivek Rao, Dimitris Rizopoulos, Luke Tierney +1 more
If I understand well what you need then (I think) the answer is No; this is a feature of the language called "Lazy Evaluation". For more info look at e.g., the "R Language Definition" document, section 4.3.3. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Vivek Rao" <rvivekrao at yahoo.com> To: <r-help at stat.math.ethz.ch> Sent: Monday, April 11, 2005 4:18 PM Subject: [R] static analysis tools for R code?
An R script will terminate when one tries to use an undefined variable, with a message such as Error in print(x) : Object "x" not found This run-time error might occur after the script has already been running for some time. In some cases it would be nice to get such warnings before the script is run, just as a syntax error caused by a missing parenthesis is caught. Are there any "static analysis" tools for R? Such a tool would not have to be perfect to be useful. Besides using undefined variables, defining variables that are never used is something I'd like to be warned about.
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
There are some preliminary tools available in the codetools package at http://www.stat.uiowa.edu/~luke/R/codetools/ Hopefully these will be cleaned up and released via CRAN or incorporated into R this summer. luke
On Mon, 11 Apr 2005, Dimitris Rizopoulos wrote:
If I understand well what you need then (I think) the answer is No; this is a feature of the language called "Lazy Evaluation". For more info look at e.g., the "R Language Definition" document, section 4.3.3. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Vivek Rao" <rvivekrao at yahoo.com> To: <r-help at stat.math.ethz.ch> Sent: Monday, April 11, 2005 4:18 PM Subject: [R] static analysis tools for R code?
An R script will terminate when one tries to use an undefined variable, with a message such as Error in print(x) : Object "x" not found This run-time error might occur after the script has already been running for some time. In some cases it would be nice to get such warnings before the script is run, just as a syntax error caused by a missing parenthesis is caught. Are there any "static analysis" tools for R? Such a tool would not have to be perfect to be useful. Besides using undefined variables, defining variables that are never used is something I'd like to be warned about.
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa Phone: 319-335-3386
Department of Statistics and Fax: 319-335-3017
Actuarial Science
241 Schaeffer Hall email: luke at stat.uiowa.edu
Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu
Look at Luke Tierney's codetools package. https://stat.ethz.ch/pipermail/r-devel/2003-July/027103.html It is useful, and has been run over R itself several times.
On Mon, 11 Apr 2005, Vivek Rao wrote:
An R script will terminate when one tries to use an undefined variable, with a message such as Error in print(x) : Object "x" not found This run-time error might occur after the script has already been running for some time. In some cases it would be nice to get such warnings before the script is run, just as a syntax error caused by a missing parenthesis is caught. Are there any "static analysis" tools for R? Such a tool would not have to be perfect to be useful. Besides using undefined variables, defining variables that are never used is something I'd like to be warned about.
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595