[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] 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

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] 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] 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] 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-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 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

[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] 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

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] 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] 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] 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] 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. __

[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] 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

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] 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] 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] 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] 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-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] 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-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] portable parallel seeds project: request for critiques

2012-03-02 Thread Petr Savicky
pdf using rngSetSeed for initialization of Mersenne-Twister is Method 4 in Section 6.1. I appreciate comments. Petr Savicky. P.S. I included some more comments on the relationship of provably good random number generators and P ?= NP question to the end of the page http://www.cs.cas.c

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
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] 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-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-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 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 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-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-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-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] 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] 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

[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] 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] 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] 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",

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] 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-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] 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] 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-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] 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] 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] 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] 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] 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-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-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-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] 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-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] 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] 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:

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

2009-12-13 Thread Petr Savicky
s a mismatch between code and documentation of testCoreNA(). Is the problem caused by having four entries in \usage{} section? Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

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

2009-12-14 Thread Petr Savicky
f the two outputs of R CMD check was [savi...@uivtx test]$ diff original modified 35c35,42 < * checking for code/documentation mismatches ... OK --- > * checking for code/documentation mismatches ... WARNING > Codoc mismatches from documen

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] 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] 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] choose(n,k) when n is almost integer

2009-12-22 Thread Petr Savicky
for integer n : 49.94785 maximum error for real n : bounderror [1,] 0e+00 2.047988e-09 [2,] 1e-20 2.699943e-08 [3,] 1e-15 3.444709e-08 [4,] 1e-10 2.806707e-08 [5,] 1e-05 8.395951e-09 [6,] 1e+00 1.205369e-11 [7,] Inf 2.731149e-14 We can see that B has smaller error, i

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-23 Thread Petr Savicky
ch C also does not modify lchoose(). It should be pointed out that choose(n, k) for non-integer n is mainly needed if n is a rational number like 1/2, 1/3, 2/3, However, making choose(n, k) accurate for all inputs seems to be not too complex as the patch C and its test results show. I appr

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

[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] choose(n,k) when n is almost integer

2010-02-02 Thread Petr Savicky
209 max rel err = 1.844756e-13 Patch C also passes make check-all in the current development version 2.11.0 (2010-02-01). I appreciate comments. 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] 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] .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? > >

[Rd] pure R code package for Windows

2007-04-28 Thread Petr Savicky
library/ and unzip it in the library directory on Windows machine. This works. The package behaves correctly. However, I do not think that this is a suggested method. Could you help me? Thank you in advance. Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] pure R code package for Windows

2007-04-30 Thread Petr Savicky
> You can also use the Windows binary build and check service at > http://129.217.207.166 after reading its disclaimer... Thank you very much. This worked including generating .chm file. The resulting package is installable under R GUI on Windows XP, which is sufficient for me. Let me point out

[Rd] grep with fixed=TRUE and ignore.case=TRUE

2007-05-07 Thread Petr Savicky
;TRUE', 'pattern' is a string to be matched as is. Overrides all conflicting arguments including ignore.case. All the best, Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] grep with fixed=TRUE and ignore.case=TRUE

2007-05-11 Thread Petr Savicky
On Wed, May 09, 2007 at 06:41:23AM +0100, Prof Brian Ripley wrote: > I suggest you collaborate with the person who replied that he thought this > was a good idea to supply patches against the R-devel sources for > scrutiny. A possible solution is to use strncasecmp instead of strncmp in function

Re: [Rd] Problem with rnorm ?

2007-05-12 Thread Petr Savicky
> #include > #include > > int main(void){ > double x[3]; > for(int i=0;i<3;i++) x[i]=rnorm(0,1); > printf("%lf,%lf,%lf",x[0],x[1],x[2]); > return 0; > } > > output : -8.773321,-8.773321,-8.773321 You probably have to call GetRNGstate() before rnorm and PutRNGstate() after. At least

Re: [Rd] grep with fixed=TRUE and ignore.case=TRUE

2007-05-17 Thread Petr Savicky
> strncasecmp is not standard C (not even C99), but R does have a substitute > for it. Unfortunately strncasecmp is not usable with multibyte charsets: > Linux systems have wcsncasecmp but that is not portable. In these days of > widespread use of UTF-8 that is a blocking issue, I am afraid.

Re: [Rd] R 2.5.0 refuses to print enough digits to recover exact floating point values

2007-05-23 Thread Petr Savicky
> > Well, okay, now what about dump, write.table, save, etc? > > save() uses the required precision. For exp(1) it stores > "2.718281828459045" and you will see that > > exp(1) == 2.718281828459045 is TRUE > save(...,ascii=TRUE) uses 16 digit precision, but this seems not to be sufficient. In

Re: [Rd] R 2.5.0 refuses to print enough digits to recover exact floating point values

2007-05-23 Thread Petr Savicky
This is an addition to my previous message. 16 digits are indeed not sufficient to represent a double value exactly. The next table is calculated in bc calculator. It shows that if we restrict (or round) double values to 16 decadic digits then from 4 to 5 consecutive distinct double values get the

[Rd] documented/undocumented behavior of as.double(formatC(x, digits=17))

2007-05-25 Thread Petr Savicky
Some days ago, there was a discussion about the command formatC(exp(1),digits=100,width=-1) Converting a double value to a string, from which the double may be reconstructed exactly, may be useful. So, I did some experimentation with it in my linux installation of R-2.5.0. I generated a vector

Re: [Rd] Determinant function (PR#9715)

2007-06-04 Thread Petr Savicky
> The function ''det'' works improperly for a singular matrix and returns a > non-zero value even if ''solve'' reports singularity. The matrix is very > simple > as shown below. > > A <- diag(rep(c(64,8), c(8,8))) > A[9:16,1] <- 8 > A[1,9:16] <- 8 > > det(A) > #[1] -196608 > solve(A) > #Error in

Re: [Rd] R 2.5.0 refuses to print enough digits to recover exact floating point values

2007-06-26 Thread Petr Savicky
I would like to reply to the following email from May in the thread [Rd] R 2.5.0 refuses to print enough digits to recover exact floating point values On Wed, May 23, 2007 at 06:32:36PM +0100, Prof Brian Ripley wrote: > I think this is a bug in the MacOS X runtime. I've checked the C99 > stand

[Rd] make check for 2.5.1 RC fails on mbcsToSbcs in graphics

2007-06-27 Thread Petr Savicky
configure and make run OK, but make check failed for R version 2.5.1 RC (2007-06-26 r42068) on graphics with error: > ## The following two examples use latin1 characters: these may not > ## appear correctly (or be omitted entirely). > plot(1:10, 1:10, main = "text(...) examples\n

Re: [Rd] inaccuracy in qbinom with partial argument matching

2007-06-29 Thread Petr Savicky
> > ## partial argument matching: > > qbinom(p0 , s = 3,p= 0.25) ## 1 ??? > > qbinom(p0-0.05, s = 3,p= 0.25) ## 1 ??? > > qbinom(p0-0.06, s = 3,p= 0.25) ## 0 o.K. > > > > Unfortunately I have no I idea how to fix this. > > You use a call that specifies your intention

Re: [Rd] make check for 2.5.1 RC fails on mbcsToSbcs in graphics

2007-06-30 Thread Petr Savicky
On Wed, Jun 27, 2007 at 04:20:39PM +0100, Prof Brian Ripley wrote: > But you can't really avoid it if you want to test non-ASCII > features: for example, you cannot test Latin-1 graphics in a C locale. > > It was intended that the postscript device opened for testing graphics was > opened with en

Re: [Rd] Shapiro Test P Value Incorrect? (PR#9768)

2007-07-06 Thread Petr Savicky
This is not a bug. The algorithm uses different approximation of the p-value for n=3 (exact value), 4<=n<=11 and n>=12 as seen in src/library/stats/src/swilk.c below the line 202 /* Calculate significance level for W */ The W statistic monotonically decreases in the presented example. Petr.

Re: [Rd] sweep sanity checking?

2007-07-12 Thread Petr Savicky
The suggestion sounds reasonable to me. Let me add that sweep is written to work even if MARGIN includes more than one dimension. To handle these cases correctly, the test may be replaced e.g. by if (check.margin && prod(dims[MARGIN])!=length(STATS)) { warning("length(STATS) != prod(dim

Re: [Rd] sweep sanity checking?

2007-07-12 Thread Petr Savicky
I am sorry for an incomplete proposal. The stricter check if (check.margin && any(dims[MARGIN]!=dimstat)) { was meant to be if (check.margin && (length(dimstat)!=length(MARGIN) || any(dims[MARGIN]!=dimstat))) { Petr. __ R-devel@r-project.org

Re: [Rd] sweep sanity checking?

2007-07-13 Thread Petr Savicky
I would like to suggest a replacement for the curent function sweep based on the two previous suggestions posted at https://stat.ethz.ch/pipermail/r-help/2005-June/073989.html and http://wiki.r-project.org/rwiki/doku.php?id=rdoc:base:sweep with some extensions. My suggestion is to use one of t

Re: [Rd] sweep sanity checking?

2007-07-25 Thread Petr Savicky
I would like to suggest a patch against R-devel-2007-07-24, which modifies function sweep by including a warning, if dim(STATS) is not consistent with dim(x)[MARGIN]. If check.margin=FALSE, the simple test whether prod(dim(x)[MARGIN]) is a multiple of length(STATS) is performed. If check.margin=TRU

Re: [Rd] sweep sanity checking?

2007-07-27 Thread Petr Savicky
Robin Hankin # https://stat.ethz.ch/pipermail/r-help/2005-June/074001.html by Heather Turner # https://stat.ethz.ch/pipermail/r-devel/2007-June/046217.html by Ben Bolker # with some further modifications by Petr Savicky sweep <- function(x, MARGIN, STATS, FUN = "-",

Re: [Rd] Optimization in R

2007-08-05 Thread Petr Savicky
parameter of optim could control, whether the function to be optimized is fn or the C entry point. Petr Savicky. > I don't have an example of that but that does not make it less > desirable. If one wants to use method 1, 2 or 3 then one can > use optim with a method= but if one wants to

Re: [Rd] Optimization in R

2007-08-05 Thread Petr Savicky
several, if derivatives are also available), similar as in the user defined random number generator. Then, a parameter of optim could control, whether the function to be optimized is fn or the C entry point. Petr Savicky. On Sat, Aug 04, 2007 at 06:56:47PM -0400, Gabor Grothendieck wrote: >

Re: [Rd] Optimization in R

2007-08-06 Thread Petr Savicky
Thank you for your response. This is a good idea. Although I use my own packages, some of them using other R API's, I missed the optimization ones. Thanks again. Petr Savicky. On Mon, Aug 06, 2007 at 07:16:11AM -0700, Thomas Lumley wrote: > On Mon, 6 Aug 2007, Petr Savicky wrote: >

Re: [Rd] sweep sanity checking?

2007-08-07 Thread Petr Savicky
the link http://www.cs.cas.cz/~savicky/R-devel/patch-sweep which is an identical copy. Petr Savicky. --- R-devel_2007-08-06/src/library/base/R/sweep.R 2007-07-27 17:51:13.0 +0200 +++ R

Re: [Rd] [Fwd: behavior of L-BFGS-B with trivial function triggers bug in stats4::mle]

2007-08-14 Thread Petr Savicky
with "L-BFGS-B". [snip] Could you also include a script, which reproduces the problem? Just to see under which conditions the problem occurs and how it looks like exactly. Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz

Re: [Rd] paste() with NAs .. change worth persuing?

2007-08-23 Thread Petr Savicky
other hand, factors are not typical in cases, where paste is used to produce a readable message. Hence, it could be possible to have is.na(u[i]) for those i, for which some of the vectors v1, ..., vn in u <- paste(v1,,vn) is a factor and has NA at i-th position. Petr Savicky. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

  1   2   >