Re: [Rd] Reset an embedded R.dll
On Thu, 15 May 2008 06:04:51 -, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: Last question: Will I need to UNPROTECT_PTR all references held, or will the call to Rf_endEmbeddedR also free protected references? What is a 'reference' here? Right, my question was imprecise. I meant 'SEXP' (which is a reference/pointer to a SEXPREC, as far as I understand it). Rf_endEmbeddedR does what ending an R session does, no more, no less. Ok - my question put differently: Will ending an R session run a full garbage collection, ignoring the 'protected' status of previously protected SEXP? Bernd -- Comerge AG, Technoparkstrasse 1, CH-8005 Zurich, Switzerland __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] R Console preference pane has the blues (PR#11466)
Full_Name: Ryan Lovett Version: 2.7.0 OS: Mac OS X 10.5.2 Submission from: (NULL) (128.32.135.6) Each of the six color selection buttons in the Console preference pane revert to blue after attempting to modify the color. The Defaults button and Transparency slider do work. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Missing gfortran man page (PR#11465)
Full_Name: Ryan Lovett Version: 2.7.0 OS: Mac OS X 10.5.2 Submission from: (NULL) (128.32.135.6) The gfortran package for Mac OS X is missing a man page. It does have an .info file but I think a man page would still be useful for those who use R's gfortran. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Reset an embedded R.dll
On Thu, 15 May 2008, Bernd Schoeller wrote: On Thu, 15 May 2008 06:04:51 -, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: Last question: Will I need to UNPROTECT_PTR all references held, or will the call to Rf_endEmbeddedR also free protected references? What is a 'reference' here? Right, my question was imprecise. I meant 'SEXP' (which is a reference/pointer to a SEXPREC, as far as I understand it). As distinct from the various reference SEXPREC types. Rf_endEmbeddedR does what ending an R session does, no more, no less. Ok - my question put differently: Will ending an R session run a full garbage collection, ignoring the 'protected' status of previously protected SEXP? No. It will run finalizers if they were set up to do so. Bernd -- Comerge AG, Technoparkstrasse 1, CH-8005 Zurich, Switzerland -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] ** operator
Dear list, I did not find any mentioning of the fact that the ** operator can be used as a synonym for the ^ operator. > 5 ** 2 [1] 25 Searching of ** in the R Reference Index only leads to some examples in the mgcv documentation. Equally ?"**" does not open the arithmetic operators help page, but produces > ?"**" No documentation for '**' in specified packages and libraries: you could try 'help.search("**")' Is there any reason to this or am I overlooking something ? Many thanks in advance, Tobias > sessionInfo() R version 2.7.0 (2008-04-22) i486-pc-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] ** operator
On 15/05/2008 7:07 AM, Tobias Verbeke wrote: Dear list, I did not find any mentioning of the fact that the ** operator can be used as a synonym for the ^ operator. > 5 ** 2 [1] 25 Searching of ** in the R Reference Index only leads to some examples in the mgcv documentation. Equally ?"**" does not open the arithmetic operators help page, but produces > ?"**" No documentation for '**' in specified packages and libraries: you could try 'help.search("**")' Is there any reason to this or am I overlooking something ? It's fairly unlikely to go away, but it's an old undocumented feature, so use at your own risk. There are lots of other undocumented features, but maybe no others at the lexical level. Check out src/main/gram.y if you want to search for more at that level, and src/* if you want them at any level. Duncan Murdoch Many thanks in advance, Tobias > sessionInfo() R version 2.7.0 (2008-04-22) i486-pc-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] interrupting native code
Hello, I have some native code that I would like to allow users to interrupt. However, I would like to do it more gracefully than with R_CheckUserInterrupt(). The solution I came up with is to call the following abort function periodically - if it returns 1 then I clean up and return. int __WINAPI RlpSolveAbortFunction(lprec *lp, void *userhandle) { if(R_interrupts_pending) return(1); return(0); } This seems to work fine on Mac (sans Aqua) and Linux. Is this going to be portable? Also, is there anything else I need to do? For instance set R_interrupts_pending to 0 after I respond to it? Thanks. Kjell __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] ** operator
Duncan Murdoch wrote: It's fairly unlikely to go away, but it's an old undocumented feature, so use at your own risk. There are lots of other undocumented features, but maybe no others at the lexical level. Check out src/main/gram.y if you want to search for more at that level, and src/* if you want them at any level. I just had a quick browse in the source and I can't see where "**" is defined. names.c relates ^ to the power operation in arithmetic.c but no sign of "**": ./names.c:{"^", do_arith, POWOP, 1, 2, {PP_BINARY2, PREC_POWER, 1}}, grepping for POWOP doesn't help. It's not an operator like '*': > get("**") Error in get("**") : variable "**" was not found > get("*") function (e1, e2) .Primitive("*") and there's no ** in gram.y. searching for 'power' and quoted "**" doesn't help me either. Searching for unquoted ** just produces too much C code to be useful. It's got to be there somewhere!!! Barry __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] ** operator
On Thu, 15 May 2008, Barry Rowlingson wrote: Duncan Murdoch wrote: It's fairly unlikely to go away, but it's an old undocumented feature, so use at your own risk. There are lots of other undocumented features, but maybe no others at the lexical level. Check out src/main/gram.y if you want to search for more at that level, and src/* if you want them at any level. I just had a quick browse in the source and I can't see where "**" is defined. names.c relates ^ to the power operation in arithmetic.c but no sign of "**": ./names.c:{"^", do_arith, POWOP, 1, 2, {PP_BINARY2, PREC_POWER, 1}}, grepping for POWOP doesn't help. It's not an operator like '*': get("**") Error in get("**") : variable "**" was not found get("*") function (e1, e2) .Primitive("*") and there's no ** in gram.y. searching for 'power' and quoted "**" doesn't help me either. Searching for unquoted ** just produces too much C code to be useful. It's got to be there somewhere!!! Is there a clue in: "^"(5, 2) [1] 25 "**"(5, 2) Error: could not find function "**" 5 ^ 2 [1] 25 5 ** 2 [1] 25 that is, it is truly obfuscated and not accessible using contemporary interfaces? Roger Barry __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] ** operator
Roger Bivand wrote: > On Thu, 15 May 2008, Barry Rowlingson wrote: > >> Duncan Murdoch wrote: >> >>> It's fairly unlikely to go away, but it's an old undocumented >>> feature, so >>> use at your own risk. There are lots of other undocumented >>> features, but >>> maybe no others at the lexical level. Check out src/main/gram.y if >>> you >>> want to search for more at that level, and src/* if you want them >>> at any >>> level. >> >> >> I just had a quick browse in the source and I can't see where "**" is >> defined. names.c relates ^ to the power operation in arithmetic.c but >> no sign of "**": >> >> ./names.c:{"^", do_arith, POWOP, 1, 2, >> {PP_BINARY2, PREC_POWER, 1}}, >> >> grepping for POWOP doesn't help. >> >> It's not an operator like '*': >>> get("**") >> Error in get("**") : variable "**" was not found >>> get("*") >> function (e1, e2) .Primitive("*") >> >> and there's no ** in gram.y. >> >> searching for 'power' and quoted "**" doesn't help me either. >> Searching for unquoted ** just produces too much C code to be useful. >> >> It's got to be there somewhere!!! > > Is there a clue in: > >> "^"(5, 2) > [1] 25 >> "**"(5, 2) > Error: could not find function "**" >> 5 ^ 2 > [1] 25 >> 5 ** 2 > [1] 25 > > that is, it is truly obfuscated and not accessible using contemporary > interfaces? Not really, just transcribed during the lexical analysis phase: case '*': if (nextchar('*')) c='^'; yytext[0] = c; yytext[1] = '\0'; yylval = install(yytext); return c; (There's no "->" function either...) -- O__ Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] interrupting native code
How is R_interrupts_pending going to be set? It is set in the interrupt handler for SIGINT, but that is not the only way to indicate an interrupt, and it is not necessarily available to users of GUIs and embedded R. Without servicing the GUIs all interaction will be dead, including sending an interrrupt from menus/buttons/keyboard. See the comment in the code for R_CheckUserInterrupt. On Thu, 15 May 2008, Kjell Konis wrote: Hello, I have some native code that I would like to allow users to interrupt. However, I would like to do it more gracefully than with R_CheckUserInterrupt(). The solution I came up with is to call the following abort function periodically - if it returns 1 then I clean up and return. int __WINAPI RlpSolveAbortFunction(lprec *lp, void *userhandle) { if(R_interrupts_pending) return(1); return(0); } This seems to work fine on Mac (sans Aqua) and Linux. Is this going to be portable? Also, is there anything else I need to do? For instance set R_interrupts_pending to 0 after I respond to it? Thanks. Kjell __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] ** operator
On Thu, 15 May 2008, Roger Bivand wrote: On Thu, 15 May 2008, Barry Rowlingson wrote: Duncan Murdoch wrote: It's fairly unlikely to go away, but it's an old undocumented feature, so use at your own risk. There are lots of other undocumented features, but maybe no others at the lexical level. Check out src/main/gram.y if you want to search for more at that level, and src/* if you want them at any level. I just had a quick browse in the source and I can't see where "**" is defined. names.c relates ^ to the power operation in arithmetic.c but no sign of "**": ./names.c:{"^", do_arith, POWOP, 1, 2, {PP_BINARY2, PREC_POWER, 1}}, grepping for POWOP doesn't help. It's not an operator like '*': get("**") Error in get("**") : variable "**" was not found get("*") function (e1, e2) .Primitive("*") and there's no ** in gram.y. searching for 'power' and quoted "**" doesn't help me either. Searching for unquoted ** just produces too much C code to be useful. It's got to be there somewhere!!! Is there a clue in: "^"(5, 2) [1] 25 "**"(5, 2) Error: could not find function "**" 5 ^ 2 [1] 25 5 ** 2 [1] 25 that is, it is truly obfuscated and not accessible using contemporary interfaces? AFAIK it has only ever been used by the parser, which replaces it by ^ in the tokenizer. I believe it is undocumented in R, but S used to allow it (and may still), so presumably it is for compatibility. As Duncan Murdoch says, use undocumented features at your own risk. I've contemplated removing this one at times. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] ** operator
I found an entry for the '** operator' in the index of the 1988 Blue Book, with a reference to p. 431. I see nothing about it on p. 431 (or 432), but that is the help page for 'Deprecated'. So I surmise that this was part of a version of S prior to that which started life as QPE (with first-class user functions). It has been in the R tokenizer since at least 1998. On Thu, 15 May 2008, Prof Brian Ripley wrote: On Thu, 15 May 2008, Roger Bivand wrote: On Thu, 15 May 2008, Barry Rowlingson wrote: Duncan Murdoch wrote: It's fairly unlikely to go away, but it's an old undocumented feature, so use at your own risk. There are lots of other undocumented features, but maybe no others at the lexical level. Check out src/main/gram.y if you want to search for more at that level, and src/* if you want them at any level. I just had a quick browse in the source and I can't see where "**" is defined. names.c relates ^ to the power operation in arithmetic.c but no sign of "**": ./names.c:{"^", do_arith, POWOP, 1, 2, {PP_BINARY2, PREC_POWER, 1}}, grepping for POWOP doesn't help. It's not an operator like '*': get("**") Error in get("**") : variable "**" was not found get("*") function (e1, e2) .Primitive("*") and there's no ** in gram.y. searching for 'power' and quoted "**" doesn't help me either. Searching for unquoted ** just produces too much C code to be useful. It's got to be there somewhere!!! Is there a clue in: "^"(5, 2) [1] 25 "**"(5, 2) Error: could not find function "**" 5 ^ 2 [1] 25 5 ** 2 [1] 25 that is, it is truly obfuscated and not accessible using contemporary interfaces? AFAIK it has only ever been used by the parser, which replaces it by ^ in the tokenizer. I believe it is undocumented in R, but S used to allow it (and may still), so presumably it is for compatibility. As Duncan Murdoch says, use undocumented features at your own risk. I've contemplated removing this one at times. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] basename/dirname produce incorrect results
I'm sorry, but that example make no sense to me -- you need to mark the encoding (and don't send HTML that will get stripped). This is presumably Windows, given the name. On Thu, 15 May 2008, ronggui wrote: The incorrect result incurs when the file path contains Chinese character. It seems that dirname/basename action on unit of byte instead of char, so the result in the following example is half of what is expected. No, it works in widechars, that is UCS-2. I have a suspicion of what the problem is (it is related to attempts to handle embedded nuls), so please try tomorrow's R-patched to see if I have fixed it. If that does not work, we need a reproducible example, and that means a message in a known encoding. (One way to do so is to attach a plain text message, and tell us in the body of the message the encoding you used.) g<-"d:\\$BG!2L4^M-CfJ8(B\\$BG!2L4^M-CfJ8(B.txt" dirname(g) [1] "d:/$BG!2L4^(B" basename(g) [1] "$BG!2L4^M-(B" -- HUANG Ronggui, Wincent http://ronggui.huang.googlepages.com/ Bachelor of Social Work, Fudan University, China Master of sociology, Fudan University, China Ph.D. Candidate, CityU of HK. [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Bug in poly() (PR#11243)
I don't understand why this is a bug in usage. Is it because the 2nd argument is not named? I get the same behavior if I do name it: = [R version 2.6.2 (2008-02-08), Windows XP Pro] R> x = rep(1:4,3) R> y = (1:12)^1.5 R> lm(y ~ poly(x, degree=10)) Call: lm(formula = y ~ poly(x, degree = 10)) Coefficients: (Intercept) poly(x, degree = 10)1 poly(x, degree = 10)2 18.3937014.21385 0.58588 poly(x, degree = 10)3 poly(x, degree = 10)4 poly(x, degree = 10)5 -0.01770 3.34767 -11.46388 poly(x, degree = 10)6 poly(x, degree = 10)7 poly(x, degree = 10)8 0.51178 0.4429612.47199 poly(x, degree = 10)9 poly(x, degree = 10)10 -28.3897218.47439 = Is there a case where we *would* want a 10th degree polynomial fitted to only 4 distinct x values? A simple modification [changing 'length(x)' to 'length(unique(x))' in 2 places] seems to fix this: = R> mypoly ... if (raw) { if (degree >= length(unique(x))) stop("'degree' must be less than number of points") ... if (is.null(coefs)) { if (degree >= length(unique(x))) stop("'degree' must be less than number of points") ... R> lm(y ~ mypoly(x, degree=10)) Error in mypoly(x, degree = 10) : 'degree' must be less than number of points = Russ -- Russell V. Lenth, Professor Department of Statistics & Actuarial Science(319)335-0814FAX (319)335-3017 The University of Iowa [EMAIL PROTECTED] Iowa City, IA 52242 USA http://www.stat.uiowa.edu/~rlenth/ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Bug in poly() (PR#11243)
The reason is that you asked for more terms than can exist. You seem unaware that 2.6.2 is obsolete, and that there are changes in R-patched, with the following NEWS item: o poly() has additional checks against user error (as in PR#11243). and that the help page now says degree: the degree of the polynomial. Must be less than the number of unique points. As the FAQ says, please don't make further reports on items that have already been addressed (as clearly marked in the bug repository). On Fri, 16 May 2008, [EMAIL PROTECTED] wrote: I don't understand why this is a bug in usage. Is it because the 2nd argument is not named? I get the same behavior if I do name it: = [R version 2.6.2 (2008-02-08), Windows XP Pro] R> x = rep(1:4,3) R> y = (1:12)^1.5 R> lm(y ~ poly(x, degree=10)) Call: lm(formula = y ~ poly(x, degree = 10)) Coefficients: (Intercept) poly(x, degree = 10)1 poly(x, degree = 10)2 18.3937014.21385 0.58588 poly(x, degree = 10)3 poly(x, degree = 10)4 poly(x, degree = 10)5 -0.01770 3.34767 -11.46388 poly(x, degree = 10)6 poly(x, degree = 10)7 poly(x, degree = 10)8 0.51178 0.4429612.47199 poly(x, degree = 10)9 poly(x, degree = 10)10 -28.3897218.47439 = Is there a case where we *would* want a 10th degree polynomial fitted to only 4 distinct x values? A simple modification [changing 'length(x)' to 'length(unique(x))' in 2 places] seems to fix this: = R> mypoly ... if (raw) { if (degree >= length(unique(x))) stop("'degree' must be less than number of points") ... if (is.null(coefs)) { if (degree >= length(unique(x))) stop("'degree' must be less than number of points") ... R> lm(y ~ mypoly(x, degree=10)) Error in mypoly(x, degree = 10) : 'degree' must be less than number of points = Russ -- Russell V. Lenth, Professor Department of Statistics & Actuarial Science(319)335-0814FAX (319)335-3017 The University of Iowa [EMAIL PROTECTED] Iowa City, IA 52242 USA http://www.stat.uiowa.edu/~rlenth/ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel