Re: [Rd] fix for save()'ing RAW on PPC (and other big endian platforms)
Byron Ellis <[EMAIL PROTECTED]> writes: > OutByte should take a byte, not an int. Writing the first byte of an > int is only going to work on little endian systems. > > serialize.c:262 > -static void OutByte(R_outpstream_t stream, int i) > +static void OutByte(R_outpstream_t stream, Rbyte i) Thanks for tracking this down. -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] fix for save()'ing RAW on PPC (and other big endian platforms)
OutByte should take a byte, not an int. Writing the first byte of an int is only going to work on little endian systems. serialize.c:262 -static void OutByte(R_outpstream_t stream, int i) +static void OutByte(R_outpstream_t stream, Rbyte i) --- Byron Ellis ([EMAIL PROTECTED]) "Oook" -- The Librarian __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Characters in lists.
Hi all, this should be a relatively straightforward question. I am constructing an R list in C which will contain both Integers and Strings (by string I mean in C I have const char* whose values I want passed through to R) The Integers are easy. I do something like this: PROTECT(tmp = NEW_INTEGER(1)); INTEGER(tmp)[0] = header.GetCols(); SET_STRING_ELT(names, i, mkChar("cols")); SET_VECTOR_ELT(vals, i++, tmp); UNPROTECT(1); This works just fine. So, when I wanted to set a string element of the list (please correct my nomenclature if I am refering to things incorrectly) I used the following bit of code: SET_STRING_ELT(names, i, mkChar("header")); SET_VECTOR_ELT(vals, i++, mkChar(header.GetHeader().c_str())); I did this based on the fact that this is how I have created named attributes for lists in the past and it seemed to work fine, however in R when I call the function I get the following results (sorry for the output, but I think the important thing is the ). $header "Cols=712\rRows=712\rTotalX=712\rTotalY=712\rOffsetX=0\rOffsetY=0\rGridCornerUL=162 119\rGridCornerUR=5286 153\rGridCornerLR=5253 5270\rGridCornerLL=130 5237\rAxis-invertX=0\rAxisInvertY=0\rswapXY=0\rDatHeader=[0..65528] T1:CLS=5412 RWS=5412 XIN=2 YIN=2 VE=302.0 07/09/04 13:38:45 50101350 M10 \024 \024 Doe16s.1sq \024 \024 \024 \024 \024 \024 \024 \024 \024 6\rAlgorithm=Percentile\rAlgorithmParameters=Percentile:75;CellMargin:2;OutlierHigh:1.500;OutlierLow:1.004;AlgVersion:6.0;FixedCellSize:FALSE;IgnoreOutliersInShiftRows:FALSE;FeatureExtraction:FALSE;UseSubgrids:FALSE;RandomizePixels:FALSE;ErrorBasis:StdvMean;StdMult:1.00\r"> Ok, so then I thought to try something a little closer to how I did the INTEGER. So I used the following code: PROTECT(tmp = NEW_CHARACTER(1)); CHAR(tmp)[0] = *header.GetHeader().c_str(); SET_STRING_ELT(names, i, mkChar("header")); SET_VECTOR_ELT(vals, i++, tmp); UNPROTECT(1); Which in R returns the following: $header [1] "" So that is not working. So the question is: given a function in C/C++ which returns a const char* how do I correctly create an R character string/vector (terminology?) to set as a list element. Thanks for any advice or any particular parts of the R source tree which might be illuminating. Also, if anyone knows some shorter code for the above code which sets the INTEGER elements of the list that would be nice as well. Thanks in advance, Jim __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Re: [R] p-value > 1 in fisher.test()
> "UweL" == Uwe Ligges <[EMAIL PROTECTED]> > on Sat, 04 Jun 2005 11:43:34 +0200 writes: UweL> (Ted Harding) wrote: >> On 03-Jun-05 Ted Harding wrote: >> >>> And on mine >>> >>> (A: PII, Red Had 9, R-1.8.0): >>> >>> ff <- c(0,10,250,5000); dim(ff) <- c(2,2); >>> >>> 1-fisher.test(ff)$p.value >>> [1] 1.268219e-11 >>> >>> (B: PIII, SuSE 7.2, R-2.1.0beta): >>> >>> ff <- c(0,10,250,5000); dim(ff) <- c(2,2); >>> >>> 1-fisher.test(ff)$p.value >>> [1] -1.384892e-12 >> >> >> I have a suggestion (maybe it should also go to R-devel). >> >> There are many functions in R whose designated purpose is >> to return the value of a probability (or a probability >> density). This designated purpose is in the mind of the >> person who has coded the function, and is implicit in its >> usage. >> >> Therefore I suggest that every such function should have >> a built-in internal check that no probability should be >> less than 0 (and if the primary computation yields such >> a value then the function should set it exactly to zero), >> and should not exceed 1 (in which case the function should >> set it exactly to 1). [And, in view of recent echanges, >> I would suggest exactly +0, not -0!] >> >> Similar for any attempts to return a negative probability >> density; while of course a positive value can be allowed >> to be anything. >> >> All probabilities would then be guaranteed to be "clean" >> and issues like the Fisher exact test above would no longer >> be even a tiny problem. >> >> Implementing this in the possibly many cases where it is >> not already present is no doubt a long-term (and tedious) >> project. >> >> Meanwhile, people who encounter problems due to its absence >> can carry out their own checks and adjustments! UweL> [moved to R-devel] UweL> Ted, my (naive?) objection: UweL> Many errors in the underlying code have been detected by a function UweL> returning a nonsensical value, but if the probability is silently set to UweL> 0 or 1 ... UweL> Hence I would agree to do so in special cases where it makes sense UweL> because of numerical issues, but please not globally. I agree very much with Uwe's point. Further to fisher.test(): This whole thread is re-hashing a pretty recent bug report on fisher.test() { "negative p-values from fisher's test (PR#7801)", April '05} I think that only *because* of the obviously wrong P-values have we found and confirmed that the refereed and published code underlying fisher.test() is bogous. Such knowledge would have been harder to gain if the P-values would have been cut into [0,1]. Martin Maechler UweL> Uwe Ligges >> Best wishes to all, >> Ted. >> >> >> >> E-Mail: (Ted Harding) <[EMAIL PROTECTED]> >> Fax-to-email: +44 (0)870 094 0861 >> Date: 04-Jun-05 Time: 00:02:32 >> -- XFMail -- __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] documentation source diff...
On Sat, 4 Jun 2005, Uwe Ligges wrote: >Dan Bolser wrote: > >> Hi, I forgot the name of the function 'colSums', and expected to be able >> to find it through the 'see also' section of the documentation for the >> 'sum' function. > >Good idea, I think it might be worth to be added to ?apply as well. > > >> Here is the diff I made of the altered documentation to facilitate this >> action... (p.s. I made the diff on the R-2.1.0 source). >> >> >> diff sum.Rd src/library/base/man/sum.Rd --context=2 >> *** sum.Rd 2005-06-03 20:24:22.468224056 +0100 >> --- src/library/base/man/sum.Rd 2005-04-18 22:30:27.0 +0100 >> *** >> *** 33,38 >> Wadsworth \& Brooks/Cole. >> } >> - \seealso{ >> - \code{\code{\link{colSums}}. > >You don't want "\code" twice... > >Some suggestions for further contributions: > >- you want to use diff with option -u >- you want to use the original file as first argument and the changed >file as second argument to diff. Thanks very much for the info (don't know how I ended up '\code{\code{ing}}'!) I added your information here http://fawn.unibw-hamburg.de/cgi-bin/Rwiki.pl?DocEditHowTo Which is a bit of a mess ;) Cheers, Dan. > >Uwe Ligges > > > > >> - } >> \keyword{arith} >> --- 33,35 >> >> __ >> R-devel@stat.math.ethz.ch mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel > __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Re: [R] p-value > 1 in fisher.test()
(Ted Harding) wrote: On 03-Jun-05 Ted Harding wrote: And on mine (A: PII, Red Had 9, R-1.8.0): ff <- c(0,10,250,5000); dim(ff) <- c(2,2); 1-fisher.test(ff)$p.value [1] 1.268219e-11 (B: PIII, SuSE 7.2, R-2.1.0beta): ff <- c(0,10,250,5000); dim(ff) <- c(2,2); 1-fisher.test(ff)$p.value [1] -1.384892e-12 I have a suggestion (maybe it should also go to R-devel). There are many functions in R whose designated purpose is to return the value of a probability (or a probability density). This designated purpose is in the mind of the person who has coded the function, and is implicit in its usage. Therefore I suggest that every such function should have a built-in internal check that no probability should be less than 0 (and if the primary computation yields such a value then the function should set it exactly to zero), and should not exceed 1 (in which case the function should set it exactly to 1). [And, in view of recent echanges, I would suggest exactly +0, not -0!] Similar for any attempts to return a negative probability density; while of course a positive value can be allowed to be anything. All probabilities would then be guaranteed to be "clean" and issues like the Fisher exact test above would no longer be even a tiny problem. Implementing this in the possibly many cases where it is not already present is no doubt a long-term (and tedious) project. Meanwhile, people who encounter problems due to its absence can carry out their own checks and adjustments! [moved to R-devel] Ted, my (naive?) objection: Many errors in the underlying code have been detected by a function returning a nonsensical value, but if the probability is silently set to 0 or 1 ... Hence I would agree to do so in special cases where it makes sense because of numerical issues, but please not globally. Uwe Ligges Best wishes to all, Ted. E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 04-Jun-05 Time: 00:02:32 -- XFMail -- __ R-help@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-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] documentation source diff...
Dan Bolser wrote: Hi, I forgot the name of the function 'colSums', and expected to be able to find it through the 'see also' section of the documentation for the 'sum' function. Good idea, I think it might be worth to be added to ?apply as well. Here is the diff I made of the altered documentation to facilitate this action... (p.s. I made the diff on the R-2.1.0 source). diff sum.Rd src/library/base/man/sum.Rd --context=2 *** sum.Rd 2005-06-03 20:24:22.468224056 +0100 --- src/library/base/man/sum.Rd 2005-04-18 22:30:27.0 +0100 *** *** 33,38 Wadsworth \& Brooks/Cole. } - \seealso{ - \code{\code{\link{colSums}}. You don't want "\code" twice... Some suggestions for further contributions: - you want to use diff with option -u - you want to use the original file as first argument and the changed file as second argument to diff. Uwe Ligges - } \keyword{arith} --- 33,35 __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-devel