[Rd] Bug in stars.R (PR#739)
Martin Maechler
Martin Maechler <maechler@stat.math.ethz.ch>
Mon, 20 Nov 2000 17:09:30 +0100
>>>>> "tdye" == tdye <tdye@lava.net> writes:
tdye> Hi all, Please let me know if this isn't the correct place to
tdye> report bugs in contributed code. Otherwise, the following code
tdye> contains one additional line and a short comment above it. The
tdye> extra line of code catches the unusual situation where a data
tdye> column contains all 0 values.
tdye> The corrected code is below the signature.
tdye> Thanks for your help. Tom
tdye> Thomas S. Dye, Ph.D. http://www.tsdye.com Home: 812A 19th
tdye> Avenue, Honolulu, Hawaii 96816. (808) 739-1367 or 387-9352.
tdye> Work: International Archaeological Research Institute, Inc., 2081
tdye> Young St., Honolulu, Hawaii 96826. Voice (808) 946-2548; Fax
tdye> 943-0716.
Dear Thomas,
thank you for the bug report and fix.
Since you *are* the original contributor of this R function,
I took the time and carefully looked at the (mass of) code you sent...
3 remarks:
- you fixed the "installed code", not the source code,
which *is* <R_TOPDIR>/src/library/base/R/stars.R
i.e. your version had dropped all the comments
- it would have been much easier had you only sent the result of
"diff -c oldfile newfile"
- After looking at your change, it seems clear that it is only needed
inside the if(scale) { .. } clause.
This all amounts to
diff -u -b -B -w -r1.3 stars.R
--- src/library/base/R/stars.R 1999/11/01 10:02:17 1.3
+++ src/library/base/R/stars.R 2000/11/20 14:36:20
@@ -54,8 +53,11 @@
## Missing values are treated as 0
x[is.na(x)] <- 0
- if (scale)
+ if (scale) {
x <- sweep(x,2,apply(x,2,max),FUN="/")
+ ## Columns of 0s will put NAs in x, next line gets rid of them
+ x[is.na(x)] <- 0
+ }
x <- x * len
-----
which will be in R 1.2.
Thank you again for stars()!
Martin Maechler <maechler@stat.math.ethz.ch> http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum LEO D10 Leonhardstr. 27
ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
phone: x-41-1-632-3408 fax: ...-1228 <><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._