[Rd] bug in codetools/R CMD check?

Hin-Tak Leung htl10 at users.sourceforge.net
Thu Feb 3 11:26:33 CET 2011


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 `row.names<-.data.frame`(`*tmp*`, value = c("1", "new", "new" : 
  duplicate 'row.names' are not allowed
Calls: <Anonymous> ... rownames<- -> row.names<- -> row.names<-.data.frame
Execution halted
-----------------

yet everything is okey dokey at http://bioconductor.org/checkResults/2.7/bioc-LATEST/#S under the snpMatrix entry.

I believe it might be a bug in codetools::incLocalSrcInfo (used by "R CMD check") and here is what I think the fix(?) - but I am not entirely sure what that routine does and why other package writers haven't noticed similiar problems before:

diff -ur codetools/R/codetools.R codetools-fix/R/codetools.R
--- codetools/R/codetools.R	2011-01-07 15:52:58.000000000 +0000
+++ codetools-fix/R/codetools.R	2011-02-03 10:03:54.000000000 +0000
@@ -823,8 +823,9 @@
     new <- list(srcfile = if (is.null(w$srcfile)) NA_character_ else w$srcfile,
                 frow = if (is.null(w$frow)) NA_integer_ else w$frow,
                 lrow = if (is.null(w$lrow)) NA_integer_ else w$lrow)
+    new <- as.data.frame(new, stringsAsFactors = FALSE)
     if (is.null(value))
-        value <- as.data.frame(new, stringsAsFactors = FALSE)
+        value <- new
     else
         value <- rbind(value, new)
     assign("srcinfo", value, entry)


Apply this "fix" would result in snpMatrix's "R CMD check" churning out:

---------------------
.ld.withmany: local variable ‘names.components’ assigned but may not be used
.ld.withmany: local variable ‘nsnps.for.each’ assigned but may not be used
misinherits: local variable ‘nc.snps’ assigned but may not be used
misinherits: local variable ‘nr.snps’ assigned but may not be used
qq.chisq: local variable ‘lab’ assigned but may not be used
read.HapMap.data: local variable ‘base’ assigned but may not be used
read.HapMap.data: local variable ‘build’ assigned but may not be used
read.HapMap.data: local variable ‘finish’ assigned but may not be used
read.HapMap.data: local variable ‘strand’ assigned but may not be used
tdt.snp: local variable ‘nc.snps’ assigned but may not be used
tdt.snp: local variable ‘nr.snps’ assigned but may not be used
---------------------

which is more like expected check warnings.

Care to comment?

Hin-Tak Leung






More information about the R-devel mailing list