[Rd] Rounding error for high-precision numeric values (PR#13010)
Full_Name: David Hall (gringer) Version: 2.7.2 (2008-08-25) OS: Debian GNU/Linux (sid/lenny) Submission from: (NULL) (130.195.86.38) Following on from a conversation I had with someone on IRC about Java's handling of difficult floating point numbers and its comparison with R's handling, I observed a couple of values that appeared to have incorrect rounding (1.9400994884341946e25, 1.9400994884341945e25). R displays these values to 18 significant figures, but the last digit is incorrect (should be 5, displays 4). This is probably within the realm of "quirky things that we just have to live with". Here's how to reproduce the problem: $ echo -e "options(digits=22)\n1.9400994884341946e25\n1.9400994884341948e25" | R \ --vanilla R version 2.7.2 (2008-08-25) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > options(digits=22) > 1.9400994884341946e25 [1] 1.940099488434194e+25 > 1.9400994884341948e25 [1] 1.940099488434195e+25 > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] R --interactive and readline() creates infinite loop
Dear all, I have asked before, in R-help [1], about a way to create an interactive session in which commands are taken from a file or standard input - like R CMD BATCH but additionally allowing user input - but there was no response to that question, and the workarounds that I have found (using "expect", creating a temporary .Rprofile) are ugly and problematic. With the appearance of the --interactive flag in R 2.7.0 I thought this might become possible, but it not only does not behave as I would expect, it appears to go into an infinite loop, and uses 100% CPU until killed. $ echo 'print(readline("Input:"))' | R --no-save --quiet > print(readline("Input:")) Input:[1] "" > [no interactivity] $ echo 'print(readline("Input:"))' | R --no-save --quiet --interactive [no response at all] This behaviour remains in the latest alphas of R 2.8.0. My platform is Mac OS X.5.5 on Intel Core 2 Duo. I assume, given this outcome, that this is not the intended use of -- interactive, but I still wonder if there is any way to achieve an interactive session based on a predefined set of commands without writing a completely new front-end (overkill, surely?). Any guidance would be appreciated. Regards, Jon [1] http://finzi.psych.upenn.edu/R/Rhelp02a/archive/117412.html -- Jonathan D. Clayden, Ph.D. Research Fellow Radiology and Physics Unit UCL Institute of Child Health 30 Guilford Street LONDON WC1N 1EH United Kingdom t | +44 (0)20 7905 2708 f | +44 (0)20 7905 2358 w | www.homepages.ucl.ac.uk/~sejjjd2/ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] help text in read.table
Dear R-developers, In read.table() the argument |colClasses = "NULL" can be used to skip columns and col.names to name the variables. The first time I tried to skip columns, I naively thought that /first/ the "NULL"-columns are skipped, /then/ you name only the remaining columns actually specified. Therefore, I did not provide names (i.e. "NULL") for the (large) number of columns skipped. When I got the warning message, "Error in read.table(file = file, header = header, sep = sep, quote = quote, : more columns than column names", I realized that I have to provide col.names also for the columns skipped. Now I wonder if it might be an idea to add a sentence in the help text for colnames (and maybe for colClasses) that you need to provide colnames = "NULL", for variables with colClasses = "NULL". Well, just a thought. I take the opportunity to thank you all for your excellent work with R! Best regards, Henrik | -- Henrik Pärn Centre for Conservation Biology Department of Biology Norwegian University of Science and Technology NO-7491 Trondheim Norway Office: +47 73596285 Fax: +47 73596100 Mobile: +47 90989255 E-mail: [EMAIL PROTECTED] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] C++ & R: Displaying a lattice graphic using D Com
Dear list members, When I modify the MFC sample (using the statconnector graphics device) to show a lattice graph in the Active X control (actually the wireframe from http://addictedtor.free.fr/graphiques/graphcode.php?graph=40 ) the program runs without generating any errors, but the data-driven part of the plot does not display. The bounding box is displayed, but not the axes or data within it. The same code executes perfectly when typed directly into R, so this is an issue with my code. Sometimes the plot 'flickers' into view or partial view very briefly, before execution has completed. However, once the code has executed no plot is visible. I am using visual C++ - and I have copied out the code at the end of this note. I would be grateful for any advice. Kind regards Noel void CMFCClientDlg::OnTest() { BeginWaitCursor(); IStatConnector lConnector; IDispatch* lCharDev = NULL; IDispatch* lGfxDev = NULL; if(FAILED(m_CharDev.GetControlUnknown()->QueryInterface(IID_IDispatch,(LPVOI D*) &lCharDev))) { MessageBox("Error querying Dispatch from Character Device"); return; } if(FAILED(lConnector.CreateDispatch(_T("StatConnectorSrv.StatConnector" { MessageBox("Error creating StatConnectorSrv"); return; } lConnector.Init(_T("R")); lConnector.SetCharacterOutputDevice(lCharDev); lConnector.AddGraphicsDevice(_T("Gfx"),m_GraphDev.GetGFX()); lConnector.EvaluateNoReturn(_T("require(lattice)")); lConnector.EvaluateNoReturn(_T("x <- seq(-pi, pi, len = 20)")); lConnector.EvaluateNoReturn(_T("y <- seq(-pi, pi, len = 20)")); lConnector.EvaluateNoReturn(_T("g <- expand.grid(x = x, y = y)")); lConnector.EvaluateNoReturn(_T("g$z <- sin(sqrt(g$x^2 + g$y^2))")); lConnector.EvaluateNoReturn(_T("plot(wireframe(z ~ x * y, g, drape = TRUE, aspect = c(3,1), colorkey = TRUE))")); lConnector.Close(); EndWaitCursor(); } __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R --interactive and readline() creates infinite loop
For an alternative approach to your original goal, take a look at demoSource() in the SoDA package from CRAN. It's a bit tedious to set up (see the Details section of the help file) but uses standard R sessions to mix lines from a demo file and interactive input. John Jon Clayden wrote: Dear all, I have asked before, in R-help [1], about a way to create an interactive session in which commands are taken from a file or standard input - like R CMD BATCH but additionally allowing user input - but there was no response to that question, and the workarounds that I have found (using "expect", creating a temporary .Rprofile) are ugly and problematic. With the appearance of the --interactive flag in R 2.7.0 I thought this might become possible, but it not only does not behave as I would expect, it appears to go into an infinite loop, and uses 100% CPU until killed. $ echo 'print(readline("Input:"))' | R --no-save --quiet > print(readline("Input:")) Input:[1] "" > [no interactivity] $ echo 'print(readline("Input:"))' | R --no-save --quiet --interactive [no response at all] This behaviour remains in the latest alphas of R 2.8.0. My platform is Mac OS X.5.5 on Intel Core 2 Duo. I assume, given this outcome, that this is not the intended use of --interactive, but I still wonder if there is any way to achieve an interactive session based on a predefined set of commands without writing a completely new front-end (overkill, surely?). Any guidance would be appreciated. Regards, Jon [1] http://finzi.psych.upenn.edu/R/Rhelp02a/archive/117412.html -- Jonathan D. Clayden, Ph.D. Research Fellow Radiology and Physics Unit UCL Institute of Child Health 30 Guilford Street LONDON WC1N 1EH United Kingdom t | +44 (0)20 7905 2708 f | +44 (0)20 7905 2358 w | www.homepages.ucl.ac.uk/~sejjjd2/ __ 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
Re: [Rd] R --interactive and readline() creates infinite loop
One canonical way of doing it is: (echo 'print(readline("Input:"))'; cat -) | R --interactive --no-save (you don't want to leave out --no-save ) John Chambers wrote: > For an alternative approach to your original goal, take a look at > demoSource() in the SoDA package from CRAN. It's a bit tedious to set > up (see the Details section of the help file) but uses standard R > sessions to mix lines from a demo file and interactive input. > > John > > Jon Clayden wrote: >> Dear all, >> >> I have asked before, in R-help [1], about a way to create an >> interactive session in which commands are taken from a file or >> standard input - like R CMD BATCH but additionally allowing user >> input - but there was no response to that question, and the >> workarounds that I have found (using "expect", creating a temporary >> .Rprofile) are ugly and problematic. >> >> With the appearance of the --interactive flag in R 2.7.0 I thought >> this might become possible, but it not only does not behave as I >> would expect, it appears to go into an infinite loop, and uses 100% >> CPU until killed. >> >> $ echo 'print(readline("Input:"))' | R --no-save --quiet >> > print(readline("Input:")) >> Input:[1] "" >> > >> [no interactivity] >> >> $ echo 'print(readline("Input:"))' | R --no-save --quiet --interactive >> [no response at all] >> >> This behaviour remains in the latest alphas of R 2.8.0. My platform >> is Mac OS X.5.5 on Intel Core 2 Duo. >> >> I assume, given this outcome, that this is not the intended use of >> --interactive, but I still wonder if there is any way to achieve an >> interactive session based on a predefined set of commands without >> writing a completely new front-end (overkill, surely?). >> >> Any guidance would be appreciated. >> >> Regards, >> Jon >> >> [1] http://finzi.psych.upenn.edu/R/Rhelp02a/archive/117412.html >> >> >> -- >> Jonathan D. Clayden, Ph.D. >> Research Fellow >> Radiology and Physics Unit >> UCL Institute of Child Health >> 30 Guilford Street >> LONDON WC1N 1EH >> United Kingdom >> >> t | +44 (0)20 7905 2708 >> f | +44 (0)20 7905 2358 >> w | www.homepages.ucl.ac.uk/~sejjjd2/ >> >> __ >> 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 -- 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] R --interactive and readline() creates infinite loop
> I assume, given this outcome, that this is not the intended use of > --interactive, but I still wonder if there is any way to achieve an > interactive session based on a predefined set of commands without writing a > completely new front-end (overkill, surely?). When you say an interactive session, do you mean that the output should be identical to what would have happened if you had copied and pasted the code in to an R session? I'm working on some code that allows you to do this, based around parse and eval. Hadley -- http://had.co.nz/ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R --interactive and readline() creates infinite loop
hadley wickham wrote: >> I assume, given this outcome, that this is not the intended use of >> --interactive, but I still wonder if there is any way to achieve an >> interactive session based on a predefined set of commands without writing a >> completely new front-end (overkill, surely?). >> > > When you say an interactive session, do you mean that the output > should be identical to what would have happened if you had copied and > pasted the code in to an R session? I'm working on some code that > allows you to do this, based around parse and eval. > I assumed that the point was to allow some code to run, possibly with user input, and then continue in an interactive session. It is, BTW, not clear to me whether or not it could be done using .First(). -- 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] R --interactive and readline() creates infinite loop
My application, at least, wanted to show (my class) individual commands from the file and then optionally insert some typed commands before going on to the next part of the source file. As far as I can see, the piped shell command approach will have to treat the whole file at one time. John Peter Dalgaard wrote: > One canonical way of doing it is: > > (echo 'print(readline("Input:"))'; cat -) | R --interactive --no-save > > (you don't want to leave out --no-save ) > > > John Chambers wrote: > >> For an alternative approach to your original goal, take a look at >> demoSource() in the SoDA package from CRAN. It's a bit tedious to set >> up (see the Details section of the help file) but uses standard R >> sessions to mix lines from a demo file and interactive input. >> >> John >> >> Jon Clayden wrote: >> >>> Dear all, >>> >>> I have asked before, in R-help [1], about a way to create an >>> interactive session in which commands are taken from a file or >>> standard input - like R CMD BATCH but additionally allowing user >>> input - but there was no response to that question, and the >>> workarounds that I have found (using "expect", creating a temporary >>> .Rprofile) are ugly and problematic. >>> >>> With the appearance of the --interactive flag in R 2.7.0 I thought >>> this might become possible, but it not only does not behave as I >>> would expect, it appears to go into an infinite loop, and uses 100% >>> CPU until killed. >>> >>> $ echo 'print(readline("Input:"))' | R --no-save --quiet >>> print(readline("Input:")) >>> Input:[1] "" >>> >>> [no interactivity] >>> >>> $ echo 'print(readline("Input:"))' | R --no-save --quiet --interactive >>> [no response at all] >>> >>> This behaviour remains in the latest alphas of R 2.8.0. My platform >>> is Mac OS X.5.5 on Intel Core 2 Duo. >>> >>> I assume, given this outcome, that this is not the intended use of >>> --interactive, but I still wonder if there is any way to achieve an >>> interactive session based on a predefined set of commands without >>> writing a completely new front-end (overkill, surely?). >>> >>> Any guidance would be appreciated. >>> >>> Regards, >>> Jon >>> >>> [1] http://finzi.psych.upenn.edu/R/Rhelp02a/archive/117412.html >>> >>> >>> -- >>> Jonathan D. Clayden, Ph.D. >>> Research Fellow >>> Radiology and Physics Unit >>> UCL Institute of Child Health >>> 30 Guilford Street >>> LONDON WC1N 1EH >>> United Kingdom >>> >>> t | +44 (0)20 7905 2708 >>> f | +44 (0)20 7905 2358 >>> w | www.homepages.ucl.ac.uk/~sejjjd2/ >>> >>> __ >>> 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 >> > > > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R --interactive and readline() creates infinite loop
Many thanks for the suggestions. The use case I had in mind is more along the lines of what Peter Dalgaard mentioned, and his solution looks ideal. I know in advance exactly what code I want to run, but some of that code may require user input. Jon 2008/9/25 John Chambers <[EMAIL PROTECTED]>: > My application, at least, wanted to show (my class) individual commands > from the file and then optionally insert some typed commands before > going on to the next part of the source file. As far as I can see, the > piped shell command approach will have to treat the whole file at one time. > > John > > Peter Dalgaard wrote: >> One canonical way of doing it is: >> >> (echo 'print(readline("Input:"))'; cat -) | R --interactive --no-save >> >> (you don't want to leave out --no-save ) >> >> >> John Chambers wrote: >> >>> For an alternative approach to your original goal, take a look at >>> demoSource() in the SoDA package from CRAN. It's a bit tedious to set >>> up (see the Details section of the help file) but uses standard R >>> sessions to mix lines from a demo file and interactive input. >>> >>> John >>> >>> Jon Clayden wrote: >>> Dear all, I have asked before, in R-help [1], about a way to create an interactive session in which commands are taken from a file or standard input - like R CMD BATCH but additionally allowing user input - but there was no response to that question, and the workarounds that I have found (using "expect", creating a temporary .Rprofile) are ugly and problematic. With the appearance of the --interactive flag in R 2.7.0 I thought this might become possible, but it not only does not behave as I would expect, it appears to go into an infinite loop, and uses 100% CPU until killed. $ echo 'print(readline("Input:"))' | R --no-save --quiet > print(readline("Input:")) > Input:[1] "" [no interactivity] $ echo 'print(readline("Input:"))' | R --no-save --quiet --interactive [no response at all] This behaviour remains in the latest alphas of R 2.8.0. My platform is Mac OS X.5.5 on Intel Core 2 Duo. I assume, given this outcome, that this is not the intended use of --interactive, but I still wonder if there is any way to achieve an interactive session based on a predefined set of commands without writing a completely new front-end (overkill, surely?). Any guidance would be appreciated. Regards, Jon [1] http://finzi.psych.upenn.edu/R/Rhelp02a/archive/117412.html -- Jonathan D. Clayden, Ph.D. Research Fellow Radiology and Physics Unit UCL Institute of Child Health 30 Guilford Street LONDON WC1N 1EH United Kingdom t | +44 (0)20 7905 2708 f | +44 (0)20 7905 2358 w | www.homepages.ucl.ac.uk/~sejjjd2/ __ 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 >>> >> >> >> > >[[alternative HTML version deleted]] > > __ > 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
Re: [Rd] R --interactive and readline() creates infinite loop
John Chambers wrote: My application, at least, wanted to show (my class) individual commands from the file and then optionally insert some typed commands before going on to the next part of the source file. As far as I can see, the piped shell command approach will have to treat the whole file at one time. Hmmno... You can "cat -" multiple times if you want, terminating each with ctrl-D. That's not to say that it is the optimal solution though. Echoing the non-keyboard input seems a bit tricky, for instance. -- 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
[Rd] Bug while loading Package "tcltk" with R-2.7.2 (PR#13016)
Full_Name: Cyril Alegret Version: 2.7.2 OS: Windows Submission from: (NULL) (90.80.39.42) An error occurs when I try to load the package "tcltk2_1.0-7" with R-2.7.2 (whereas it works with version 2.6.2). Please find below the error message : "> source("C:\\Data\\Travail\\Software&Method\\R\\Procs\\Chargement des librairies.R") Le chargement a nécessité le package : tcltk Chargement de Tcl/Tk... terminé Error in names(res) <- c("default", "menu", "caption", "smallcaption", : objet "res" non trouvé Error : .onLoad a échoué dans 'loadNamespace' pour 'tcltk2' Erreur : le chargement du package / espace de noms a échoué pour 'tcltk2'" Thank you for your help __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Bug while loading Package "tcltk" with R-2.7.2 (PR#13016)
On 25/09/2008 7:30 AM, [EMAIL PROTECTED] wrote: Full_Name: Cyril Alegret Version: 2.7.2 OS: Windows Submission from: (NULL) (90.80.39.42) An error occurs when I try to load the package "tcltk2_1.0-7" with R-2.7.2 (whereas it works with version 2.6.2). Please find below the error message : "> source("C:\\Data\\Travail\\Software&Method\\R\\Procs\\Chargement des librairies.R") Le chargement a nécessité le package : tcltk Chargement de Tcl/Tk... terminé Error in names(res) <- c("default", "menu", "caption", "smallcaption", : objet "res" non trouvé Error : .onLoad a échoué dans 'loadNamespace' pour 'tcltk2' Erreur : le chargement du package / espace de noms a échoué pour 'tcltk2'" Thank you for your help Why do you think this has something to do with tcltk? It's pretty clearly a problem in your script, or in the tcltk2 (not tcltk!) package. But since you didn't track it down within your script, we can't help you. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel