Re: [Rd] portable parallel seeds project: request for critiques

2012-03-02 Thread Petr Savicky
ut, however, that the initialization by array from 2002 is more careful than the single number initialization, So, it is better to use the array initialization even for a single number seed. Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] portable parallel seeds project: request for critiques

2012-03-02 Thread Petr Savicky
or example, MD5 cannot be used for cryptography any more, since there are known algorithms to break it. However, if you use it for a simulation, then the simulation will be biased only if it contains an algorithm, which breaks MD5. The probability that this happens just by chance is small. Petr Sav

Re: [Rd] portable parallel seeds project: request for critiques

2012-03-02 Thread Petr Savicky
to the initial state of the generator using a function, for which we have a good guarantee that it produces output, which is computationally hard to distinguish from truly random numbers. For this purpose, i suggest to use the package rngSetSeed provided currently at http://www.cs.cas.cz/~sav

Re: [Rd] portable parallel seeds project: request for critiques

2012-02-22 Thread Petr Savicky
On Wed, Feb 22, 2012 at 12:17:25PM -0600, Paul Johnson wrote: [...] > In order for this to be easy for users, I need to put the init streams > and set current stream functions into a package, and then streamline > the process of creating the seed array. My opinion is that CRAN is > now overflowed

Re: [Rd] OpenMP and random number generation

2012-02-22 Thread Petr Savicky
on but didn't find any information about > that. Package CORElearn (i am a coauthor) uses random number generation under OpenMP in C++. This requires to have a separate copy of the generator with its own memory for each thread. Do you want to use

Re: [Rd] portable parallel seeds project: request for critiques

2012-02-21 Thread Petr Savicky
<- runif(n) set.seed(seed2) y <- runif(n) rbind(seed1, seed2) table(x[-1] == y[-n]) The output is [,1] seed1 124370417 seed2 205739774 FALSE TRUE 5 994 This means that if the streams x, y are generated from the two seeds above, then y is

Re: [Rd] portable parallel seeds project: request for critiques

2012-02-18 Thread Petr Savicky
can compute s_{i,j} by an efficient algorithm. > The different thing in my approach is that I'm saving one row of seeds > per simulation "run". So each run can be replicated exactly. > > I hope. Saving .Random.seed should be a safe strategy. Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] portable parallel seeds project: request for critiques

2012-02-17 Thread Petr Savicky
lization using the vector c(seed, i, j) is done with a good quality hash function, the runs will be independent. What is your opinion on this? An advantage of seeding with a vector is also that there can be significantly more initial states of the generator among which we select by the seed than 2^32, which is the maximum for a single integer seed. Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] matrix not positive definite (while it should be)

2011-05-06 Thread Petr Savicky
N], which consists of replicated components of X, has the expanded covariance matrix n times n, which you ask for. Since the mean and the covariance matrix determine the distribution uniquely, this is also a description of the required distribution. The distr

Re: [Rd] Dangerous Bug with IF function of R

2011-04-18 Thread Petr Savicky
1 it doesn't work!!! > please try it it is amazing!!! Incrementing a number by 0.1 produces numbers, which are not exactly representable in binary, so this operation involves a rounding error. Try the following q=0 for (j in 1:11){ if ((q==1)){ print(q) }

Re: [Rd] duplicates() function

2011-04-12 Thread Petr Savicky
t;- 1000 n <- 4 a <- matrix(as.character(sample(10, m*n, replace=TRUE)), nrow=m, ncol=n) system.time(out1 <- duplicatedSort(a)) system.time(out2 <- duplicated(a)) identical(out1, out2) table(out1) I obtained, for example, user system elapsed 0.003 0.000 0.003

Re: [Rd] duplicates() function

2011-04-09 Thread Petr Savicky
in first.occ are those, which are required for the output of duplicates(), but they are in the order of the sorted "dat". The last line first.occ[order(s)] reorders the vector to the original order of the rows. Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

[Rd] testing presence of pdflatex in R CMD check

2011-03-25 Thread Petr Savicky
s or index ... ERROR Re-running with no redirection of stdout/stderr. Hmm ... looks like a package You may want to clean up by 'rm -rf /tmp/RtmpQ0WawT/Rd2pdf41481e1' Is it intentional not to test the presence of pdflatex during R CMD check? Petr Savicky. __

Re: [Rd] round, unique and factor

2011-03-21 Thread Petr Savicky
to a factor, then back at the very end. Because it is a bigger change > the potential for breakage is higer, however. Can you describe the error in more detail? Is it related to consistency of converting a number to character and back? Petr Savicky. __

Re: [Rd] unique.matrix issue [Was: Anomaly with unique and match]

2011-03-12 Thread Petr Savicky
elative differences in x, but if the mantissa begins with 9, then a smaller relative difference is sufficient to change 15-th digit. In terms of unique(), this implies nrow(unique(cbind(x))) [1] 2 nrow(unique(cbind(9*x))) [1] 4 Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] unique.matrix issue [Was: Anomaly with unique and match]

2011-03-10 Thread Petr Savicky
on(a) { temp <- apply(a, 2, rank, ties.method="max") temp <- apply(temp, 1, function(x) paste(x, collapse = "\r")) a[!duplicated(temp), , drop=FALSE] } unique.mat(a) [,1] [,2] 112 312 512 712 Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] Anomaly with unique and match

2011-03-09 Thread Petr Savicky
g rank(). For example, temp3 <- as.matrix(rank(temp1, ties.method="max")) match(temp3, unique(temp3)) [1] 1 2 3 4 4 5 6 7 7 7 6 6 6 8 8 8 6 6 6 9 9 9 6 6 Can this be used in your code? Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] error in memCompress() in make check

2011-02-22 Thread Petr Savicky
On Tue, Feb 22, 2011 at 01:38:07PM +0100, Petr Savicky wrote: ... > The commands > > txt <- readLines(file.path(R.home("doc"), "COPYING")) > txt.xz <- memCompress(txt, "x") > > do not produce an error, if the compiled R runs in the s

Re: [Rd] error in memCompress() in make check

2011-02-22 Thread Petr Savicky
t;), "COPYING")) txt.xz <- memCompress(txt, "x") do not produce an error, if the compiled R runs in the same shell, where "make check" was run. However, they produce the error, if R is started in a new shell. The command find /usr -name "liblzma*" has empty outp

[Rd] error in memCompress() in make check

2011-02-22 Thread Petr Savicky
TF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base gcc --version gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46) Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] R command line and pipe using in Linux?

2011-02-14 Thread Petr Savicky
of the output is formulated there. Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] print(...,digits=2) behavior

2011-02-13 Thread Petr Savicky
example3 <- c( 1.004999, 1.005001) for (x in example3) print(x, digits=7) [1] 1 [1] 1.01 example4 <- c( 9.994999, 9.995001) for (x in example4) print(x, digits=7) [1] 9.99 [1] 10 I appr

Re: [Rd] R 2.12.1 Windows 32bit and 64bit - are numerical differences expected?

2011-02-10 Thread Petr Savicky
On Thu, Feb 10, 2011 at 10:37:09PM +1100, Graham Williams wrote: > Should one expect minor numerical differences between 64bit and 32bit R on > Windows? Hunting around the lists I've not been able to find a definitive > answer yet. Seems plausible using different precision arithmetic, but waned > t

Re: [Rd] print(...,digits=2) behavior

2011-02-09 Thread Petr Savicky
uggestion only and the actual number of printed digits may be smaller, if the relative error of the output number is less than 10^-digits. Use 'signif(, digits)' before printing to get the exact number of the printed significant digits. I appreciate to know the opinion of R developers on this. Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] print(...,digits=2) behavior

2011-02-07 Thread Petr Savicky
ounded to a single digit are (8 - 7.921)/7.921 [1] 0.009973488 (8 - 7.92)/7.92 [1] 0.01010101 In the first case, this is less than 10^-2 and so, l = 1 is used. In the second case, the relative error for l = 1 is larger than 10^-2 an so, l = 2 is chosen. In the cases

Re: [Rd] Wait for user input with readline()

2010-12-07 Thread Petr Savicky
s interactive. If readline() is not the last line of the code, then the next line of code is used instead of the user input. Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] opening graphics device with a given number

2010-11-13 Thread Petr Savicky
ice 6 >26 The function devSet() works fine and i will use it. Thank you very much for this information. Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

[Rd] opening graphics device with a given number

2010-11-13 Thread Petr Savicky
Usually, i use an interval of the device numbers, but sometimes, it could be useful to open, say, device 4, even if device 3 is not needed. Is there a way, how to open a device with a given number without opening devices with smaller numbers? Petr Savicky. ___

Re: [Rd] .Call and .C arguments

2010-03-29 Thread Petr Savicky
on exactly. So, already at the R level is, actually formatC(1204.245, digits=20) # [1] "1204.24498909" See http://rwiki.sciviews.org/doku.php?id=misc:r_accuracy or FAQ 7.31 for more examples. Petr Savicky. > > Is there a way to pass the arguments differently? > >

Re: [Rd] Associative array?

2010-03-11 Thread Petr Savicky
ally does not keep the exact value and performs some rounding. However, conversion of a double x to character type, which preserves the number exactly, may be obtained, for example, using formatC(x, digits=17, width=-1) Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] choose(n,k) when n is almost integer

2010-02-03 Thread Petr Savicky
On Tue, Feb 02, 2010 at 01:37:46PM +0100, Petr Savicky wrote: > I would like to add some more information concerning the patch C > to the function choose() proposed in the email > https://stat.ethz.ch/pipermail/r-devel/2009-December/056177.html > > The patch uses transformations

Re: [Rd] choose(n,k) when n is almost integer

2010-02-02 Thread Petr Savicky
I would like to add some more information concerning the patch C to the function choose() proposed in the email https://stat.ethz.ch/pipermail/r-devel/2009-December/056177.html The patch uses transformations of choose(n, k), which are described in http://www.cs.cas.cz/~savicky/R-devel

[Rd] missing R-devel/po

2010-01-06 Thread Petr Savicky
irectory "R-devel/po" at https://svn.r-project.org/R/trunk/, so the problem could be just temporary. Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] seq.int broken (seq as well) (PR#14169)

2009-12-31 Thread Petr Savicky
umerically equal to an) integer and, e.g., only 'to' is specified, or also if only 'length' or only 'along.with' is specified. *Note:* this may change in the future and programmers should not rely on it. This sugge

Re: [Rd] choose(n,k) when n is almost integer

2009-12-23 Thread Petr Savicky
obtained sometimes from the original implementation and which is more accurate in all ranges of the output. For testing patch C a simpler script is sufficient, since we need not to take care of the warnings. Namely http://www.cs.cas.cz/~savicky/R-devel/test_choose_1.R which produces the output (the

Re: [Rd] choose(n,k) when n is almost integer

2009-12-22 Thread Petr Savicky
ort, which is missing on my computer. The test was run both with Intel extended and SSE arithmetic. Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] choose(n,k) when n is almost integer

2009-12-22 Thread Petr Savicky
from choose() and the intention of this patch is not to change this. Most of these warnings are eliminated in the original implementation by treating numbers, which differ from an integer by less than 1e-7, as integers. However, there are some such cases even if the difference is slightly larger than 1e

Re: [Rd] a little bug for the function 'sprintf' (PR#14161)

2009-12-21 Thread savicky
> When you type in the example codes: > > > sprintf("%s is %f feet tall\n", "Sven", 7.1) > > and R returns: > > [1] "Sven is 7.10 feet tall\n" > > this is very different from the 'sprintf' function in C/C++, for in C/C++, > the format string "\n" usually represents a new line, but here, jus

Re: [Rd] RFC: lchoose() vs lfactorial() etc

2009-12-17 Thread Petr Savicky
002 1.035 So, the jump in the exactly integer value n[16] == 5 is comparable to machine accuracy. I would be pleased to provide more tests, if some of the above solutions or their modifications can be accepted. Petr Savicky. --- R-devel_2009-12-16/src/nmath/choose.c

Re: [Rd] RFC: lchoose() vs lfactorial() etc

2009-12-15 Thread Petr Savicky
992673 -3.5992673 [6,] -0.020507812NaN -3.8869494 [7,] 0.016113281 -4.1281114 -4.1281114 [8,] -0.013092041 NaN -4.3357508 [9,] 0.010910034 -4.5180723 -4.5180723 [10,] -0.009273529NaN -4.6805913 Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] Accuracy (PR#14139)

2009-12-14 Thread savicky
igits=4) # [1] 0.9131 I do not know the history of the R printing algorithm. It is designed primarily for printing vectors, where the rules are more complicated to achieve a good unified format for all numbers. May be, someone else can say more about it. The above analysis may b

Re: [Rd] Accuracy (PR#14139)

2009-12-14 Thread Petr Savicky
igits=4) # [1] 0.9131 I do not know the history of the R printing algorithm. It is designed primarily for printing vectors, where the rules are more complicated to achieve a good unified format for all numbers. May be, someone else can say more about it. The above analysis may b

Re: [Rd] R CMD check may not detect a code/documentation mismatch

2009-12-14 Thread Petr Savicky
e current R-devel and run "make" and "make check" (both OK) and compared the output of R CMD check XML_2.6-0.tar.gz R CMD check randomForest_4.5-33.tar.gz R CMD check tree_1.0-27.tar.gz R CMD check survival_2.35-7.tar.gz with R being both original R-devel and the modified on

[Rd] R CMD check may not detect a code/documentation mismatch

2009-12-13 Thread Petr Savicky
For the package at http://www.cs.cas.cz/~savicky/R-devel/something_0.0.0.tar.gz which is a minor part of some other package only to demonstrate the problem, i get (under R version 2.11.0 Under development 2009-12-12 r50714 and also under R-2.9.2, openSUSE 11.1 (x86_64) and CentOS release 5.2

Re: [Rd] cor.test(method = spearman, exact = TRUE) not exact (PR#14095)

2009-11-30 Thread Petr Savicky
On Mon, Nov 30, 2009 at 04:00:12AM +0100, dsim...@gmail.com wrote: > > a <- c(1:10) > > b <- c(1:10) > > cor.test(a, b, method = "spearman", alternative = "greater", exact = TRUE) > > Spearman's rank correlation rho > > data: a and b > S = 0, p-value < 2.2e-16 > alternative hypothesis:

Re: [Rd] Unexpected behaviour of seq(from,to,by) (PR#14057)

2009-11-11 Thread Petr Savicky
So, we have formatC(V[7], digits=20) # [1] "0.60008882" formatC(0.6, digits=20) # [1] "0.5999778" See http://wiki.r-project.org/rwiki/doku.php?id=misc:r_accuracy for more examples and explanations. Petr Savicky. > V[8] > # [1] 0.7 > V[8

Re: [Rd] identical(0, -0)

2009-08-22 Thread Petr Savicky
On Sat, Aug 22, 2009 at 12:00:44AM +0200, Martin Maechler wrote: > I have taken up the issue now, > and after thinking, studying the source, trying to define a > 'method = ' argument, came to the conclusion that both > the implementation and documentation (and source code "self-explanation") > are

Re: [Rd] user supplied random number generators

2009-08-18 Thread Petr Savicky
r message in a private email (as was also the email you were replying to). Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] identical(0, -0)

2009-08-12 Thread Petr Savicky
On Wed, Aug 12, 2009 at 04:02:28PM +0200, Martin Maechler wrote: > >>>>> "PS" == Petr Savicky > >>>>> on Wed, 12 Aug 2009 13:50:46 +0200 writes: > > PS> Let me add the following to the discussion of identical(0, -0). > PS>

Re: [Rd] identical(0, -0)

2009-08-12 Thread Petr Savicky
Let me add the following to the discussion of identical(0, -0). I would like to suggest to replace the paragraph 'identical' sees 'NaN' as different from 'NA_real_', but all 'NaN's are equal (and all 'NA' of the same type are equal). in ?identical by the following text, which is a correction

Re: [Rd] identical(0, -0)

2009-08-11 Thread Petr Savicky
On Tue, Aug 11, 2009 at 10:04:20AM +0200, Martin Maechler wrote: > > "DM" == Duncan Murdoch > > on Mon, 10 Aug 2009 11:51:53 -0400 writes: > > DM> For people who want to play with these, here are some functions that > let > DM> you get or set the "payload" value in a NaN. N

Re: [Rd] identical(0, -0)

2009-08-10 Thread Petr Savicky
On Mon, Aug 10, 2009 at 05:47:57AM -0400, Duncan Murdoch wrote: > I wouldn't mind a "strict" option. It would compare bit patterns, so > would distinguish +0 from -0, and different NaN values. I think that a logical option "strict" in the above meaning could be useful for debugging. The default

Re: [Rd] identical(0, -0)

2009-08-10 Thread Petr Savicky
On Sat, Aug 08, 2009 at 10:39:04AM -0400, Prof. John C Nash wrote: > I'll save space and not include previous messages. > > My 2 cents: At the very least the documentation needs a fix. If it is > easy to do, then Ted Harding's suggestion of a switch (default OFF) to > check for sign difference w

Re: [Rd] Accuracy (PR#13867)

2009-08-04 Thread Petr Savicky
On Tue, Aug 04, 2009 at 04:25:09PM +0200, lueth...@student.ethz.ch wrote: > Hi > > I created the following vectors: > > p_1=c(0.2,0.2,0.2,0.2,0.1,0.25,0.4,0.1,0.25,0.4,0.1,0.25,0.4,0.1,0.25,0.4,0.2,0.5,0.8,0.2,0.5,0.8,0.2,0.5,0.8,0.2,0.5,0.8) > p_2=c(0,0,0,0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.

Re: [Rd] incorrect result (41/10-1/10)%%1 (PR#13863)

2009-08-03 Thread Petr Savicky
> I get an incorrect result for > > (41/10-1/10)%%1 > > [1] 1 Note that due to rounding errors, 41/10-1/10 is formatC(41/10-1/10, digits=20) # [1] "3.9995559" Besides FAQ 7.31, related information may be found also at http://wiki.r-project.org/rwiki/doku.php?id=misc:r_accuracy

Re: [Rd] factor() calls sort.list unnecessarily?

2009-07-05 Thread Petr Savicky
On Fri, Jul 03, 2009 at 07:57:49AM -0700, Martin Morgan wrote: [...] > sort.list is always called but used only to determine the order of > levels, so unnecessary when levels are provided. I think, this is correct. Replacing ind <- sort.list(x) by if (missing(levels)) ind <- sort.list(x

Re: [Rd] read.csv

2009-06-25 Thread Petr Savicky
I am sorry for not including the attachment mentioned in my previous email. Attached now. Petr. --- R-devel/src/library/utils/R/readtable.R 2009-05-18 17:53:08.0 +0200 +++ R-devel-readtable/src/library/utils/R/readtable.R 2009-06-25 10:20:06.0 +0200 @@ -143,9 +143,6 @@

Re: [Rd] read.csv

2009-06-25 Thread Petr Savicky
On Sun, Jun 14, 2009 at 02:56:01PM -0400, Gabor Grothendieck wrote: > If read.csv's colClasses= argument is NOT used then read.csv accepts > double quoted numerics: > > 1: > read.csv(stdin()) > 0: A,B > 1: "1",1 > 2: "2",2 > 3: > A B > 1 1 1 > 2 2 2 > > However, if colClasses is used then it se

Re: [Rd] read.csv

2009-06-16 Thread Petr Savicky
On Sun, Jun 14, 2009 at 09:21:24PM +0100, Ted Harding wrote: > On 14-Jun-09 18:56:01, Gabor Grothendieck wrote: > > If read.csv's colClasses= argument is NOT used then read.csv accepts > > double quoted numerics: > > > > 1: > read.csv(stdin()) > > 0: A,B > > 1: "1",1 > > 2: "2",2 > > 3: > > A B

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-31 Thread Petr Savicky
On Sat, May 30, 2009 at 07:32:52PM +0200, Martin Maechler wrote: > > "vQ" == Wacek Kusnierczyk > > on Sat, 30 May 2009 11:16:43 +0200 writes: [...] > vQ> one simple way to improve the code is as follows; instead of > (simplified) > > vQ> const char* dropTrailing(const char

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-29 Thread Petr Savicky
On Fri, May 29, 2009 at 03:53:02PM +0200, Martin Maechler wrote: > my version of *using* the function was > > 1 SEXP attribute_hidden StringFromReal(double x, int *warn) > 2 { > 3 int w, d, e; > 4 formatReal(&x, 1, &w, &d, &e, 0); > 5 if (ISNA(x)) return NA_STRING; > 6 else return mkChar(d

Re: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-28 Thread Petr Savicky
On Wed, May 27, 2009 at 10:51:38PM +0200, Martin Maechler wrote: > I have very slightly modified the changes (to get rid of -Wall > warnings) and also exported the function as Rf_dropTrailing0(), > and tested the result with 'make check-all' . Thank you very much for considering the patch. -Wall

Re: [Rd] inconsistency in ?factor

2009-05-25 Thread Petr Savicky
On Mon, May 25, 2009 at 03:58:06PM +0800, Berwin A Turlach wrote: > Well, the first statement is a remark on comparison in general while > the second statement is specific to "comparison operators and generic > methods". There are other ways of comparing objects; note: > > R> f1 <- factor(c("a",

[Rd] inconsistency in ?factor

2009-05-25 Thread Petr Savicky
In the almost current development version (2009-05-22 r48594) and also in https://svn.r-project.org/R/trunk/src/library/base/man/factor.Rd ?factor contains (compare the formulations marked by ^^) \section{Warning}{ The interpretation of a factor depends on both the codes and the \code{"

Re: [Rd] qbinom (PR#13711)

2009-05-23 Thread Petr Savicky
On Wed, May 20, 2009 at 11:10:11PM +0200, wolfgang.re...@gmail.com wrote: ... > Strange behavior of qbinom: > > > qbinom(0.01, 5016279, 1e-07) > [1] 0 > > qbinom(0.01, 5016279, 2e-07) > [1] 16 > > qbinom(0.01, 5016279, 3e-07) > [1] 16 > > qbinom(0.01, 5016279, 4e-07) > [1] 16 > > qbinom(0.01, 5016

[Rd] as.numeric(levels(factor(x))) may be a decreasing sequence

2009-05-23 Thread Petr Savicky
Function factor() in the current development version (2009-05-22) guarantees that levels are different character strings. However, they may represent the same decimal number. The following example is derived from a posting by Stavros Macrakis in thread "Match .3 in a sequence" in March nums <- 0

Re: [Rd] Spearman's rank correlation test (PR#13574)

2009-05-15 Thread Petr Savicky
Bug report "Spearman's rank correlation test (PR#13574)" was moved to trashcan with empty Notes field. I would like to learn, what was wrong with this bug report. Can i ask the developers to add a note to it? Thank you in advance. Petr. __ R-devel@r-pr

Re: [Rd] simple add error (PR#13699)

2009-05-13 Thread Petr Savicky
On Wed, May 13, 2009 at 02:35:12PM +0200, gos...@igmm.cnrs.fr wrote: > I cannot explain why R seems to have problems adding two big numbers. > > sprintf("%f",10^4+10^19) gives "10010240.00" > instead of "1001.00" > > problems seems to arriv

Re: [Rd] suggestion for extending ?as.factor

2009-05-12 Thread Petr Savicky
On Mon, May 11, 2009 at 05:06:38PM +0200, Martin Maechler wrote: > The version I have committed a few hours ago is indeed a much > re-simplified version, using as.character(.) explicitly The current development version (2009-05-11 r48528) contains in ?factor a description of levels parametr le

Re: [Rd] suggestion for extending ?as.factor

2009-05-11 Thread Petr Savicky
On Mon, May 11, 2009 at 05:06:38PM +0200, Martin Maechler wrote: [...] > The version I have committed a few hours ago is indeed a much > re-simplified version, using as.character(.) explicitly > and consequently no longer providing the extra optional > arguments that we have had for a couple of da

Re: [Rd] suggestion for extending ?as.factor

2009-05-10 Thread Petr Savicky
On Sat, May 09, 2009 at 10:55:17PM +0200, Martin Maechler wrote: [...] > If'd revert to such a solution, > we'd have to get back to Peter's point about the issue that > he'd think table(.) should be more tolerant than as.character() > about "almost equality". > For compatibility reasons, we could

Re: [Rd] suggestion for extending ?as.factor

2009-05-08 Thread Petr Savicky
On Fri, May 08, 2009 at 06:48:40PM +0200, Martin Maechler wrote: > >>>>> "PS" == Petr Savicky > >>>>> on Fri, 8 May 2009 18:10:56 +0200 writes: [...] > PS> ... I have > PS> strong objections against the existing implementatio

Re: [Rd] suggestion for extending ?as.factor

2009-05-08 Thread Petr Savicky
On Fri, May 08, 2009 at 05:14:48PM +0200, Petr Savicky wrote: > Let me suggest to consider the following modification, where match() is done > on the strings, not on the original values. > levels <- unique(as.character(sort(unique(x > x <- as.character(x) > f &l

Re: [Rd] suggestion for extending ?as.factor

2009-05-08 Thread Petr Savicky
On Fri, May 08, 2009 at 03:18:01PM +0200, Martin Maechler wrote: > As long as we don't want to allow factor() to fail --rarely -- > I think (and that actually has been a recurring daunting thought > for quite a few days) that we probably need an > extra step of checking for duplicate levels, and

Re: [Rd] suggestion for extending ?as.factor

2009-05-08 Thread Petr Savicky
On Wed, May 06, 2009 at 10:41:58AM +0200, Martin Maechler wrote: > PD> I think that the real issue is that we actually do want almost-equal > PD> numbers to be folded together. > > yes, this now (revision 48469) will happen by default, using signif(x, 15) > where '15' is the default f

Re: [Rd] suggestion for extending ?as.factor

2009-05-07 Thread Petr Savicky
On Wed, May 06, 2009 at 10:41:58AM +0200, Martin Maechler wrote: > PD> I think that the real issue is that we actually do want almost-equal > PD> numbers to be folded together. > > yes, this now (revision 48469) will happen by default, using signif(x, 15) > where '15' is the default f

Re: [Rd] suggestion for extending ?as.factor

2009-05-05 Thread Petr Savicky
On Tue, May 05, 2009 at 11:27:36AM +0200, Peter Dalgaard wrote: > I know. The point was rather that if you are not careful with rounding, > you get the some of the bars wrong (you get 2 or 3 small bars very close > to each other instead of one longer one). Computed p values from > permutation tests

Re: [Rd] suggestion for extending ?as.factor

2009-05-05 Thread Petr Savicky
On Mon, May 04, 2009 at 07:28:06PM +0200, Peter Dalgaard wrote: > Petr Savicky wrote: > > For this, we get > > > > > convert(0.3) > > [1] "0.3" > > > convert(1/3) > > [1] "0." # 16 digits suf

Re: [Rd] suggestion for extending ?as.factor

2009-05-04 Thread Petr Savicky
On Mon, May 04, 2009 at 05:39:52PM +0200, Martin Maechler wrote: [snip] > Let me quickly expand the tasks we have wanted to address, when > I started changing factor() for R-devel. > > 1) R-core had unanimously decided that R 2.10.0 should not allow >duplicated levels in factors anymore. > >

[Rd] suggestion for extending ?as.factor

2009-05-03 Thread Petr Savicky
In R-2.10.0, the development version, function as.factor() uses 17 digit precision for conversion of numeric values to character type. This is very good for the consistency of the resulting factor, however, i expect that people will complain about, for example, as.factor(0.3) being [1] 0.2999

Re: [Rd] 'is.integer' (PR#13671)

2009-04-23 Thread Petr Savicky
On Thu, Apr 23, 2009 at 11:37:37AM +0200, Martin Maechler wrote: [snip] > TP> To test whether a value is an integer value, you can so something > like this: > > >> is.wholenumber <- function(x, tolerance = .Machine$double.eps^0.5) > TP> return(abs(x - round(x)) < tolerance) > >>

Re: [Rd] 'is.integer' (PR#13671)

2009-04-23 Thread Petr Savicky
On Wed, Apr 22, 2009 at 04:30:36PM -0400, Stavros Macrakis wrote: [snip] > Now consider 1e40, which has the property > that floor(x)==x==ceiling(x), which you might think characterizes an > integer; but it also has the property that x+1 == x. Similarly for > 1/3 * 1e40. [snip] The number 1/3 * 1

Re: [Rd] Error in FrF2 example on Mac OS

2009-03-24 Thread Petr Savicky
On Tue, Mar 24, 2009 at 07:41:31AM -0700, Ulrike Grömping wrote: > > Probably, k is needed also later. Assumig that 2^k works correctly, > > the following could be sufficient > > > >if (!is.null(nruns)){ > > k <- round(log2(nruns)) > > if (!2^k==nruns) stop("nruns must be a power o

Re: [Rd] Error in FrF2 example on Mac OS

2009-03-24 Thread Petr Savicky
On Tue, Mar 24, 2009 at 02:45:57PM +0100, Uwe Ligges wrote: > >gives the custom error message "nruns must be a power of 2.", which is > >generated in the first check within function FrF2: > > > >if (!is.null(nruns)){ > > k <- floor(log2(nruns)) > > if (!2^k==nruns) stop("nruns must

Re: [Rd] Match .3 in a sequence

2009-03-17 Thread Petr Savicky
On Tue, Mar 17, 2009 at 10:04:39AM -0400, Stavros Macrakis wrote: ... > 1) Factor allows repeated levels, e.g. factor(c(1),c(1,1,1)), with no > warning or error. Yes, this is a confusing behavior, since repeated levels are never meaningful. > 2) Even from distinct inputs, factor of a numeric vect

Re: [Rd] Match .3 in a sequence

2009-03-17 Thread Petr Savicky
On Tue, Mar 17, 2009 at 10:15:39AM +0100, Wacek Kusnierczyk wrote: ... > there's one more curiosity about factors, in particular, ordered factors: > > ord <- as.ordered(nums); ord > # [1] 0.300 0.3 0.3 > 0.300 > # Levels: 0.30

Re: [Rd] Match .3 in a sequence

2009-03-16 Thread Petr Savicky
On Mon, Mar 16, 2009 at 07:39:23PM -0400, Stavros Macrakis wrote: ... > Let's look at the extraordinarily poor behavior I was mentioning. Consider: > > nums <- (.3 + 2e-16 * c(-2,-1,1,2)); nums > [1] 0.3 0.3 0.3 0.3 > > Though they all print as .3 with the default precision (which is > normal and

Re: [Rd] Match .3 in a sequence

2009-03-16 Thread Petr Savicky
On Mon, Mar 16, 2009 at 06:36:53AM -0700, Daniel Murphy wrote: > Hello:I am trying to match the value 0.3 in the sequence seq(.2,.3). I get > > 0.3 %in% seq(from=.2,to=.3) > [1] FALSE As others already pointed out, you should use seq(from=0.2,to=0.3,by=0.1) to get 0.3 in the sequence. In order to

[Rd] Spearman's rank correlation test (PR#13574)

2009-03-05 Thread savicky
Full_Name: Petr Savicky Version: 2.7.2, 2.8.1, 2.9.0 OS: Linux Submission from: (NULL) (147.231.6.9) The p-value of Spearman's rank correlation test is calculated in cor.test(x, y, method="spearman") using algorithm AS 89. However, the way how AS 89 is used incures error, which

Re: [Rd] invalid comparison in numeric sequence (PR#13551)

2009-02-25 Thread Petr Savicky
> > seq(0,1,0.1)==0.4 > [1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE > > seq(0,1,0.1)==0.6 > [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE > > seq(0,1,0.1)==0.8 > [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE > > What is w

[Rd] Spearman's rank correlation test

2009-02-12 Thread Petr Savicky
Hi All: help(cor.test) claims For Spearman's test, p-values are computed using algorithm AS 89. Algorithm AS 89 was introduced by the paper D. J. Best & D. E. Roberts (1975), Algorithm AS 89: The Upper Tail Probabilities of Spearman's rho. Applied Statistics, Vol. 24, No. 3, 377-379. Table

Re: [Rd] bug in cor.test(method = "spearman")

2009-01-26 Thread Petr Savicky
Hi All: The p-value of Spearman's rank correlation test is calculated using algorithm AS 89. However, the way how AS 89 is used incures error, which may be an order of magnitude larger than the error of the original algorithm. In case of no ties AS 89 expects an even value of the statistic S =

[Rd] bug in cor.test(method = "spearman")

2009-01-17 Thread savicky
Dear R developers: There is a possible bug in calculating the p-value for Spearman's rank correlation. Line 155 in file R-patched/src/library/stats/R/cor.test.R is as.double(round(q) + lower.tail), I think, it should be as.double(round(q) + 2*lower.tail), The reason is that round(q)

[Rd] bug in detection of zero state for Mersenne Twister (PR#10362)

2007-10-22 Thread savicky
Full_Name: Petr Savicky Version: all versions starting from 1.7.0 OS: observed on Linux, but is platform independent Submission from: (NULL) (62.24.91.47) The function runif(n) contains a protection against the zero state of Mersenne Twister stored in .Random.seed. If the state is zero, it is

[Rd] predictable bit patterns in runif(n) shortly after set.seed

2007-10-17 Thread Petr Savicky
nd the patch to R-devel, if the proposed solution is of the sort, which could be considered. Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

[Rd] all zeroes in Mersenne Twister state may remain undetected

2007-10-15 Thread Petr Savicky
mp; 0x8000) != 0); + if(!notallzero) + for (j = 2; j <= 624; j++) if(RNG_Table[RNG_kind].i_seed[j] != 0) { notallzero = 1; break; Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

[Rd] as.integer(x) versus as.integer(trunc(x))

2007-10-12 Thread Petr Savicky
5 [3,] 2147483646.0 2147483646 2147483646 [4,] 2147483646.5 2147483646 2147483646 [5,] 2147483647.0 2147483647 2147483647 [6,] 2147483647.5 2147483647 2147483647 [7,] 2147483648.0 NA NA Petr Savicky. __ R-devel@r-project.o

Re: [Rd] modifying large R objects in place

2007-09-29 Thread Petr Savicky
rol of duplication could help. The tools may be, for example, some function, which allows a simple query to the NAMED status of a given object on R level and modifying some of the built-in functions to be more careful with NAMED attribute. A possible strengthening of gc() would, of course, be very useful here. I think about an explicit use of it, not about the automatical runs. So, for safety reasons, the "NAMED reduction" could be done by a different function, not the default gc() itself. Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] modifying large R objects in place

2007-09-28 Thread Petr Savicky
n NAMED may be dropped from 2 to 1? How much would this increase the complexity of gc()? Thank you in advance for your kind reply. Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] modifying large R objects in place

2007-09-27 Thread Petr Savicky
a <- matrix(1:6,nrow=2) nrow(a,a) # Error in nrow(a, a) : unused argument(s) (1:6) dim(a,a) # Error: 2 arguments passed to 'dim' which requires 1 May be, also other solutions exist. Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

  1   2   >