Re: [Rd] Call function only when running via R CMD check?
Many thanks for your replies. I had a quick look at both functions: - CRAN(): it detects timing check from --as-cran. - queryRCmdCheck() allows to detect which part of the check is calling a function (examples, tests?). Both are useful! Would be nice to have a R-base function which can provide a definite identification of R CMD check and other special calls (e.g. in \Sexpr in Rd files). Bests, Renaud 2012/12/18 Spencer Graves > Have you considered the CRAN function in "fda"? Spencer > > > > On 12/18/2012 4:00 AM, Henrik Bengtsson wrote: > >> Hi Renaud, >> >> On Tue, Dec 18, 2012 at 8:44 AM, Renaud Gaujoux >> wrote: >> >>> Hi Henrik (and list), >>> >>> I am interested in a similar feature, and would be happy to see the >>> suggestions you got off-line :) >>> Have you come up with a robust solution, which would work in a variety of >>> situations (in examples, tests, \Sexpr calls, etc..)? >>> >> see queryRCmdCheck() of R.utils. Example: >> >> # Get the 'R CMD check' status, if any >> status <- R.utils::queryRCmdCheck() >> >> if (status != "notRunning") { >>cat("The current R session was launched by R CMD check. Status:", >> status, "\n") >> } else { >>cat("The current R session was not launched by R CMD check.\n") >> } >> >> I haven't tested it with Sweave, but with examples and tests. >> >> R.utils 1.18.0 is on CRAN, but you'd want 1.18.3, because: >> >> Version: 1.18.3 [2012-11-06] >> o BUG FIX: queryRCmdCheck() did not detect "tests" evidences when >>'R CMD check' was testing multiple architectures. >> >> It may be another couple of weeks before I submit it to CRAN, but in >> the meanwhile you can grab it via: >> >> source("http://aroma-project.**org/hbLite.R<http://aroma-project.org/hbLite.R> >> "); >> hbLite("R.utils") >> >> Any feedback (positive or negative) is appreciated. >> >> Hope it helps >> >> /Henrik >> >> >> Thank you. >>> >>> Bests, >>> Renaud >>> >>> -- >>> Renaud Gaujoux >>> Computational Biology - University of Cape Town >>> South Africa >>> >>> >>> __** >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/**listinfo/r-devel<https://stat.ethz.ch/mailman/listinfo/r-devel> >> >> >> > > -- > Spencer Graves, PE, PhD > President and Chief Technology Officer > Structure Inspection and Monitoring, Inc. > 751 Emerson Ct. > San José, CA 95126 > ph: 408-655-4567 > web: www.structuremonitoring.com > > > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Keeping up to date with R-devel
Hi, is checking out R SVN trunk the recommended way to keep up to date with R-devel and check packages with the latest version? My objective is to be able to have both R and R-devel versions installed/working and up to date. R-devel binaries would be available as symlinks in my home directory so that I can do: Rdevel CMD check mypkg Rdscript -e "some R code" anywhere on my system. So the workflow would be: Only once: svn co https://svn.r-project.org/R/trunk rdevel Then in rdevel: svn update ./configure --prefix=~/bin/R-devel make make install [Only after first compilation: cd ~/bin/; ln- s R-devel/bin/R Rdevel; ln- s R-devel/bin/Rscript Rdscript ] Then build/check packages as usual, using Rdevel CMD instead of R CMD. Obviously contrib packages need to be installed/updated in Rdevel. Can anybody see an issue in this workflow? Improvements? unneeded commands? possible conflcts in libraries? Would be Is there any chance that the Linux binary repositories include Rdevel-base packages that would do all this and install R-devel system wide. It would be up to date via apt-get-like systems. Not sure how automatic it is to go from sources to .deb packages. Thank you. [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Keeping up to date with R-devel
Hi, thanks for the responses. Dirk I found the script you posted once. Can anyone send me a link to the "beaten to death post"? I am fine with these approaches and kind of already follow them. I imagine that after an R-devel update you have to re-install all the contrib packages that need to compile library objects, right? It would still be nice to have devel binary core packages, even if CRAN page states: "CRAN itself does no longer mirror source snapshots (as of 2001-11-14), because it makes only limited sense to propagate archives that change on a daily basis through a network of mirror sites. When a snapshot reaches one of the final nodes in the mirroring process, there are already 2 newer versions available at the orginal sites." As for package checking is concerned, getting an update of R-devel that is 2 versions late would be perfectly fine, wouldn't it? When compiling from source, R and R-devel coexist happily if one specifies an installation prefix other than the default. What other conflict could happen? Renaud 2013/2/27 Dirk Eddelbuettel > > On 27 February 2013 at 12:08, Renaud wrote: > | is checking out R SVN trunk the recommended way to keep up to date with > | R-devel and check packages with the latest version? > > In theory. > > In practice you need a time machine as I just something rejected for a test > that did not exist when I submitted :-/ > > Until the package "timeMachine" appears on CRAN, I do keep an svn checkout > which I update about once a week. I have a little build script which I > posted once and which I'd be happy to send to you but I can't show it in > public for risk of ex-communication as it builds in the very verboten place > (and no, I've never been bitten but yes I do make distclean too). > > Dirk > > -- > Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com > > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] interpolation using akima (PR#8174)
This message should be sent to the package maintainer, not to this list. Moreover, it works fine with my installation (i.e., I don't get the bug you describe): R: platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status beta major2 minor2.0 year 2005 month09 day 24 svn rev 35666 language R akima: Package: akima Version: 0.4-5 Date: 2005-07-21 Best, Renaud 2005/10/3, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > Full_Name: Jonathan Lees > Version: 2.0.1 > OS: linux-gnu > Submission from: (NULL) (152.2.75.65) > > > there is a problem with calculating the convex hull in 2-D interpolation using > the codes interp fromt eh akima package: > > x =c(0.6505304, -1.1821562, -0.2600792, 0.7913716) > y = c(1.0424226, 0.1754048, -1.4523334, 0.2349112) > z = c(0.000, 3.042, 0.370, 0.122) > > >EX = seq(from=min(x), to=max(x), length=100) > WHY = seq(from=min(y), to=max(y), length=100) > > ZZ = interp(x=x, y=y, z=z, xo=EX, yo=WHY, extrap=FALSE) > > plot(x,y, type='n') > image(ZZ, add=TRUE) > points(x,y) > text(x,y,labels=z) > > BUG: > Notice the convex hull is wrong. > It includes only 3 of the 4 points provided. > If you add another point near by it does some > really wierd stuff. > x = c(x, -0.3950865) > y = c(y, -1.449117) > z = c(z, .37) > > > > I do not think it should behave in this manner. > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > -- Renaud LANCELOT Directeur Adjoint chargé des Affaires Scientifiques Deputy Director for Scientific Affairs Département EMVT du CIRAD, TA 30/B Campus International de Baillarguet 34398 Montpellier Cedex 5 - France Tel. +33 (0)4 67 59 37 17 Secr. +33 (0)4 67 59 39 04 Fax +33 (0)4 67 59 37 95 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Defining a method that behaves like '$'?
Hi, is there a way to define a method say '$$' that would behave like '$' and allow calls like 'a$$name'? Thanks. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Defining a method that behaves like '$'?
Alright. Maybe the symbol I chose was not appropriate. I tried ':' to be able to do 'a:name' with 'a' a S4 object. I get the following error: Error in genericForPrimitive(f) : methods may not be defined for primitive function ":" in this version of R Does there exist any symbol that would be suitable for the job? Thanks -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 09/07/2010 14:29, Duncan Murdoch wrote: On 09/07/2010 8:18 AM, Renaud Gaujoux wrote: Hi, is there a way to define a method say '$$' that would behave like '$' and allow calls like 'a$$name'? No, the parser handles a fixed syntax, and that expression is not legal. You could do it with a %$$% name using the infix operator syntax. (I think the description in the R Language Definition suggests this is not legal, since $$ is not a valid name, but it does currently work and that's unlikely to change.) Duncan Murdoch ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Defining a method that behaves like '$'?
I do not want to access the slot itself but its content: a:toto would be a...@slot1[['toto']]. The thing is that I would like to have two different methods: '$' (that I already have) and another one to define, ideally that behaves like '$'. So in brief: - a:toto would be for a...@slot1[['toto']] - a$tata would be for a...@slot2[['tata']] But apparently it might not be possible. -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 09/07/2010 14:58, Marc Schwartz wrote: You were, in effect, trying to overload the ":" operator, which is of course for defining sequences. If you are using S4 methods, what is wrong with using the default "@" as the extraction syntax (eg. a...@name) to get at slots? See ?"@" and ?slot HTH, Marc Schwartz On Jul 9, 2010, at 7:49 AM, Renaud Gaujoux wrote: Alright. Maybe the symbol I chose was not appropriate. I tried ':' to be able to do 'a:name' with 'a' a S4 object. I get the following error: Error in genericForPrimitive(f) : methods may not be defined for primitive function ":" in this version of R Does there exist any symbol that would be suitable for the job? Thanks -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 09/07/2010 14:29, Duncan Murdoch wrote: On 09/07/2010 8:18 AM, Renaud Gaujoux wrote: Hi, is there a way to define a method say '$$' that would behave like '$' and allow calls like 'a$$name'? No, the parser handles a fixed syntax, and that expression is not legal. You could do it with a %$$% name using the infix operator syntax. (I think the description in the R Language Definition suggests this is not legal, since $$ is not a valid name, but it does currently work and that's unlikely to change.) Duncan Murdoch ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Defining a method that behaves like '$'?
Thanks all. Just to clarify a bit my intention with another '$'-like function. It was due to the nice features of '$': - it hides the internal implementation - it is known by most users so no extra brain-memory is required - it is quick and simple to write, which I think is actually very important as R code is often written repeatedly over and over - it allows for auto-completion - it allows dynamic structures in the sense that one can allow the user to add its own 'members' which are accessible through the same interface: 'a$custom.member', 'a$builtin.member'. I will try to work out a solution from all the suggestions I got from the list. Thanks again to all. Renaud. -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 10/07/2010 17:29, Marc Schwartz wrote: On Jul 10, 2010, at 7:24 AM, Barry Rowlingson wrote: On Fri, Jul 9, 2010 at 2:10 PM, Renaud Gaujoux wrote: I do not want to access the slot itself but its content: a:toto would be a...@slot1[['toto']]. The thing is that I would like to have two different methods: '$' (that I already have) and another one to define, ideally that behaves like '$'. So in brief: - a:toto would be for a...@slot1[['toto']] - a$tata would be for a...@slot2[['tata']] But apparently it might not be possible. Even if possible, definitely not desirable. As already mentioned, a:b is the sequence a to b (as in 0:10), so it's going to look weird to anyone who hasn't noticed your definition. Also, it looks fairly meaningless. By which I mean there's no obvious reason why a colon should do what you want it to do. There's also no obvious reason why a dollar sign does what it does (whats it got to do with dollars?) but we've had it for 20 years so we're stuck with it. Write a method for your objects and force your users to do a bit more typing as a trade-off for legibility: slot1(a,"toto") is a lot more readable than a:toto (assuming you replace 'slot1' with something meaningful). Remember, code is most likely to be written once, and read many times - so make it easy for readers! Just to throw in another $0.02, in hindsight, not fully understanding the context of Renaud's original query, this may be a situation where implementing relevant extractor functions would make sense. Consider functions such as coef(), effects(), fitted() etc. for regression models. These allow you and your users to have functions that return components of your object class without being concerned about the internal structure of your object. Importantly, you and your users will not be affected by future changes to your object structure that you may find you have to implement over time. You simply modify the extractor functions as required when the internal structure of your class changes, so that they can be used post-change, without breaking existing code. So for example: toto(a) would return a...@slot1[['toto']] and tata(a) would return a...@slot2[['tata']]. Food for thought. Marc ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R and Epi Info
Dear Kevin, I often use Epi Info to develop questionnaires and databases with MSc / PhD students for the purpose of field surveys. It's straightforward to send queries in the Epi Info databases (MS Access format) and retrieve data using packages like RODBC. All the best, Renaud 2010/8/31 Sullivan, Kevin M : > Hello, > I was wondering who to contact to see about somehow interconnecting or > integrating the programs R and Epi Info. I have been involved in the > development of Epi Info which is a software program developed by the Centers > for Disease Control and Prevention (CDC) in Atlanta > (www.cdc.gov/epiinfo<http://www.cdc.gov/epiinfo>). Epi Info allows for > creating data entry systems and performs certain epidemiologic and > statistical analyses. Currently Epi Info is in the public domain and I > believe future versions will be open source. It might be useful to pull > together some of the Epi Info development team members and R team members to > discuss how the programs might complement each other. Note that I request > this from my position at Emory University and this is not an official request > from CDC. > Thanks, Kevin > > > This e-mail message (including any attachments) is for...{{dropped:24}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Non identical numerical results from R code vs C/C++ code?
Hi, suppose you have two versions of the same algorithm: one in pure R, the other one in C/C++ called via .Call(). Assuming there is no bug in the implementations (i.e. they both do the same thing), is there any well known reason why the C/C++ implementation could return numerical results non identical to the one obtained from the pure R code? (e.g. could it be rounding errors? please explain.) Has anybody had a similar experience? By not identical, I mean very small differences (< 2.4 e-14), but enough to have identical() returning FALSE. Maybe I should not bother, but I want to be sure where the differences come from, at least by mere curiosity. Briefly the R code perform multiple matrix product; the C code is an optimization of those specific products via custom for loops, where entries are not computed in the same order, etc... which improves both memory usage and speed. The result is theoretically the same. Thank you, Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Non identical numerical results from R code vs C/C++ code?
Thank you Duncan for your reply. Currently I am using 'double' for the computations. What type should I use for extended real in my intermediate computations? The result will still be 'double' anyway right? On 10/09/2010 13:00, Duncan Murdoch wrote: On 10/09/2010 6:46 AM, Renaud Gaujoux wrote: Hi, suppose you have two versions of the same algorithm: one in pure R, the other one in C/C++ called via .Call(). Assuming there is no bug in the implementations (i.e. they both do the same thing), is there any well known reason why the C/C++ implementation could return numerical results non identical to the one obtained from the pure R code? (e.g. could it be rounding errors? please explain.) Has anybody had a similar experience? R often uses extended reals (80 bit floating point values on Intel chips) for intermediate values. C compilers may or may not do that. By not identical, I mean very small differences (< 2.4 e-14), but enough to have identical() returning FALSE. Maybe I should not bother, but I want to be sure where the differences come from, at least by mere curiosity. Briefly the R code perform multiple matrix product; the C code is an optimization of those specific products via custom for loops, where entries are not computed in the same order, etc... which improves both memory usage and speed. The result is theoretically the same. Changing the order of operations will often affect rounding. For example, suppose epsilon is the smallest number such that 1 + epsilon is not equal to 1. Then 1 + (epsilon/2) + (epsilon/2) will evaluate to either 1 or 1 + epsilon, depending on the order of computing the additions. Duncan Murdoch Thank you, Renaud ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Non identical numerical results from R code vs C/C++ code?
Ok. I quickly tried using LDOUBLE wherever I could, but it did not changed the results. I might try harder... I agree with you Barry, and I will re-double re-check my code. Thank you both for your help. Bests, Renaud On 10/09/2010 13:24, Barry Rowlingson wrote: On Fri, Sep 10, 2010 at 11:46 AM, Renaud Gaujoux wrote: Hi, suppose you have two versions of the same algorithm: one in pure R, the other one in C/C++ called via .Call(). Assuming there is no bug in the implementations (i.e. they both do the same thing), is there any well known reason why the C/C++ implementation could return numerical results non identical to the one obtained from the pure R code? (e.g. could it be rounding errors? please explain.) Has anybody had a similar experience? By not identical, I mean very small differences (< 2.4 e-14), but enough to have identical() returning FALSE. Maybe I should not bother, but I want to be sure where the differences come from, at least by mere curiosity. Briefly the R code perform multiple matrix product; the C code is an optimization of those specific products via custom for loops, where entries are not computed in the same order, etc... which improves both memory usage and speed. The result is theoretically the same. I've had almost exactly this situation recently with an algorithm I first implemented in R and then in C. Guess what the problem was? Yes, a bug in the C code. At first I thought everything was okay because the returned values were close-ish, and I thought 'oh, rounding error', but I wasn't happy about that. So I dug a bit deeper. This is worth doing even if you are sure there no bugs in the C code (remember: there's always one more bug). First, construct a minimal dataset so you can demonstrate the problem with a manageable size of matrix. I went down to 7 data points. Then get the C to print out its inputs. Identical, and as expected? Good. Now debug intermediate calculations, printing or saving from C and checking they are the same as the intermediate calculations from R. If possible, try returning intermediate calculations in C and checking identical() with R intermediates. Eventually you will find out where the first diverge - and this is the important bit. It's no use just knowing the final answers come out different, it's likely your answer has a sensitive dependence on initial conditions. You need to track down when the first bits are different. Or it could be rounding error... Barry ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Non identical numerical results from R code vs C/C++ code?
Thanks Paul for the hints. After some tests, reducing portion of my code, I found that simply doing a naive computation of 'crossprod' in C does NOT give exactly the same results as calling the Fortran underlying routine (dsyrk) as used in the R source code. I will try the double 0.0 to see if it makes a difference. What do you mean by "You also need to be careful about conversion from integer to real, to do double conversion." ? Where are the trap in this type of conversion? Thanks. Renaud On 10/09/2010 16:07, Paul Gilbert wrote: With fortran I have always managed to be able to get identical results on the same computer with the same OS. You will have trouble if you switch OS or hardware, or try the same hardware and OS with different math libraries. All the real calculations need to be double, even intermediate variables. Also, I've had trouble with arrays not being initialized to double 0.0. If you initialize to single 0.0 the straggling bits can cause differences. You also need to be careful about conversion from integer to real, to do double conversion. I'm not sure about C, but I would guess there are some of the same problems. Paul -Original Message- From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r- project.org] On Behalf Of Renaud Gaujoux Sent: September 10, 2010 6:47 AM To: r-devel@r-project.org Subject: [Rd] Non identical numerical results from R code vs C/C++ code? Hi, suppose you have two versions of the same algorithm: one in pure R, the other one in C/C++ called via .Call(). Assuming there is no bug in the implementations (i.e. they both do the same thing), is there any well known reason why the C/C++ implementation could return numerical results non identical to the one obtained from the pure R code? (e.g. could it be rounding errors? please explain.) Has anybody had a similar experience? By not identical, I mean very small differences (< 2.4 e-14), but enough to have identical() returning FALSE. Maybe I should not bother, but I want to be sure where the differences come from, at least by mere curiosity. Briefly the R code perform multiple matrix product; the C code is an optimization of those specific products via custom for loops, where entries are not computed in the same order, etc... which improves both memory usage and speed. The result is theoretically the same. Thank you, Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel La version française suit le texte anglais. This email may contain privileged and/or confidential ...{{dropped:27}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Encoding problem in Rd file
Dear all, I have a problem with an Rd file containing French accentuated characters. I have uploaded the file at http://filex.cirad.fr/get?k=cjW7lImMaNC6Ci2vX0H I have declared Encoding: latin1 in the package DESCRIPTION file and I have added \encoding{latin1} in the header of the Rd file. When I compile the package manual, I have LaTeX errors: ! Package inputenc Error: Unicode char \u8:ÃF not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H for immediate help. ... l.579 ...ain. Aspects méthodologiques.} Rev. à F augère, O., Dockès, A.-C... Your command was ignored. Type Ito replace it with another command, orto continue without it. ! Package inputenc Error: Unicode char \u8:ÃF not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H for immediate help. ... l.581 à F augère, O., Tillard, E., Faugère, B., 1992. \emph{Prophylaxie ch... Your command was ignored. Type Ito replace it with another command, orto continue without it. ! Package inputenc Error: Unicode char \u8:Ã\end not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H for immediate help. ... l.587 \end {References} Your command was ignored. Type Ito replace it with another command, orto continue without it. *** I can easily find the offending lines using showNonASCII(readLines(file)). However, I don't know what to do to solve the problem. The strange thing (to me!) is that the pdf is actually built with appropriate accentuated characters, at least when I look at it with my pdf viewer (Acrobat reader). My config is: > sessionInfo() R version 2.11.1 Patched (2010-09-30 r53117) Platform: i386-pc-mingw32 (32-bit) locale: [1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252 [3] LC_MONETARY=French_France.1252 LC_NUMERIC=C [5] LC_TIME=French_France.1252 attached base packages: [1] tools stats graphics grDevices utils datasets methods [8] base other attached packages: [1] fortunes_1.4-0 -- Renaud Lancelot EDEN Project, coordinator http://www.eden-fp6project.net/ UMR CIRAD-INRA "Contrôle des maladies animales exotiques et émergentes" Joint research unit "Control of emerging and exotic animal diseases" CIRAD, Campus International de Baillarguet TA A-DIR / B F34398 Montpellier http://umr-cmaee.cirad.fr/ Tel. +33 4 67 59 37 17 - Fax +33 4 67 59 37 95 Secr. +33 4 67 59 37 37 - Cell. +33 6 77 52 08 69 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Encoding problem in Rd file
Thank you very much. My LaTeX installation is up to date (very recently updated with MIKTeK update facility). I have run R CMD Rd2dvi --no-clean dja.Rd and the result looks OK. I have put the resulting TeX file at http://filex.cirad.fr/get?k=K1cBpKr3UBUmdOJFMlx Do you have another suggestion? Renaud 2010/10/3 Duncan Murdoch : > On 03/10/2010 12:23 PM, Renaud Lancelot wrote: >> >> Dear all, >> >> I have a problem with an Rd file containing French accentuated >> characters. I have uploaded the file at >> http://filex.cirad.fr/get?k=cjW7lImMaNC6Ci2vX0H >> >> I have declared >> Encoding: latin1 >> in the package DESCRIPTION file >> >> and I have added >> \encoding{latin1} >> in the header of the Rd file. >> >> When I compile the package manual, I have LaTeX errors: >> >> ! Package inputenc Error: Unicode char \u8:ÃF not set up for use with >> LaTeX. >> >> See the inputenc package documentation for explanation. >> Type H for immediate help. >> ... >> >> l.579 ...ain. Aspects méthodologiques.} Rev. à F >> augère, O., Dockès, >> A.-C... > > R converts everything to UTF-8 and declares it that way for LaTeX. It looks > as though your LaTeX installation isn't prepared to handle that, or > something has gone wrong in the conversion on your system. The letter > following "Rev. " above is a capital E with an acute accent, which is > encoded as C3 89 in UTF-8. Interpreted as Latin1, that looks like "Ã", > because the 89 is unprintable, but it shouldn't come out as "ÃF". > > I'd suggest updating your LaTeX inputenc package. If that doesn't work, you > can see if the problem is in the conversion, by running > > R CMD Rd2dvi --no-clean dja.Rd > > and look in the Rd2.tex file that was produced. > > Duncan Murdoch > >> >> Your command was ignored. >> Type I to replace it with another command, >> or to continue without it. >> >> >> ! Package inputenc Error: Unicode char \u8:ÃF not set up for use with >> LaTeX. >> >> See the inputenc package documentation for explanation. >> Type H for immediate help. >> ... >> >> l.581 à F >> augère, O., Tillard, E., Faugère, B., 1992. \emph{Prophylaxie >> ch... >> >> Your command was ignored. >> Type I to replace it with another command, >> or to continue without it. >> >> >> ! Package inputenc Error: Unicode char \u8:Ã\end not set up for use with >> LaTeX. >> >> >> See the inputenc package documentation for explanation. >> Type H for immediate help. >> ... >> >> l.587 \end >> {References} >> Your command was ignored. >> Type I to replace it with another command, >> or to continue without it. >> >> *** >> I can easily find the offending lines using >> showNonASCII(readLines(file)). However, I don't know what to do to >> solve the problem. The strange thing (to me!) is that the pdf is >> actually built with appropriate accentuated characters, at least when >> I look at it with my pdf viewer (Acrobat reader). >> >> My config is: >> >>> sessionInfo() >> >> R version 2.11.1 Patched (2010-09-30 r53117) >> Platform: i386-pc-mingw32 (32-bit) >> >> locale: >> [1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252 >> [3] LC_MONETARY=French_France.1252 LC_NUMERIC=C >> [5] LC_TIME=French_France.1252 >> >> attached base packages: >> [1] tools stats graphics grDevices utils datasets methods >> [8] base >> >> other attached packages: >> [1] fortunes_1.4-0 >> >> >> >> > > -- Renaud Lancelot EDEN Project, coordinator http://www.eden-fp6project.net/ UMR CIRAD-INRA "Contrôle des maladies animales exotiques et émergentes" Joint research unit "Control of emerging and exotic animal diseases" CIRAD, Campus International de Baillarguet TA A-DIR / B F34398 Montpellier http://umr-cmaee.cirad.fr/ Tel. +33 4 67 59 37 17 - Fax +33 4 67 59 37 95 Secr. +33 4 67 59 37 37 - Cell. +33 6 77 52 08 69 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Encoding problem in Rd file
I see C:/R\R-2.11.1\share\texmf\Rd.sty which is my current R installation. By the way, there is no error during the compilation with R CMD Rd2dvi --no-clean dja.Rd So, it looks that the problem is located elsewhere... Thank you for your help. All the best, Renaud 2010/10/3 Duncan Murdoch : > On 03/10/2010 1:14 PM, Renaud Lancelot wrote: >> >> Thank you very much. My LaTeX installation is up to date (very >> recently updated with MIKTeK update facility). >> I have run R CMD Rd2dvi --no-clean dja.Rd and the result looks OK. I >> have put the resulting TeX file at >> http://filex.cirad.fr/get?k=K1cBpKr3UBUmdOJFMlx >> >> Do you have another suggestion? > > Not really, other than trying a LaTeX expert. When I run your file through > latex using > > R CMD latex Rd2.tex > > it compiles fine with no errors (only an "underfull hbox" warning). > > One thought: some people install copies of Rd.sty into their local tex > installation. If that version isn't compatible with the current macros > generated by R, you could have problems. You should see something like > > (F:/R/svn/r-devel/R/share/texmf/tex/latex\Rd.sty > Package: Rd > > in the Rd2.log file. If you see that it finds Rd.sty outside of the current > R version, delete the old file. > > Duncan Murdoch > > >> >> Renaud >> >> 2010/10/3 Duncan Murdoch : >>> >>> On 03/10/2010 12:23 PM, Renaud Lancelot wrote: >>>> >>>> Dear all, >>>> >>>> I have a problem with an Rd file containing French accentuated >>>> characters. I have uploaded the file at >>>> http://filex.cirad.fr/get?k=cjW7lImMaNC6Ci2vX0H >>>> >>>> I have declared >>>> Encoding: latin1 >>>> in the package DESCRIPTION file >>>> >>>> and I have added >>>> \encoding{latin1} >>>> in the header of the Rd file. >>>> >>>> When I compile the package manual, I have LaTeX errors: >>>> >>>> ! Package inputenc Error: Unicode char \u8:ÃF not set up for use with >>>> LaTeX. >>>> >>>> See the inputenc package documentation for explanation. >>>> Type H for immediate help. >>>> ... >>>> >>>> l.579 ...ain. Aspects méthodologiques.} Rev. à F >>>> augère, O., Dockès, >>>> A.-C... >>> >>> R converts everything to UTF-8 and declares it that way for LaTeX. It >>> looks >>> as though your LaTeX installation isn't prepared to handle that, or >>> something has gone wrong in the conversion on your system. The letter >>> following "Rev. " above is a capital E with an acute accent, which is >>> encoded as C3 89 in UTF-8. Interpreted as Latin1, that looks like "Ã", >>> because the 89 is unprintable, but it shouldn't come out as "ÃF". >>> >>> I'd suggest updating your LaTeX inputenc package. If that doesn't work, >>> you >>> can see if the problem is in the conversion, by running >>> >>> R CMD Rd2dvi --no-clean dja.Rd >>> >>> and look in the Rd2.tex file that was produced. >>> >>> Duncan Murdoch >>> >>>> Your command was ignored. >>>> Type I to replace it with another command, >>>> or to continue without it. >>>> >>>> >>>> ! Package inputenc Error: Unicode char \u8:ÃF not set up for use with >>>> LaTeX. >>>> >>>> See the inputenc package documentation for explanation. >>>> Type H for immediate help. >>>> ... >>>> >>>> l.581 à F >>>> augère, O., Tillard, E., Faugère, B., 1992. \emph{Prophylaxie >>>> ch... >>>> >>>> Your command was ignored. >>>> Type I to replace it with another command, >>>> or to continue without it. >>>> >>>> >>>> ! Package inputenc Error: Unicode char \u8:Ã\end not set up for use with >>>> LaTeX. >>>> >>>> >>>> See the inputenc package documentation for explanation. >>>> Type H for immediate help. >>>> ... >>>> >>>> l.587 \end >>>> {References} >>>> Your command was ignored. >>>> Type I to replace it with another command, >>>> or to continue without it. >>>> >>>> ***
Re: [Rd] Encoding problem in Rd file
I found the problem. It turned out that the coding system of the Rd file (as defined under Emacs) was mistakenly set by me to a wrong value. I had to define it as iso-latin-1, and then retype the accentuated characters under this new system. Everything looks OK, now. Sorry for bothering you. 2010/10/3 Renaud Lancelot : > I see C:/R\R-2.11.1\share\texmf\Rd.sty which is my current R > installation. By the way, there is no error during the compilation > with > > R CMD Rd2dvi --no-clean dja.Rd > > So, it looks that the problem is located elsewhere... > > Thank you for your help. > > All the best, > > Renaud > > 2010/10/3 Duncan Murdoch : >> On 03/10/2010 1:14 PM, Renaud Lancelot wrote: >>> >>> Thank you very much. My LaTeX installation is up to date (very >>> recently updated with MIKTeK update facility). >>> I have run R CMD Rd2dvi --no-clean dja.Rd and the result looks OK. I >>> have put the resulting TeX file at >>> http://filex.cirad.fr/get?k=K1cBpKr3UBUmdOJFMlx >>> >>> Do you have another suggestion? >> >> Not really, other than trying a LaTeX expert. When I run your file through >> latex using >> >> R CMD latex Rd2.tex >> >> it compiles fine with no errors (only an "underfull hbox" warning). >> >> One thought: some people install copies of Rd.sty into their local tex >> installation. If that version isn't compatible with the current macros >> generated by R, you could have problems. You should see something like >> >> (F:/R/svn/r-devel/R/share/texmf/tex/latex\Rd.sty >> Package: Rd >> >> in the Rd2.log file. If you see that it finds Rd.sty outside of the current >> R version, delete the old file. >> >> Duncan Murdoch >> >> >>> >>> Renaud >>> >>> 2010/10/3 Duncan Murdoch : >>>> >>>> On 03/10/2010 12:23 PM, Renaud Lancelot wrote: >>>>> >>>>> Dear all, >>>>> >>>>> I have a problem with an Rd file containing French accentuated >>>>> characters. I have uploaded the file at >>>>> http://filex.cirad.fr/get?k=cjW7lImMaNC6Ci2vX0H >>>>> >>>>> I have declared >>>>> Encoding: latin1 >>>>> in the package DESCRIPTION file >>>>> >>>>> and I have added >>>>> \encoding{latin1} >>>>> in the header of the Rd file. >>>>> >>>>> When I compile the package manual, I have LaTeX errors: >>>>> >>>>> ! Package inputenc Error: Unicode char \u8:ÃF not set up for use with >>>>> LaTeX. >>>>> >>>>> See the inputenc package documentation for explanation. >>>>> Type H for immediate help. >>>>> ... >>>>> >>>>> l.579 ...ain. Aspects méthodologiques.} Rev. à F >>>>> augère, O., Dockès, >>>>> A.-C... >>>> >>>> R converts everything to UTF-8 and declares it that way for LaTeX. It >>>> looks >>>> as though your LaTeX installation isn't prepared to handle that, or >>>> something has gone wrong in the conversion on your system. The letter >>>> following "Rev. " above is a capital E with an acute accent, which is >>>> encoded as C3 89 in UTF-8. Interpreted as Latin1, that looks like "Ã", >>>> because the 89 is unprintable, but it shouldn't come out as "ÃF". >>>> >>>> I'd suggest updating your LaTeX inputenc package. If that doesn't work, >>>> you >>>> can see if the problem is in the conversion, by running >>>> >>>> R CMD Rd2dvi --no-clean dja.Rd >>>> >>>> and look in the Rd2.tex file that was produced. >>>> >>>> Duncan Murdoch >>>> >>>>> Your command was ignored. >>>>> Type I to replace it with another command, >>>>> or to continue without it. >>>>> >>>>> >>>>> ! Package inputenc Error: Unicode char \u8:ÃF not set up for use with >>>>> LaTeX. >>>>> >>>>> See the inputenc package documentation for explanation. >>>>> Type H for immediate help. >>>>> ... >>>>> >>>>> l.581 à F >>>>> augère, O., Tillard, E., Faugère, B., 1992. \emph{Prophylaxie >>>>> ch.
[Rd] library: loading of required packages and argument 'lib.loc'
Hi, is there a reason why when calling the argument 'lib.loc' of library() is not used when trying to load the required packages? 0. Package A depends on package B 1. Install packages A and B in a subdirectory 'lib' of the current directory 2. Call: library(A, lib.loc='./lib') This will give something like the following: Loading required package: B Error: package 'B' could not be loaded In addition: Warning message: In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) : there is no package called 'B' In function library there the call '.getRequiredPackages2(pkgInfo)' loads the required packages but do not pass the argument lib.loc (whereas .getRequiredPackages2 has an argument for this). I know a quick work around for this is to put './lib' into .libPaths but it would be nice if library() could do it locally (e.g. pass the argument), without changing the global settings. Thanks, Renaud ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 4500. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Missing argument vs. empty argument
Hi, is there an easy, robust, and/or recommended way to distinguish a missing argument from an empty argument as in: foo <- function(i, j){ print(missing(j)) print(nargs()) } foo(i) # TRUE, 1 foo(i,) # TRUE, 2 I know I can work around with nargs, the list of arguments and the names of the passed arguments, but I wish there is something already in place for this. This is specially important for '['-like methods where x[i,] is not the same as x[i]. What I am looking for is a function that tells me if an argument has actually been passed empty: foo <- function(i, j, k){ print( empty.arg(j) ) print(nargs()) } would result in: foo(i) # FALSE, 1 foo(i, ) # TRUE, 2 foo(i, j) # FALSE, 2 foo(i, k=2) # FALSE, 2 foo(i, k=2, ) # TRUE, 3 Thank you for any help or pointer. Bests, Renaud ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Missing argument vs. empty argument
My purpose is indeed to write a '[' method. I will go for the `[.data.frame` solution then. Thank you. On 25/01/2011 12:53, Prof Brian Ripley wrote: On Tue, 25 Jan 2011, Renaud Gaujoux wrote: Hi, is there an easy, robust, and/or recommended way to distinguish a missing argument from an empty argument as in: An empty argument is a missing argument when argument matching is done, e.g. foo <- function(i,j) match.call() foo(i) foo(i = i) foo(i,) foo(i = i) foo(,j) foo(j = j) It is rather against the spirit of R to use the actual call rather than the matched call. Unless you are doing this to write a '[' method I would suggest you find a different convention, e.g. distinguish f(i) and f(i, NULL). For the exception, look at `[.data.frame`, which does use nargs(). (NB: what I have said does not apply to primitives like '[' itself, which do not do standard argument matching.) foo <- function(i, j){ print(missing(j)) print(nargs()) } foo(i) # TRUE, 1 foo(i,) # TRUE, 2 I know I can work around with nargs, the list of arguments and the names of the passed arguments, but I wish there is something already in place for this. This is specially important for '['-like methods where x[i,] is not the same as x[i]. What I am looking for is a function that tells me if an argument has actually been passed empty: foo <- function(i, j, k){ print( empty.arg(j) ) print(nargs()) } would result in: foo(i) # FALSE, 1 foo(i, ) # TRUE, 2 foo(i, j) # FALSE, 2 foo(i, k=2) # FALSE, 2 foo(i, k=2, ) # TRUE, 3 Thank you for any help or pointer. Bests, Renaud ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Extending type list: names and inherited methods issue
Hi, I want to extend the type list, but it looks like the names are not handled properly (in the show method), not the [ method. See below for code example. I imagine this comes from the S3/S4 mixing, but I would like to understand and the recommended work around (that avoid redefining all the list methods [, $, etc...). Thank you. Bests, Renaud # define S4 class that inherits from list setClass('A', contains='list') # nothing to say when one creates an object with an unnamed list x <- new('A', list(1,2,3)) x # set the names: seems ok but they are not printed names(x) <- letters[1:3] names(x) x # same thing if one put the S3 .Data slot names(x@.Data) <- letters[4:6] names(x) x # the subsetting works but returns a list instead of the expected object of class A class(x[1]) > sessionInfo() R version 2.12.1 (2010-12-16) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_ZA.utf8 LC_NUMERIC=C LC_TIME=en_ZA.utf8LC_COLLATE=en_ZA.utf8 LC_MONETARY=C LC_MESSAGES=en_ZA.utf8LC_PAPER=en_ZA.utf8 [8] LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=CLC_MEASUREMENT=en_ZA.utf8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Why does slot<- duplicate its argument?
Hi, is there a reason why `slot<-` should duplicate its argument? I am under R 2.12.1. Thank you, Renaud For example: setClass('A', representation(data='matrix')) a <- new('A') x <- matrix(1,2,3) tracemem(x) slot(a, 'data') <- x ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Class not found when search in .onLoad
Hi, I am facing with a strange behaviour of isClass and extends when these are called in .onLoad in both R 2.12.1 and R 2.13.0. This is preventing my package from doing some object initializations at a proper place (i.e. in .onLoad). Suppose one defines two S4 classes in a package, and that one needs to check the inheritance between these two when loading the package (e.g. to validate slots in objects). See package attached or code below (not sure attachments can go through). in R 2.13.0: At the loading check after installation, the classes are not found by `isClass` and `extends` when these are called in .onLoad, but are correctly found when called in .onAttach. However findClass correctly finds the class in both case, as well as isClass if it is called with the argument `where=asNamespace('')`. When the package is loaded from an open R session, the behaviour is the same. in R 2.12.1: the classes are correctly found by isClass and extends when these are called in .onLoad or .onAttach, but only at installation (i.e. at the loading check after R CMD INSTALL). When the package is loaded from an open R session, one fails to find the classes only in .onLoad while in .onAttach they are correctly found. This is really an issue as up to now I was using .onAttach to do my checks and initialization, but it is not a wise thing as package that would only need to import my package (load and not attach) will not get internal objects properly initialized. All this should be done in .onLoad, but I cannot do it due to this behaviour of `extends`. Can someone provide some explanations or work around. Thank you, Renaud # script.R setClass('A', representation(data='numeric')) setClass('B', contain='A') check.classes <- function(){ a <- new('A') b <- new('B') message("isClass('A'): ", methods::isClass('A')) message("isClass('A') in namespace: ", methods::isClass('A', where=asNamespace('anRpackage'))) message("findClass('A'): ") print(methods::findClass('A')) message("isClass('B'): ", methods::isClass('B')) message("isClass('B') in namespace: ", methods::isClass('B', where=asNamespace('anRpackage'))) message("findClass('B'): ") print(methods::findClass('B')) message("extends('B', 'A'): ", methods::extends('B', 'A')) message("is(a, 'A'): ", is(a, 'A')) message("inherits(a, 'A'): ", inherits(a, 'A')) message("is(b, 'A'): ", is(b, 'A')) } .onLoad <- function(libname, pkgname=NULL){ cat("\n## .onLoad ##\n") check.classes() } .onAttach <- function(libname, pkgname){ cat("\n## .onAttach ##\n") check.classes() } # Output # R-2.13.0 CMD INSTALL anRpackage_1.0.tar.gz * installing *source* package ‘anRpackage’ ... ** R ** preparing package for lazy loading ** help *** installing help indices ** building package indices ... ** testing if installed package can be loaded ## .onLoad ## isClass('A'): FALSE isClass('A') in namespace: TRUE findClass('A'): [[1]] isClass('B'): FALSE isClass('B') in namespace: TRUE findClass('B'): [[1]] extends('B', 'A'): FALSE is(a, 'A'): TRUE inherits(a, 'A'): TRUE is(b, 'A'): TRUE ## .onAttach ## isClass('A'): TRUE isClass('A') in namespace: TRUE findClass('A'): [[1]] isClass('B'): TRUE isClass('B') in namespace: TRUE findClass('B'): [[1]] extends('B', 'A'): TRUE is(a, 'A'): TRUE inherits(a, 'A'): TRUE is(b, 'A'): TRUE * DONE (anRpackage) # From a R-2.12.1 Console ## .onLoad ## isClass('A'): FALSE isClass('A') in namespace: TRUE findClass('A'): [[1]] isClass('B'): FALSE isClass('B') in namespace: TRUE findClass('B'): [[1]] extends('B', 'A'): FALSE is(a, 'A'): TRUE inherits(a, 'A'): TRUE is(b, 'A'): TRUE ## .onAttach ## isClass('A'): TRUE isClass('A') in namespace: TRUE findClass('A'): [[1]] isClass('B'): TRUE isCla
Re: [Rd] Class not found when search in .onLoad
Thank you John for your response. Things are a little bit more complicated though. The inheritance checks are not only made in .onLoad, they are part of a class validity method, which is called in .onLoad because some objects from this class are created at this stage. Such objects can also be created at any moment, not in a call from .onLoad. More or less briefly: class 'A' is in fact a virtual class defined in the package's namespace, with the purpose of defining a common interface. While the package does provide some derived classes (i.e. defined within the namespace), users too must be able to define derived classes from 'A' (i.e. not defined within the namespace). In another class from the namespace, the validity method checks that one of its character slot contains the name of a class that inherits from interface 'A'. I was just expecting `isClass` and `extends` to also work in .onLoad without specifying the argument `where` (i.e. searching everywhere, starting by the package's namespace if called within a namespace). The argument `where` being there to allow finer search. There is no argument pkgname to the validity method, to directly apply the work around. I guess I can always check the presence of the class in the some-how hard-coded namespace, and if it is not found there look for the class elsewhere: #... clref <- getClass('A', .Force=TRUE, where=THE.NAMESPACE) cl <- getClass(name, .Force=TRUE, where=THE.NAMESPACE) if( is.null(cl) ) cl <- getClass(name, .Force=TRUE) if( !extends(cl, clref) ) return('invalid slot') #... I will use this, in last resort, although it feels strange as it will only be to deal with the case where objects are created within a call to .onLoad. I am really interested in understanding why all this: - what makes this call so different? In my sample package, if I add a call `check.classes()` directly in script.R, the classes are correctly found when the installation sources the script prepare the package for lazy loading. - why things seemed to work ok in R-2.12.1 at the installation loading check, but do not work when loading the package from an R session? Could you please briefly give some explanations or pointers? Thank you. Bests, Renaud On 23/06/2011 18:44, John Chambers wrote: The workaround is to use the package's namespace, as you did. That's one of the reasons why pkgname is an argument to .onLoad(). Depending on what you want to do, you can either use the namespace as an argument where= or get the class definition from the namespace and use it in place of the class name. A side advantage is that such checks work regardless of whether or not the classes, etc. are exported from the package. Also, on the remote chance there is another class of the same name, the check works unambiguously on your package's version. The relevant part of your script, modified accordingly, seems to work as desired. John # script.R setClass('A', representation(data='numeric')) setClass('B', contains='A') # the argument is contains= check.classes <- function(where){ message("isClass('A', where = where): ", methods::isClass('A', where = where)) message("isClass('B', where = where): ", methods::isClass('B', where = where)) classA <- getClass('A', where = where) classB <- getClass('B', where = where) message("extends(classB, classA): ", methods::extends(classB, classA)) } .onLoad <- function(libname, pkgname=NULL){ cat("\n## .onLoad ##\n") check.classes(asNamespace(pkgname)) } .onAttach <- function(libname, pkgname){ cat("\n## .onAttach ##\n") check.classes(asNamespace(pkgname)) } On 6/23/11 4:22 AM, Renaud Gaujoux wrote: Hi, I am facing with a strange behaviour of isClass and extends when these are called in .onLoad in both R 2.12.1 and R 2.13.0. This is preventing my package from doing some object initializations at a proper place (i.e. in .onLoad). Suppose one defines two S4 classes in a package, and that one needs to check the inheritance between these two when loading the package (e.g. to validate slots in objects). See package attached or code below (not sure attachments can go through). in R 2.13.0: At the loading check after installation, the classes are not found by `isClass` and `extends` when these are called in .onLoad, but are correctly found when called in .onAttach. However findClass correctly finds the class in both case, as well as isClass if it is called with the argument `where=asNamespace('')`. When the package is loaded from an open R session, the behaviour is the same. in R 2.12.1: the classes are correctly found by isClass and extends when these are called in .onLoad or .onAttach, but only at install
Re: [Rd] Class not found when search in .onLoad
On 24/06/2011 22:04, John Chambers wrote: Strictly speaking, that is not meaningful. A class (like any R object) is uniquely referenced by a name *and an environment*. The name of a package can be used to construct the environment, but your "character slot" won't identify a class reliably unless the character string has a "package" attribute. Look at class(x), for example, from an object from one of these classes. It will have a "package" attribute identifying the package. The character string with the package attribute is what you should be storing in the slot (or else store the class definition---takes more space but is slightly more efficient). Thank you for this clarification, I will make my factory method for the relevant class add the package attribute to the slot. Storing the class would require recreating the object if the user makes changes in the class definition. These objects are meant to be used when developing new algorithms. In this context one expects the user to do multiple tries and modifications, and I want to ease the process, by using dynamic links to classes (a character slot) rather than static links (result of getClass). However, this does not explain why .onLoad does not find the class while .onAttach finds it, does it? Is .onLoad evaluated outside the namespace environment, while .onAttach is evaluated within the namespace? Thank you. Renaud ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Class not found when search in .onLoad
On 27/06/2011 14:27, Simon Urbanek wrote: On Jun 27, 2011, at 3:17 AM, Renaud Gaujoux wrote: On 24/06/2011 22:04, John Chambers wrote: Strictly speaking, that is not meaningful. A class (like any R object) is uniquely referenced by a name *and an environment*. The name of a package can be used to construct the environment, but your "character slot" won't identify a class reliably unless the character string has a "package" attribute. Look at class(x), for example, from an object from one of these classes. It will have a "package" attribute identifying the package. The character string with the package attribute is what you should be storing in the slot (or else store the class definition---takes more space but is slightly more efficient). Thank you for this clarification, I will make my factory method for the relevant class add the package attribute to the slot. Storing the class would require recreating the object if the user makes changes in the class definition. These objects are meant to be used when developing new algorithms. In this context one expects the user to do multiple tries and modifications, and I want to ease the process, by using dynamic links to classes (a character slot) rather than static links (result of getClass). However, this does not explain why .onLoad does not find the class while .onAttach finds it, does it? Is .onLoad evaluated outside the namespace environment, while .onAttach is evaluated within the namespace? Look at the default of where - it is the top environment, not the evaluated one, and in .onLoad the namespace is not attached yet while it is in .onAttach. Ok, but .onLoad is defined in the source of the package (i.e. within the package's namespace, am I correct?). So from what I get from the docs (copy/pasted below), isn't the top-environment supposed to be the package's namepsace, even if the package is not yet attached, and its namepace not yet in the search path? from ?isClass " where: The environment in which to modify or remove the definition. Defaults to the top-level environment of the calling function (the global environment for ordinary computations, but the environment or name space of a package in the source for a package). When searching for class definitions, ‘where’ defines where to do the search, and the default is to search from the top-level environment or name space of the caller to this function." from ?topenv "‘topenv’ returns the first top level environment found when searching ‘envir’ and its enclosing environments. An environment is considered top level if it is the internal environment of a name space, a package environment in the search path, or ‘.GlobalEnv’." Cheers, S Possibly @John: it's a bit puzzling that isClass has a default for where yet it is entirely ignored as getClassDef is called without where. If anyone changes the default in getDeffClass() then isClass signature will be misleading - is there a practical reason for this construct? Thanks, S. ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Class not found when search in .onLoad
All is clear now. Thank you for this clarification. Cheers, Renaud On 27/06/2011 15:38, Simon Urbanek wrote: On Jun 27, 2011, at 8:43 AM, Renaud Gaujoux wrote: On 27/06/2011 14:27, Simon Urbanek wrote: On Jun 27, 2011, at 3:17 AM, Renaud Gaujoux wrote: On 24/06/2011 22:04, John Chambers wrote: Strictly speaking, that is not meaningful. A class (like any R object) is uniquely referenced by a name *and an environment*. The name of a package can be used to construct the environment, but your "character slot" won't identify a class reliably unless the character string has a "package" attribute. Look at class(x), for example, from an object from one of these classes. It will have a "package" attribute identifying the package. The character string with the package attribute is what you should be storing in the slot (or else store the class definition---takes more space but is slightly more efficient). Thank you for this clarification, I will make my factory method for the relevant class add the package attribute to the slot. Storing the class would require recreating the object if the user makes changes in the class definition. These objects are meant to be used when developing new algorithms. In this context one expects the user to do multiple tries and modifications, and I want to ease the process, by using dynamic links to classes (a character slot) rather than static links (result of getClass). However, this does not explain why .onLoad does not find the class while .onAttach finds it, does it? Is .onLoad evaluated outside the namespace environment, while .onAttach is evaluated within the namespace? Look at the default of where - it is the top environment, not the evaluated one, and in .onLoad the namespace is not attached yet while it is in .onAttach. Ok, but .onLoad is defined in the source of the package (i.e. within the package's namespace, am I correct?). So from what I get from the docs (copy/pasted below), isn't the top-environment supposed to be the package's namepsace, even if the package is not yet attached, and its namepace not yet in the search path? Not in this case, because where is the methods namespace (see the bottom of my last e-mail - where is not evaluated in environment of your package but in methods due to the default being removed by isClass). I would say this is a bug - changing isClass to the trivial isClass<- function(Class, formal=TRUE, where = topenv(parent.frame())) !is.null(getClassDef(Class, where)) has the desired effect. Cheers, Simon from ?isClass " where: The environment in which to modify or remove the definition. Defaults to the top-level environment of the calling function (the global environment for ordinary computations, but the environment or name space of a package in the source for a package). When searching for class definitions, ‘where’ defines where to do the search, and the default is to search from the top-level environment or name space of the caller to this function." from ?topenv "‘topenv’ returns the first top level environment found when searching ‘envir’ and its enclosing environments. An environment is considered top level if it is the internal environment of a name space, a package environment in the search path, or ‘.GlobalEnv’." Cheers, S Possibly @John: it's a bit puzzling that isClass has a default for where yet it is entirely ignored as getClassDef is called without where. If anyone changes the default in getDeffClass() then isClass signature will be misleading - is there a practical reason for this construct? Thanks, S. ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 9111. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] doMC - compiler - concatenate an expression vector into a single expression?
Hi, this post is about foreach operators, the compiler package and the last update of doMC that includes support for the compiler functionality. I am using a home-made %dopar%-like operator that adds some custom expression to be executed before the foreach loop expression itself (see sample code below). It used to work perfectly with doMC 1.2.1, but with the introduction of the compiler functionality, things do not work properly. The change in the doMC package consists in evaluating a compiled expression instead of the original R expression: # from doMC:::doMC ... c.expr <- comp(expr, env = envir, options = list(suppressUndefined = TRUE)) and for R >= 2.13.0 comp is defined as compiler::compile: function (e, env = .GlobalEnv, options = NULL) { cenv <- makeCenv(env) cntxt <- make.toplevelContext(cenv, options) cntxt$env <- addCenvVars(cenv, findLocals(e, cntxt)) genCode(e, cntxt) } My guess is that the function findLocals or genCode can not handle a 2-length expression vector. Maybe somebody who knows the internals of these functions could explain better this behaviour? How can I concatenate two expressions into a single one? Thank you, Renaud ## # Sample code ## `%dopar2%` <- function(obj, ex){ # append custom code to the expression ex <- c(expression({ a <- i; message("Custom ", a);}), substitute(ex)) # call the standard %dopar% operator do.call(`%dopar%`, list(obj, ex), envir=parent.frame() ) } res <- foreach(i=1:3) %dopar2% { print(i); i*2; } res # # Output with doSEQ or doMC 1.2.1 # Custom 1 [1] 1 Custom 2 [1] 2 Custom 3 [1] 3 > res [[1]] [1] 2 [[2]] [1] 4 [[3]] [1] 6 # # Output with doMC 1.2.2 # [[1]] expression({ a <- i message("Custom ", a) }, { print(i) i * 2 }) [[2]] expression({ a <- i message("Custom ", a) }, { print(i) i * 2 }) [[3]] expression({ a <- i message("Custom ", a) }, { print(i) i * 2 }) -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [R-sig-hpc] doMC - compiler - concatenate an expression vector into a single expression?
Thank you very much Steve. Your suggestion works perfectly -- at least with doSEQ, doMC and doMPI. Bests, Renaud On 28/06/2011 15:35, Stephen Weston wrote: I think that the result of the concatenation should be a call object, rather than an expression object. How about something along the lines of: '%dopar2%'<- function(obj, ex) { ex<- as.call(list(as.name('{'), quote({ a<- i; message("Custom ", a) }), substitute(ex))) do.call('%dopar%', list(obj, ex), envir=parent.frame()) } - Steve On Tue, Jun 28, 2011 at 8:26 AM, Renaud Gaujoux wrote: Hi, this post is about foreach operators, the compiler package and the last update of doMC that includes support for the compiler functionality. I am using a home-made %dopar%-like operator that adds some custom expression to be executed before the foreach loop expression itself (see sample code below). It used to work perfectly with doMC 1.2.1, but with the introduction of the compiler functionality, things do not work properly. The change in the doMC package consists in evaluating a compiled expression instead of the original R expression: # from doMC:::doMC ... c.expr<- comp(expr, env = envir, options = list(suppressUndefined = TRUE)) and for R>= 2.13.0 comp is defined as compiler::compile: function (e, env = .GlobalEnv, options = NULL) { cenv<- makeCenv(env) cntxt<- make.toplevelContext(cenv, options) cntxt$env<- addCenvVars(cenv, findLocals(e, cntxt)) genCode(e, cntxt) } My guess is that the function findLocals or genCode can not handle a 2-length expression vector. Maybe somebody who knows the internals of these functions could explain better this behaviour? How can I concatenate two expressions into a single one? Thank you, Renaud ## # Sample code ## `%dopar2%`<- function(obj, ex){ # append custom code to the expression ex<- c(expression({ a<- i; message("Custom ", a);}), substitute(ex)) # call the standard %dopar% operator do.call(`%dopar%`, list(obj, ex), envir=parent.frame() ) } res<- foreach(i=1:3) %dopar2% { print(i); i*2; } res # # Output with doSEQ or doMC 1.2.1 # Custom 1 [1] 1 Custom 2 [1] 2 Custom 3 [1] 3 res [[1]] [1] 2 [[2]] [1] 4 [[3]] [1] 6 # # Output with doMC 1.2.2 # [[1]] expression({ a<- i message("Custom ", a) }, { print(i) i * 2 }) [[2]] expression({ a<- i message("Custom ", a) }, { print(i) i * 2 }) [[3]] expression({ a<- i message("Custom ", a) }, { print(i) i * 2 }) ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} ___ R-sig-hpc mailing list r-sig-...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-hpc ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] R cmd check and multicore foreach loop
Hi, in R 2.12.1, R CMD check hangs when building a vignette that uses a foreach loop with the doMC parallel backend. This does not happen in R 2.13.1, nor if I use doSEQ instead of doMC. All versions of multicore, doMC and foreach are the same on both my R installations. Has anybody encountered a similar issue? Thank you. Renaud ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R cmd check and multicore foreach loop
I did notice some strange behaviour once, but things were working without a problem for a while now. foreach loops and concepts are nice concepts, which I'd like to carry on using. Maybe somebody from the foreach-dopar packages could explain why they have such issues? Tim do you have concrete examples of the issues you talked with other developers? Thank you. Renaud On 17/08/2011 12:45, Tim Triche, Jr. wrote: > yes -- doMC (and doSMP) are kind of bogus and I just use > multicore::mclapply() to good effect these days. I checked around > with other people doing similar things at the Bioconductor developer > day and pretty much everyone confirmed that doWHATEVER seems to have > issues, where as multicore itself... doesn't. > > Just my $0.02, > > --t > > > On Wed, Aug 17, 2011 at 1:45 AM, Renaud Gaujoux > mailto:ren...@mancala.cbio.uct.ac.za>> > wrote: > > Hi, > > in R 2.12.1, R CMD check hangs when building a vignette that uses > a foreach loop with the doMC parallel backend. > This does not happen in R 2.13.1, nor if I use doSEQ instead of doMC. > All versions of multicore, doMC and foreach are the same on both > my R installations. > > Has anybody encountered a similar issue? > > Thank you. > Renaud > > > > > ### > UNIVERSITY OF CAPE TOWN > This e-mail is subject to the UCT ICT policies and > e-mai...{{dropped:5}} > > __ > R-devel@r-project.org <mailto:R-devel@r-project.org> mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > > > > > -- > > > If people do not believe that mathematics is simple, it is > only because they do not realize how complicated life is. > > John von Neumann > <http://www-groups.dcs.st-and.ac.uk/%7Ehistory/Biographies/Von_Neumann.html> > ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:9}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R cmd check and multicore foreach loop
hopefully you'll be able to create a reproducible example, as my hanging issues seem to come and go without any obvious reason. On 17/08/2011 13:50, Tim Triche, Jr. wrote: > I'll see if I can put together a self-contained example. Primarily, > the times that I use multicore (and attempted to use doSMP, mostly > because one of my users refuses to ditch Windows) are when I am > reading a ton of binary files, none of which depend on the others. > This is a blindingly obvious use-case for e.g. doMC and doSMP, yet > what typically happens is that the entire operation wedges. I'm told > that doSMP really only works well with Revolution R, but per above, I > will try to put together a working self-contained example to show how. > > > On Wed, Aug 17, 2011 at 4:39 AM, Renaud Gaujoux <mailto:ren...@cbio.uct.ac.za>> wrote: > > I did notice some strange behaviour once, but things were working > without a problem for a while now. > foreach loops and concepts are nice concepts, which I'd like to > carry on using. > Maybe somebody from the foreach-dopar packages could explain why > they have such issues? > > Tim do you have concrete examples of the issues you talked with > other developers? > > Thank you. > > Renaud > > On 17/08/2011 12:45, Tim Triche, Jr. wrote: >> yes -- doMC (and doSMP) are kind of bogus and I just use >> multicore::mclapply() to good effect these days. I checked >> around with other people doing similar things at the Bioconductor >> developer day and pretty much everyone confirmed that doWHATEVER >> seems to have issues, where as multicore itself... doesn't. >> >> Just my $0.02, >> >> --t >> >> >> On Wed, Aug 17, 2011 at 1:45 AM, Renaud Gaujoux >> > <mailto:ren...@mancala.cbio.uct.ac.za>> wrote: >> >> Hi, >> >> in R 2.12.1, R CMD check hangs when building a vignette that >> uses a foreach loop with the doMC parallel backend. >> This does not happen in R 2.13.1, nor if I use doSEQ instead >> of doMC. >> All versions of multicore, doMC and foreach are the same on >> both my R installations. >> >> Has anybody encountered a similar issue? >> >> Thank you. >> Renaud >> >> >> >> >> ### >> UNIVERSITY OF CAPE TOWN >> This e-mail is subject to the UCT ICT policies and >> e-mai...{{dropped:5}} >> >> __ >> R-devel@r-project.org <mailto:R-devel@r-project.org> mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> >> >> >> >> -- >> >> >> If people do not believe that mathematics is simple, it >> is only because they do not realize how complicated life is. >> >> John von Neumann >> >> <http://www-groups.dcs.st-and.ac.uk/%7Ehistory/Biographies/Von_Neumann.html> >> > > ### > > UNIVERSITY OF CAPE TOWN > > This e-mail is subject to the UCT ICT policies and e-mail > disclaimer published on our website at > http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable > from +27 21 650 9111 . This e-mail is > intended only for the person(s) to whom it is addressed. If the > e-mail has reached you in error, please notify the author. If you > are not the intended recipient of the e-mail you may not use, > disclose, copy, redirect or print the content. If this e-mail is > not related to the business of UCT it is sent by the sender in the > sender's individual capacity. > > ### > > > > > -- > When you emerge in a few years, you can ask someone what you missed, > and you'll find it can be summed up in a few minutes. > > Derek Sivers <http://sivers.org/berklee> > ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:9}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R cmd check and multicore foreach loop
Uhm... maybe this is the issue. The issue seems to specially occur when I am building the vignette, which performs some parallel computations on a reduced example, therefore faster than in a normal usage of the package. The two processes (on my dual core) output some logging information using cat, which are normally sent to the console, but I guess that in the case of a vignette these are written to tex file. It is very few data though (a loop counter), so writing should be also very quick, even in a file. Could it be possible that a I/O deadlock happens because of this output? I actually use mutexes, at the end of each loop to perform bigger writing operation on a common file, but I hadn't think these would be required for the logging output, assuming that stdout and stderr were thread safe. Maybe I should use mutexes at this level too. Does multicore or doMC provide optional separate logging as doMPI does? (I guess this might be better posted to R-hpc) Thank you. Renaud On 17/08/2011 14:56, Brian G. Peterson wrote: On Wed, 2011-08-17 at 04:50 -0700, Tim Triche, Jr. wrote: I'll see if I can put together a self-contained example. Primarily, the times that I use multicore (and attempted to use doSMP, mostly because one of my users refuses to ditch Windows) are when I am reading a ton of binary files, none of which depend on the others. This is a blindingly obvious use-case for e.g. doMC and doSMP, yet what typically happens is that the entire operation wedges. I'm told that doSMP really only works well with Revolution R, but per above, I will try to put together a working self-contained example to show how. Remember that physical I/O can bind up the processes too. Having a bunch of processes all trying to read from local disk at the same time (especially when they are all trying to read the same file(s), a problem it seems you may not have) is a recipe for I/O locks that can seize up your processes. So, if the problem only occurs with physical I/O, the first thing I would try is to move that storage to a storage device on another machine that is tuned for that level of disk I/O. Regards, - Brian ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] getNativeSymbolInfo("user_unif_rand") returns different results on windows and linux
Hi, When loading a package that provides the user-supplied RNG hook user_unif_rand, calling getNativeSymbolInfo("user_unif_rand") returns informations about the loaded symbol. I am using this to identify which package currently provides the RNG hook. The results are the same on windows and linux if only one library provides the hook. If one loads a second package that provides this hook, then on linux (Ubuntu 10.10), calling again getNativeSymbolInfo("user_unif_rand") returns the latest symbol information (which I presume is the correct result). On windows (XP and Vista) however the symbol information does not change (same pointer address) and the package data is NULL. See results for both systems below. I tested this with R 2.12.1, 2.13.0 and 2.13.1 on Windows. Is this a normal behaviour for dll loaded on Windows? Thank you. Renaud # # LINUX # > library(rlecuyer) > getNativeSymbolInfo("user_unif_rand") $name [1] "user_unif_rand" $address attr(,"class") [1] "NativeSymbol" $package DLL name: rlecuyer Filename: /home/renaud/R/x86_64-pc-linux-gnu-library/2.12/rlecuyer/libs/rlecuyer.so Dynamic lookup: TRUE attr(,"class") [1] "NativeSymbolInfo" > library(rstream) > getNativeSymbolInfo("user_unif_rand") $name [1] "user_unif_rand" $address attr(,"class") [1] "NativeSymbol" $package DLL name: rstream Filename: /home/renaud/R/x86_64-pc-linux-gnu-library/2.12/rstream/libs/rstream.so Dynamic lookup: TRUE attr(,"class") [1] "NativeSymbolInfo" # # WINDOWS # > library(rlecuyer) > getNativeSymbolInfo("user_unif_rand") $name [1] "user_unif_rand" $address attr(,"class") [1] "NativeSymbol" $package DLL name: rlecuyer Filename: C:/Program Files/R/R-2.13.1/library/rlecuyer/libs/i386/rlecuyer.dll Dynamic lookup: TRUE attr(,"class") [1] "NativeSymbolInfo" > library(rstream) > getNativeSymbolInfo("user_unif_rand") $name [1] "user_unif_rand" $address attr(,"class") [1] "NativeSymbol" $package NULL attr(,"class") [1] "NativeSymbolInfo" ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] getNativeSymbolInfo("user_unif_rand") returns different results on windows and linux
Hi, sorry to bump this post but I did not get any reply on this puzzling issue, which looks important though. While investigating the issue it came out that the value returned by getNativeSymbolInfo('user_unif_rand') (on Windows XP) seems to depend on whether it has already been called on the same symbol (see test code below. Each sequence needs to be run on on a fresh R session). Things works perfectly under Linux. Thank you for any explanation on the matter. Renaud ## SEQUENCE 1 ## library(rstream) getNativeSymbolInfo('user_unif_rand') # this returns complete info pointing to rstream's hook RESULT $name [1] "user_unif_rand" $address attr(,"class") [1] "NativeSymbol" $package DLL name: rstream Filename: C:/Program Files/R/R-2.13.1/library/rstream/libs/i386/rstream.dll Dynamic lookup: TRUE attr(,"class") [1] "NativeSymbolInfo" # call again getNativeSymbolInfo getNativeSymbolInfo('user_unif_rand') # this returns INcomplete info pointing to rstream's hook ### RESULT $name [1] "user_unif_rand" $address attr(,"class") [1] "NativeSymbol" $package NULL attr(,"class") [1] "NativeSymbolInfo" ## SEQUENCE 2 ## library(rstream) library(rlecuyer) getNativeSymbolInfo('user_unif_rand') # this returns complete info pointing to relcuyer's hook ## RESULT ## $name [1] "user_unif_rand" $address attr(,"class") [1] "NativeSymbol" $package DLL name: rlecuyer Filename: C:/Program Files/R/R-2.13.1/library/rlecuyer/libs/i386/rlecuyer.dll Dynamic lookup: TRUE attr(,"class") [1] "NativeSymbolInfo" ## SEQUENCE 3 ## ### Load library that provides a hook for user_unif_rand library(rstream) getNativeSymbolInfo('user_unif_rand') # this returns complete info pointing to rstream's hook ## RESULT ## $name [1] "user_unif_rand" $address attr(,"class") [1] "NativeSymbol" $package DLL name: rstream Filename: C:/Program Files/R/R-2.13.1/library/rstream/libs/i386/rstream.dll Dynamic lookup: TRUE attr(,"class") [1] "NativeSymbolInfo" ## ### Load other library that provides the hook library(rlecuyer) getNativeSymbolInfo('user_unif_rand') # this returns INcomplete info pointing to rstream's hook ## RESULT ## $name [1] "user_unif_rand" $address attr(,"class") [1] "NativeSymbol" $package NULL attr(,"class") [1] "NativeSymbolInfo" > sessionInfo() R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_South Africa.1252 LC_CTYPE=English_South Africa.1252 [3] LC_MONETARY=English_South Africa.1252 LC_NUMERIC=C [5] LC_TIME=English_South Africa.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rlecuyer_0.3-1 rstream_1.3.1 ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] getNativeSymbolInfo("user_unif_rand") returns different results on windows and linux
Hi Martin, oups... I indeed had not seen this reply (maybe I should drink less water). Thank you and sorry for the gross bump. Duncan, thank you for the work around. A cache issue makes sense as shown by the sample code in my bump-post. The cache could be updated when loading a new DLL, by looking up it symbols against the cache. Another issue is illustrated by the following calls: library(rstream) getNativeSymbolInfo("user_unif_rand", "rstream") getNativeSymbolInfo("user_unif_rand", "rstream") Although one specifies the package here, the results are different (see below: the first returns the complete information, the second has a NULL element package). I noticed other issues which makes very difficult to predict which DLL will actually be resolved (e.g. when one plays with loading/unloading packages that provides the hook), but I guess caching is behind all these. Renaud > library(rstream) > getNativeSymbolInfo("user_unif_rand", "rstream") $name [1] "user_unif_rand" $address attr(,"class") [1] "NativeSymbol" $package DLL name: rstream Filename: C:/Program Files/R/R-2.13.1/library/rstream/libs/i386/rstream.dll Dynamic lookup: TRUE attr(,"class") [1] "NativeSymbolInfo" > getNativeSymbolInfo("user_unif_rand", "rstream") $name [1] "user_unif_rand" $address attr(,"class") [1] "NativeSymbol" $package NULL attr(,"class") [1] "NativeSymbolInfo" On 23/08/2011 17:58, Martin Morgan wrote: > Hi Renaud -- did you miss this > > https://stat.ethz.ch/pipermail/r-devel/2011-August/061812.html > > ? Martin > > On 08/23/2011 07:40 AM, Renaud Gaujoux wrote: >> Hi, >> >> sorry to bump this post but I did not get any reply on this puzzling >> issue, which looks important though. >> >> While investigating the issue it came out that the value returned by >> getNativeSymbolInfo('user_unif_rand') (on Windows XP) seems to depend on >> whether it has already been called on the same symbol (see test code >> below. Each sequence needs to be run on on a fresh R session). >> >> Things works perfectly under Linux. >> >> Thank you for any explanation on the matter. >> >> Renaud >> >> ## SEQUENCE 1 ## >> library(rstream) >> getNativeSymbolInfo('user_unif_rand') >> # this returns complete info pointing to rstream's hook >> RESULT >> $name >> [1] "user_unif_rand" >> >> $address >> >> attr(,"class") >> [1] "NativeSymbol" >> >> $package >> DLL name: rstream >> Filename: C:/Program >> Files/R/R-2.13.1/library/rstream/libs/i386/rstream.dll >> Dynamic lookup: TRUE >> >> attr(,"class") >> [1] "NativeSymbolInfo" >> >> >> # call again getNativeSymbolInfo >> getNativeSymbolInfo('user_unif_rand') >> # this returns INcomplete info pointing to rstream's hook >> ### RESULT >> $name >> [1] "user_unif_rand" >> >> $address >> >> attr(,"class") >> [1] "NativeSymbol" >> >> $package >> NULL >> >> attr(,"class") >> [1] "NativeSymbolInfo" >> >> >> >> ## SEQUENCE 2 ## >> library(rstream) >> library(rlecuyer) >> getNativeSymbolInfo('user_unif_rand') >> # this returns complete info pointing to relcuyer's hook >> ## RESULT ## >> $name >> [1] "user_unif_rand" >> >> $address >> >> attr(,"class") >> [1] "NativeSymbol" >> >> $package >> DLL name: rlecuyer >> Filename: C:/Program >> Files/R/R-2.13.1/library/rlecuyer/libs/i386/rlecuyer.dll >> Dynamic lookup: TRUE >> >> attr(,"class") >> [1] "NativeSymbolInfo" >> >> >> ## SEQUENCE 3 ## >> ### Load library that provides a hook for user_unif_rand >> library(rstream) >> getNativeSymbolInfo('user_unif_rand') >> # this returns complete info pointing to rstream's hook >> ## RESULT ## >> $name >> [1] "user_unif_rand" >> >> $address >> >> attr(,"class") >> [1] "NativeSymbol" >> >> $package >> DLL name: rstream >> Filename: C:/Program >> Files/R/R-2.13
[Rd] List S3 methods and defining packages
Hi, from the man page ?methods, I expected to be able to build pairs (class,package) for a given S3 method, e.g., print, using attr(methods(print), 'info'). However all the methods, except the ones defined in base or S4 methods, get the 'from' value "registered S3method for print", instead of the actual package name (see below for the first rows). Is this normal behaviour? If so, is there a way to get what I want: a character vector mapping class to package (ideally in loading order, but this I can re-order from search()). Thank you. Bests, Renaud visible from generic isS4 print.abbrev FALSE registered S3method for print print FALSE print.acf FALSE registered S3method for print print FALSE print.AES FALSE registered S3method for print print FALSE print.agnesFALSE registered S3method for print print FALSE print.anovaFALSE registered S3method for print print FALSE print.AnovaFALSE registered S3method for print print FALSE print.anova.loglm FALSE registered S3method for print print FALSE print,ANY-methodTRUE base print TRUE print.aov FALSE registered S3method for print print FALSE __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] List S3 methods and defining packages
Thank you for your reply Martin. Your code made me realize that S3 methods are added to the .__S3MethodsTable__. of the package that defines the generic, not to the ones defining the method itself. How does things work in the case of a method from one package B masking the one from another package A? I don't get any warning message and there seems to be only one entry in the relevant .__S3MethodsTable__. Aren't these tables updated when the masking package B is detached? On 7 July 2015 at 21:01, Martin Morgan wrote: > On 07/07/2015 02:05 AM, Renaud Gaujoux wrote: >> >> Hi, >> >> from the man page ?methods, I expected to be able to build pairs >> (class,package) for a given S3 method, e.g., print, using >> >> attr(methods(print), 'info'). >> >> However all the methods, except the ones defined in base or S4 >> methods, get the 'from' value "registered S3method for print", instead >> of the actual package name (see below for the first rows). >> >> Is this normal behaviour? If so, is there a way to get what I want: a >> character vector mapping class to package (ideally in loading order, >> but this I can re-order from search()). > > > It's the way it has always been, so normal in that sense. > > There could be two meanings of 'from' -- the namespace in which the generic > to which the method belongs is defined, and the namespace in which the > method is defined. I think the former is what you're interested in, but the > latter likely what methods() might be modified return. > > For your use case, maybe something like > > .S3methodsInNamespace <- function(envir, pattern) { > mtable <- get(".__S3MethodsTable__.", envir = asNamespace(envir)) > methods <- ls(mtable, pattern = pattern) > env <- vapply(methods, function(x) { > environmentName(environment(get(x, mtable))) > }, character(1)) > setNames(names(env), unname(env)) > } > > > followed by > > nmspc = loadedNamespaces() > lapply(setNames(nmspc, nmspc), .S3methodsInNamespace, "^plot.") > > which reveals the different meanings of 'from', e.g., > >> lapply(setNames(nmspc, nmspc), .S3methodsInNamespace, >> "^plot.")["graphics"] > $graphics >stats graphicsstats > "plot.acf""plot.data.frame" "plot.decomposed.ts" > graphicsstatsstats > "plot.default""plot.dendrogram" "plot.density" >stats graphics graphics > "plot.ecdf""plot.factor" "plot.formula" > graphicsstats graphics > "plot.function""plot.hclust" "plot.histogram" >statsstatsstats > "plot.HoltWinters""plot.isoreg""plot.lm" >statsstatsstats > "plot.medpolish" "plot.mlm" "plot.ppr" >statsstats stats >"plot.prcomp" "plot.princomp" "plot.profile.nls" > graphicsstatsstats >"plot.raster" "plot.spec" "plot.stepfun" >stats graphicsstats > "plot.stl" "plot.table""plot.ts" >statsstats > "plot.tskernel" "plot.TukeyHSD" > > Also this is for loaded, rather than attached, namespaces. > > Martin Morgan > >> Thank you. >> >> Bests, >> Renaud >> >> visible >> from generic isS4 >> print.abbrev FALSE registered >> S3method for print print FALSE >> print.acf FALSE registered >> S3method for print print FALSE >> print.AES FALSE registered >> S3method for print print FALSE >> print.agnesFALSE registered >> S3method for print print FALSE >> print.anovaFALSE registered >> S3method for print print FALSE >> print.Anova
Re: [Rd] List S3 methods and defining packages
Thanks Kevin, this indeed clarifies a bit the S3 method registration universe. On 8 July 2015 at 15:48, Kevin Wright wrote: > Not sure if this answers your question, but you can't unregister a method. > See > > http://tolstoy.newcastle.edu.au/R/help/06/07/30791.html > > Kevin Wright > > > On Wed, Jul 8, 2015 at 5:09 AM, Renaud Gaujoux > wrote: >> Thank you for your reply Martin. >> Your code made me realize that S3 methods are added to the >> .__S3MethodsTable__. of the package that defines the generic, not to >> the ones defining the method itself. >> How does things work in the case of a method from one package B >> masking the one from another package A? I don't get any warning >> message and there seems to be only one entry in the relevant >> .__S3MethodsTable__. >> Aren't these tables updated when the masking package B is detached? >> >> On 7 July 2015 at 21:01, Martin Morgan wrote: >>> On 07/07/2015 02:05 AM, Renaud Gaujoux wrote: >>>> >>>> Hi, >>>> >>>> from the man page ?methods, I expected to be able to build pairs >>>> (class,package) for a given S3 method, e.g., print, using >>>> >>>> attr(methods(print), 'info'). >>>> >>>> However all the methods, except the ones defined in base or S4 >>>> methods, get the 'from' value "registered S3method for print", instead >>>> of the actual package name (see below for the first rows). >>>> >>>> Is this normal behaviour? If so, is there a way to get what I want: a >>>> character vector mapping class to package (ideally in loading order, >>>> but this I can re-order from search()). >>> >>> >>> It's the way it has always been, so normal in that sense. >>> >>> There could be two meanings of 'from' -- the namespace in which the generic >>> to which the method belongs is defined, and the namespace in which the >>> method is defined. I think the former is what you're interested in, but the >>> latter likely what methods() might be modified return. >>> >>> For your use case, maybe something like >>> >>> .S3methodsInNamespace <- function(envir, pattern) { >>> mtable <- get(".__S3MethodsTable__.", envir = asNamespace(envir)) >>> methods <- ls(mtable, pattern = pattern) >>> env <- vapply(methods, function(x) { >>> environmentName(environment(get(x, mtable))) >>> }, character(1)) >>> setNames(names(env), unname(env)) >>> } >>> >>> >>> followed by >>> >>> nmspc = loadedNamespaces() >>> lapply(setNames(nmspc, nmspc), .S3methodsInNamespace, "^plot.") >>> >>> which reveals the different meanings of 'from', e.g., >>> >>>> lapply(setNames(nmspc, nmspc), .S3methodsInNamespace, >>>> "^plot.")["graphics"] >>> $graphics >>>stats graphicsstats >>> "plot.acf""plot.data.frame" "plot.decomposed.ts" >>> graphicsstatsstats >>> "plot.default""plot.dendrogram" "plot.density" >>>stats graphics graphics >>> "plot.ecdf""plot.factor" "plot.formula" >>> graphicsstats graphics >>> "plot.function""plot.hclust" "plot.histogram" >>>statsstatsstats >>> "plot.HoltWinters""plot.isoreg""plot.lm" >>>statsstatsstats >>> "plot.medpolish" "plot.mlm" "plot.ppr" >>>statsstatsstats >>>"plot.prcomp" "plot.princomp" "plot.profile.nls" >>> graphicsstatsstats >>>"plot.raster" "plot.spec" "plot.stepfun" >>>stats graphicsstats >>> "plot.stl" "plot.table"
[Rd] Method from package dependency is not updated due to lazy load?
Hi, not sure this is a bug or just an unavoidable undesirable side-effect -- or just me that does not do the right thing. Consider the code and output below. It creates 2 packages: * pkgA * pkgB that creates a method for a generic defined in pkgA Changes in a method for the generic in pkgA (after re-installing pkgA) are not reflected in pkgB, unless pkgB is re-installed against the new version of pkgA. I understand this may be linked to lazy-loading, which somehow keeps the old method version. More worrying is the fact that calling pkgA::genericA() in .GlobalEnv still calls the old version. I guess this is due to lazy-load caching the method definition, but is this normal/known behaviour? This means that all the packages that depend on pkgA must be re-installed, even after small internal changes that do not affect the interface or behavior of the exported generic, e.g., internal functions with new required arguments used in the imported generic (which is the error that got me looking into this). Updating reverse-dependencies when installing pkgA could solve the issue (default with message, and optionally disabled). At minimum, a warning when loading pkgB could notify the user that there could be issues due to version discrepancy. Thank you. Bests, Renaud ## Code library(devtools) unlink('test', recursive = TRUE) dir.create('test/lib', recursive = TRUE) # create packages createA <- function(version){ dir.create(file.path('test', version), recursive = TRUE) pdir <- file.path('test', version, 'pkgA') create(pdir, list(Depends = 'methods'), rstudio = FALSE) cat(sprintf(" setGeneric('genericA', function(x) standardGeneric('genericA')) setMethod('genericA', 'missing', function(x) 'A-%s')", version), file = file.path(pdir, 'R/function.R')) } createA('v1') createA('v2') # package B imports A create('test/pkgB', list(Imports = 'pkgA', Depends = 'methods'), rstudio = FALSE) cat('import(pkgA)', file = 'test/pkgB/NAMESPACE', append = TRUE) cat(" callA <- function() genericA() setGeneric('genericA', package = 'pkgA') setMethod('genericA', 'character', function(x) genericA()) ", file = 'test/pkgB/R/function.R') # install packages install.packages('test/v1/pkgA', lib = 'test/lib', repos = NULL, quiet = TRUE) install.packages('test/pkgB', lib = 'test/lib', repos = NULL, quiet = TRUE) # this returns A-v1 system("Rscript -e \"library(pkgA, lib = 'test/lib'); genericA()\"") system("Rscript -e \"library(pkgB, lib = 'test/lib'); callA(); pkgA::genericA()\"") # install pkgA version 2 install.packages('test/v2/pkgA', lib = 'test/lib', repos = NULL, quiet = TRUE) # this returns A-v2 system("Rscript -e \"library(pkgA, lib = 'test/lib'); genericA()\"") # this still returns A-v1 system("Rscript -e \"library(pkgB, lib = 'test/lib'); callA(); pkgA::genericA()\"") # re-install pkgB install.packages('test/pkgB', lib = 'test/lib', repos = NULL, quiet = TRUE) # this now returns A-v2 system("Rscript -e \"library(pkgB, lib = 'test/lib'); callA(); pkgA::genericA()\"") ### Output > library(devtools)> unlink('test', recursive = TRUE)> dir.create('test/lib', > recursive = TRUE)> # create packages> createA <- function(version){+ > dir.create(file.path('test', version), recursive = TRUE)+ pdir <- > file.path('test', version, 'pkgA')+ create(pdir, list(Depends = 'methods'), > rstudio = FALSE)+ cat(sprintf("+ setGeneric('genericA', function(x) > standardGeneric('genericA'))+ setMethod('genericA', 'missing', function(x) > 'A-%s')", version), file = file.path(pdir, 'R/function.R'))+ }> > createA('v1')Creating package 'pkgA' in '/home/renaud/tmp/r-devel/test/v1' No DESCRIPTION found. Creating with values: Package: pkgA Title: What the Package Does (one line, title case) Version: 0.0.0.9000 Authors@R: person("First", "Last", email = "first.l...@example.com", role = c("aut", "cre")) Description: What the package does (one paragraph). Depends: methods License: What license is it under? LazyData: true> createA('v2')Creating package 'pkgA' in '/home/renaud/tmp/r-devel/test/v2' No DESCRIPTION found. Creating with values: Package: pkgA Title: What the Package Does (one line, title case) Version: 0.0.0.9000 Authors@R: person
[Rd] Ubuntu console weird behaviour
Hi, I have been experiencing a weird behavior when running R in Ubuntu terminal. I don't know exactly what triggers the issue and could not find a 100% reproducible way of getting it. The problem is that sometimes (often after an error is thrown, or after copy/paste of plain text from an editor), the console acts as if its width was limited, breaking lines and makes very difficult to navigate into command history or edit previous commands. Essentially, the console is messed up and only comes back to normal when restarting R in a fresh session. I understand it is a bit of a poor error report, but I was hoping that people might have encountered the same issue (and would recognize it as described here). I looked at bash checkwinsize as suggested here and it is on: http://unix.stackexchange.com/questions/61584/how-to-solve-the-issue-that-a-terminal-screen-is-messed-up-usually-after-a-res Thank you. Bests, Renaud My settings are: R version 3.2.3 (2015-12-10) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 15.10 locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_ZA.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_ZA.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_ZA.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_ZA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base -- Renaud Gaujoux, PhD Systems Immunology - Technion, Haifa, Israel [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] .S3methods: issue in content of info data.frame
Hi, I was trying to get a list of S3 method for a given generic, along with the package in which they are defined, and I came across what looks like an issue in the data.frame returned in attribute 'info'. The column 'from' mostly gets the value "registered S3method for ..." except for visible methods. Is this the expected behavior? See code and output below. Thank you. Bests, Renaud $ Rscript -e "library(xtable); attr(.S3methods('plot'), 'info'); sessionInfo()" visible from generic isS4 plot.acf FALSE registered S3method for plotplot FALSE plot.data.frame FALSE registered S3method for plotplot FALSE plot.decomposed.ts FALSE registered S3method for plotplot FALSE plot.default TRUE graphicsplot FALSE plot.dendrogram FALSE registered S3method for plotplot FALSE plot.density FALSE registered S3method for plotplot FALSE plot.ecdf TRUEstatsplot FALSE plot.factor FALSE registered S3method for plotplot FALSE plot.formula FALSE registered S3method for plotplot FALSE plot.function TRUE graphicsplot FALSE plot.hclust FALSE registered S3method for plotplot FALSE plot.histogram FALSE registered S3method for plotplot FALSE plot.HoltWinters FALSE registered S3method for plotplot FALSE plot.isoreg FALSE registered S3method for plotplot FALSE plot.lm FALSE registered S3method for plotplot FALSE plot.medpolish FALSE registered S3method for plotplot FALSE plot.mlm FALSE registered S3method for plotplot FALSE plot.ppr FALSE registered S3method for plotplot FALSE plot.prcomp FALSE registered S3method for plotplot FALSE plot.princompFALSE registered S3method for plotplot FALSE plot.profile.nls FALSE registered S3method for plotplot FALSE plot.raster FALSE registered S3method for plotplot FALSE plot.specFALSE registered S3method for plotplot FALSE plot.stepfun TRUEstatsplot FALSE plot.stl FALSE registered S3method for plotplot FALSE plot.table FALSE registered S3method for plotplot FALSE plot.ts TRUEstatsplot FALSE plot.tskernelFALSE registered S3method for plotplot FALSE plot.TukeyHSDFALSE registered S3method for plotplot FALSE R version 3.3.2 (2016-10-31) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 16.04.1 LTS locale: [1] LC_CTYPE=en_ZA.UTF-8 LC_NUMERIC=C LC_TIME=en_ZA.UTF-8LC_COLLATE=en_ZA.UTF-8 LC_MONETARY=en_ZA.UTF-8 [6] LC_MESSAGES=en_ZA.UTF-8LC_PAPER=en_ZA.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_ZA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets base other attached packages: [1] xtable_1.8-2 loaded via a namespace (and not attached): [1] tools_3.3.2 [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Wish for arima function: add a data argument and a formula-type for regressors
Hi, Using arima on data that are in a data frame, especially when adding xreg, would be much easier if the arima function contained 1) a "data=" argument 2) the possibility to include the covariate(s) in a formula style. Ideally the call could be something like > arima(symptome, order=c(1,0,0), xreg=~trait01*mesure0, data=anxiete) ( or arima(symptome~trait01*mesure0, order=c(1,0,0), data=anxiete) ) instead of present: > anxiete$interact = anxiete$trait01*anxiete$mesure0 > arima(anxiete$symptome, order=c(1,0,0), xreg=anxiete[, c("trait01", "mesure0", "interact")]) Background: Especially in psychology, so-called single case analyses consist often in a the interaction effect of treatment and usual training effect, with typically arma type of error, resulting in the above model. Typically, all the needed data are in a data.frame . An additional advantage concerns the names of the coefficient in the output: if only one regressor: >arima(anxiete$symptome, order=c(1,0,0), xreg=anxiete[, c("trait01")]) [...] Coefficients: ar1 intercept anxiete[, c("trait01")] 0.564933.8623 -8.1225 s.e. 0.1073 0.5969 0.8052 but the name convention changes with several regressors: >arima(anxiete$symptome, order=c(1,0,0), xreg=anxiete[, c("trait01", "mesure0", "interact")]) [...] Coefficients: ar1 intercept trait01 mesure0 interact 0.271534.1363 -5.5777 0.0075 -0.1809 s.e. 0.1211 0.6685 0.9009 0.03420.0490 -- Prof. Olivier Renaud http://www.unige.ch/fapse/mad/ Methodology & Data Analysis - Psychology Dept - University of Geneva UniMail, Office 4138 - 40, Bd du Pont d'Arve - CH-1211 Geneva 4 [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] [Windows] Behaviour of shell on error
Hi, on my R-3.0.2 windows (32bits) no error is thrown occurs when calling a shell command with intern=TRUE, mustWork=TRUE. Is this a intended/known behaviour? >From the source of base::shell it is clear that mustWork is only used when intern=FALSE. This is not that clear from the help page: " Arguments mustWork a logical; if TRUE failure to run the command will give an R error, if FALSE a warning and if NA, no R message. Value If intern = TRUE, a character vector giving the output of the command, one line per character string, or an error message if the command could not be run. " Thank you. Bests, Renaud ## Example ### # no error as expected shell('notacommand') shell('notacommand', intern=TRUE) # error as expected shell('notacommand', mustWork = TRUE) # I am expecting to get an error here as well, but none is thrown shell('notacommand', intern = TRUE, mustWork = TRUE) sessionInfo() ### Output ### > # no error as expected > shell('notacommand') 'notacommand' is not recognized as an internal or external command, operable program or batch file. Warning messages: 1: running command 'C:\Windows\system32\cmd.exe /c notacommand' had status 1 2: In shell("notacommand") : 'notacommand' execution failed with error code 1 > shell('notacommand', intern=TRUE) [1] "'notacommand' is not recognized as an internal or external command," [2] "operable program or batch file." attr(,"status") [1] 1 Warning message: running command 'C:\Windows\system32\cmd.exe /c notacommand' had status 1 > # error as expected > shell('notacommand', mustWork = TRUE) 'notacommand' is not recognized as an internal or external command, operable program or batch file. Error in shell("notacommand", mustWork = TRUE) : 'notacommand' execution failed with error code 1 In addition: Warning message: running command 'C:\Windows\system32\cmd.exe /c notacommand' had status 1 > # I am expecting to get an error here as well, but none is thrown > shell('notacommand', intern = TRUE, mustWork = TRUE) [1] "'notacommand' is not recognized as an internal or external command," [2] "operable program or batch file." attr(,"status") [1] 1 Warning message: running command 'C:\Windows\system32\cmd.exe /c notacommand' had status 1 > > sessionInfo() R version 3.0.2 (2013-09-25) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] cat with backspace and newline characters
Hi, when mixing newline and backspace characters I get the following output (see below). In the second call, the backspace character is simply not applied. Is this normal behaviour? Thank you. > cat("abc\b") ab> cat("abc\b\n") abc > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] cat with backspace and newline characters
I don't know what the normal behaviour is. I was expecting the remaining of the line to be wiped out, but you must be right: the character 'c' is already printed, the cursor moves back one position and go to the next line, leaving the 'c' in place. But what about this one: > cat("abc\b\b\b") > c Here, I end up with the cursor being on the 'c', i.e. if I type something it erase the 'c'. It is strange that the 'c' appears _after_ the console prompt, isn't it? Renaud On 1 November 2013 13:41, Sean O'Riordain wrote: > Hi Renaud, > > Are you sure it's not applied? is \b a backspace i.e. just move the > cursor back one space, or is it a delete the character to the left of > the cursor? > > Kind regards, > Sean > > > On 1 November 2013 11:06, Renaud Gaujoux > wrote: > > Hi, > > > > when mixing newline and backspace characters I get the following output > > (see below). In the second call, the backspace character is simply not > > applied. Is this normal behaviour? > > Thank you. > > > >> cat("abc\b") > > ab> cat("abc\b\n") > > abc > >> > > > > [[alternative HTML version deleted]] > > > > __ > > 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] cat with backspace and newline characters
Maybe it's a Linux problem: > cat("abc\b") ab> cat("abc\b\n") abc > sessionInfo() R version 3.0.2 (2013-09-25) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base > > Sys.info() sysname "Linux" release "3.11.0-12-generic" version "#19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013" nodename "X" machine "x86_64" login "X" user "X" effective_user "X" > On 1 November 2013 19:54, Dennis Murphy wrote: > I can't reproduce the error, either: > > > cat("abc\b") > ab> cat("abc\b\n") > ab > > > > sessionInfo() > R version 3.0.2 (2013-09-25) > Platform: x86_64-w64-mingw32/x64 (64-bit) > > locale: > [1] LC_COLLATE=English_United States.1252 > [2] LC_CTYPE=English_United States.1252 > [3] LC_MONETARY=English_United States.1252 > [4] LC_NUMERIC=C > [5] LC_TIME=English_United States.1252 > > > > Dennis > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] cat with backspace and newline characters
Thanks for the clarification. This appears to be a terminal behaviour issue. It is user lack-of-understanding: there is no error here. > I believe lack of understanding is probably amongst the top reasons why users post to the list and get happily enlightened. I don't think I said there was an error though, but only asked if this was normal behaviour, and apparently many standard Linux terminals get it wrong. This looks a bit sad for a very terminal-driven OS. Renaud [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] cat with backspace and newline characters
> Anyway, > thanks for all the experiments, and (to Renaud) support.rstudio.org is > the place to report such problems. > Funny how the post diverged to an RStudio-related issue. Anyway, I posted a link to this post at support.rstudio.org: http://support.rstudio.org/help/discussions/problems/9242-cat-with-backspace-and-newline-characters/ >From the user point of view, the following behaviour still feels like a strange behaviour of the R prompt: > cat("abc\b\b\b") > c (with the cursor now position on the 'c') I don't know if there is a general official behaviour of prompt characters, but I think one expects the prompt to always follow whatever is printed by the previous R command, without corruption of the input line to be. Renaud [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] How to do package cleanup: hooks .onUnload, R_unload_mylib, .onDetach are not called on quit
Hi, it seems that the package hooks .onLoad and its C++ pendant R_unload_mylib are actually not called when R quits, but only when explicitly calling detach('package:mylib', unload = TRUE). Maybe this is platform specific, I'm on Ubuntu 13.10 - R 3.0.2 (see below). * is there a mechanism that a package can use to effectively do some cleanup on standard exit, such as calling cleaning up routines of a loaded third-party library? I tried .onDetach but it did not work either. * by curiosity, in what kind of practical situation would a user want to call detach(..., unload = TRUE)? * is there a reason why the hooks are not called on quit? Thank you. Bests, Renaud ### > Sys.info() sysname release version "Linux" "3.11.0-12-generic" "#19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013" nodename machinelogin "X" "x86_64" "renaud" user effective_user "renaud" "renaud" > sessionInfo() R version 3.0.2 (2013-09-25) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 [6] LC_MESSAGES=en_US.UTF-8LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C [11] 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] How to do package cleanup: hooks .onUnload, R_unload_mylib, .onDetach are not called on quit
Many thanks for all responses and clarification! It worked great by defining a dummy environment in the package namespace and calling reg.finalizer to "attach" the cleanup function to it. Bests, Renaud On 6 November 2013 13:54, Prof Brian Ripley wrote: > On 06/11/2013 11:36, Duncan Murdoch wrote: >> >> On 13-11-06 5:26 AM, Renaud Gaujoux wrote: >>> >>> Hi, >>> >>> it seems that the package hooks .onLoad and its C++ pendant >>> R_unload_mylib are actually not called when R quits, but only when >>> explicitly calling detach('package:mylib', unload = TRUE). >>> Maybe this is platform specific, I'm on Ubuntu 13.10 - R 3.0.2 (see >>> below). >> >> >> No, this is by design. See ?setHook. >> >>> >>>* is there a mechanism that a package can use to effectively do some >>> cleanup on standard exit, such as calling cleaning up routines of a >>> loaded third-party library? I tried .onDetach but it did not work >>> either. >> >> >> Yes, you can set a finalizer. See ?reg.finalizer. > > > RODBC is one example. > >> >> >> >>>* by curiosity, in what kind of practical situation would a user >>> want to call detach(..., unload = TRUE)? > > > An example is when you want a different version of a package. (That might > now work and probably will not if the package does not unload its DLL.) > > >>>* is there a reason why the hooks are not called on quit? >> >> >> They are slow to run, and are usually not needed. Finalizers handle the >> rare cases where you really do need something to happen. > > > Or to put it another way, the OS will do most of the unloading when it > terminates the process, more efficiently than the process itself can. That > includes 'unloading' DLLs and freeing memory. > > >> >> Duncan Murdoch >> >>> >>> Thank you. >>> >>> Bests, >>> Renaud >>> >>> ### >>>> >>>> Sys.info() >>> >>> >>> sysname release >>>version >>> "Linux" >>> "3.11.0-12-generic" "#19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013" >>> nodename >>> machinelogin >>> "X" >>>"x86_64" "renaud" >>> user >>> effective_user >>> "renaud" >>>"renaud" >>>> >>>> sessionInfo() >>> >>> R version 3.0.2 (2013-09-25) >>> Platform: x86_64-pc-linux-gnu (64-bit) >>> >>> locale: >>> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C >>> LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 >>> LC_MONETARY=en_US.UTF-8 >>> [6] LC_MESSAGES=en_US.UTF-8LC_PAPER=en_US.UTF-8 LC_NAME=C >>> LC_ADDRESS=C LC_TELEPHONE=C >>> [11] 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 > > > > -- > Brian D. Ripley, rip...@stats.ox.ac.uk > 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] cat with backspace and newline characters
I agree that the handling of \b is not that strange, once one agrees on what \b actually means, i.e. "go back one character" and not "delete previous character". The fact that R GUI on Mac and Windows interprets/renders it differently shows that normality and strangeness is quite relative though. To make my previous response clearer, I was just wondering if the printing of R prompt character ">" after the evaluation of an expression could detect trailing \b from cat in stdout/stderr and shift its position so that it is displayed after the last printed character. For example cat("abc\b\b\b") would give abc> and not a> c But this is: 0) Again platform, front-end dependent; 1) maybe not be possible (e.g., can we actually move forward without printing a character that would erase the previous output?) 2) maybe not even desirable; 3) certainly not worth the effort anyway! I guess we can happily close this thread :D Many thanks. Bests, Renaud __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] S4 method for '[' with extra arguments: distinguishing between x[i] and x[i, ]
Hi, I want to implement a '[' for an S4 class, that behaves differently when called with a single index argument or multiple indexes (possibly missing), like what happens when subsetting matrices x[i] vs. x[i, ]. I manage to do it using nargs() and checking if drop is missing (see code below), but when I want to add an extra argument to the method (before drop), then the parent call somehow changes and always includes all indexes in the call (even missing ones) and nargs() always returns the same value. I thought there might be a generic for a single index (with no j in the definition) but could not find its definition, and can't see how setMethod will know for which '[' to define the method. Defining a method for signature(x = 'A', j = 'missing') has the same issue. Is there actually a way to do this? Thank you. Bests, Renaud # Code # Class A setClass('A', contains = 'character') # No extra argument is fine setMethod('[', 'A', function(x, i, j, ..., drop = TRUE){ ca <- match.call() mdrop <- missing(drop) Nargs <- nargs() - !mdrop print(ca) print(nargs()) print(mdrop) print(Nargs) if( !missing(i) && Nargs < 3 ) TRUE else FALSE }) testA <- function(){ a <- new('A') tests <- c('a[1]', 'a[1,]', 'a[,1]') sapply(tests, function(s){ message('\n#', s); message('single arg: ', eval(parse(text = s))) s <- sub(']', ', drop = FALSE]', s, fixed = TRUE) message('\n#', s); message('single arg: ', eval(parse(text = s))) }) invisible() } testA() # with extra argument => cannot distinguish the calls setMethod('[', 'A', function(x, i, j, ..., extra = FALSE, drop = TRUE){ ca <- match.call() mdrop <- missing(drop) Nargs <- nargs() - !mdrop print(ca) print(nargs()) print(mdrop) print(Nargs) if( !missing(i) && Nargs < 3 ) TRUE else FALSE }) testA() # System info sessionInfo() R.version # RESULTS > # Class A > setClass('A', contains = 'character') > > # No extra argument is fine > setMethod('[', 'A', function(x, i, j, ..., drop = TRUE){ + ca <- match.call() + mdrop <- missing(drop) + Nargs <- nargs() - !mdrop + print(ca) + print(nargs()) + print(mdrop) + print(Nargs) + if( !missing(i) && Nargs < 3 ) TRUE + else FALSE + }) [1] "[" > > testA <- function(){ + a <- new('A') + tests <- c('a[1]', 'a[1,]', 'a[,1]') + sapply(tests, function(s){ + message('\n#', s); message('single arg: ', eval(parse(text = s))) + s <- sub(']', ', drop = FALSE]', s, fixed = TRUE) + message('\n#', s); message('single arg: ', eval(parse(text = s))) + }) + invisible() + } > > testA() #a[1] a[i = 1] [1] 2 [1] TRUE [1] 2 single arg: TRUE #a[1, drop = FALSE] a[i = 1, drop = FALSE] [1] 3 [1] FALSE [1] 2 single arg: TRUE #a[1,] a[i = 1] [1] 3 [1] TRUE [1] 3 single arg: FALSE #a[1,, drop = FALSE] a[i = 1, drop = FALSE] [1] 4 [1] FALSE [1] 3 single arg: FALSE #a[,1] a[j = 1] [1] 3 [1] TRUE [1] 3 single arg: FALSE #a[,1, drop = FALSE] a[j = 1, drop = FALSE] [1] 4 [1] FALSE [1] 3 single arg: FALSE > > # with extra argument => cannot distinguish the calls > setMethod('[', 'A', function(x, i, j, ..., extra = FALSE, drop = TRUE){ + ca <- match.call() + mdrop <- missing(drop) + Nargs <- nargs() - !mdrop + print(ca) + print(nargs()) + print(mdrop) + print(Nargs) + if( !missing(i) && Nargs < 3 ) TRUE + else FALSE + }) [1] "[" > > testA() #a[1] .local(x = x, i = i, j = j, drop = drop) [1] 4 [1] FALSE [1] 3 single arg: FALSE #a[1, drop = FALSE] .local(x = x, i = i, j = j, drop = drop) [1] 4 [1] FALSE [1] 3 single arg: FALSE #a[1,] .local(x = x, i = i, j = j, drop = drop) [1] 4 [1] FALSE [1] 3 single arg: FALSE #a[1,, drop = FALSE] .local(x = x, i = i, j = j, drop = drop) [1] 4 [1] FALSE [1] 3 single arg: FALSE #a[,1] .local(x = x, i = i, j = j, drop = drop) [1] 4 [1] FALSE [1] 3 single arg: FALSE #a[,1, drop = FALSE] .local(x = x, i = i, j = j, drop = drop) [1] 4 [1] FALSE [1] 3 single arg: FALSE > > # System info > sessionInfo() R version
[Rd] contrib.url in non-interactive mode
Hi, is it intended that one cannot install packages in non-interactive mode, without explicitly setting a CRAN mirror (see below)? Couldn't a default mirror be used in that case? Thank you. Bests, Renaud $ Rscript --vanilla -e "install.packages('whatever')" Installing package into '/home/renaud/R/x86_64-pc-linux-gnu-library/3.0' (as 'lib' is unspecified) Error in contrib.url(repos, type) : trying to use CRAN without setting a mirror Calls: install.packages -> grep -> contrib.url Execution halted [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Proxy settings not honoured anymore
Hi, it seems that my proxy settings are not picked up by the R console any longer, although the environment variable http_proxy is set and exported. Is anybody experiencing this issue as well? Thank you. Bests, Renaud # System info (from R --vanilla) > sessionInfo() R version 3.0.3 (2014-03-06) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] 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] Proxy settings not honoured anymore
All right, just ignore this silly post, things magically came back into place... :| On 27 March 2014 17:28, Renaud Gaujoux wrote: > Hi, > > it seems that my proxy settings are not picked up by the R console any > longer, although the environment variable http_proxy is set and > exported. > Is anybody experiencing this issue as well? > Thank you. > > Bests, > Renaud > > # System info (from R --vanilla) >> sessionInfo() > R version 3.0.3 (2014-03-06) > Platform: x86_64-pc-linux-gnu (64-bit) > > locale: > [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C > [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 > [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 > [7] LC_PAPER=en_US.UTF-8 LC_NAME=C > [9] LC_ADDRESS=C LC_TELEPHONE=C > [11] 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
[Rd] traceback does not show source line number of long calls when truncating output
Hi, in R-3.1.0 (Linux), traceback() does not show the source file line number for the truncated calls, when limiting the number of lines output for each call with argument max.lines. See sample code, output and session info below (in particular, output for call number 5). I guess this is not intended. Thank you. Bests, Renaud ## File: traceback.R a <- function(...){ stop('this is an error') } # code to generate the long call # set.seed(123) # v <- unique(replicate(10, { paste0(sample(letters[1:26]), collapse = "") })) # sprintf("a(%s)", paste0(v, '=', 1, collapse = ", ")) a(htjuwakqxzpgrsbncvyofdmeli=1, ozgdvsnpaimweybtkulrhcfjxq=1, udnecprhlbgwtfjisyzoxaqmvk=1, jcfpzqyirwotbsehdngauxlkvm=1, mwvojdsfbqlchznegyirpkautx=1, qwzxlnyorhegackmvubfsjtipd=1, ofkylhmugjvdwzscirnexptbqa=1, sgolfwzrevpjnythbqxmdckuai=1, ezlfyoangrspdmihtuxkvwcbqj=1, gjetdqkmvwxufslhcbpirnazoy=1) ## In R source('traceback.R', keep.source = TRUE) traceback() traceback(max.lines = 2) sessionInfo() ## Output > source('traceback.R', keep.source = TRUE) Error in a(htjuwakqxzpgrsbncvyofdmeli = 1, ozgdvsnpaimweybtkulrhcfjxq = 1, : this is an error > traceback() 6: stop("this is an error") at traceback.R#1 5: a(htjuwakqxzpgrsbncvyofdmeli = 1, ozgdvsnpaimweybtkulrhcfjxq = 1, udnecprhlbgwtfjisyzoxaqmvk = 1, jcfpzqyirwotbsehdngauxlkvm = 1, mwvojdsfbqlchznegyirpkautx = 1, qwzxlnyorhegackmvubfsjtipd = 1, ofkylhmugjvdwzscirnexptbqa = 1, sgolfwzrevpjnythbqxmdckuai = 1, ezlfyoangrspdmihtuxkvwcbqj = 1, gjetdqkmvwxufslhcbpirnazoy = 1) at traceback.R#8 4: eval(expr, envir, enclos) 3: eval(ei, envir) 2: withVisible(eval(ei, envir)) 1: source("traceback.R", keep.source = TRUE) > traceback(max.lines = 2) 6: stop("this is an error") at traceback.R#1 5: a(htjuwakqxzpgrsbncvyofdmeli = 1, ozgdvsnpaimweybtkulrhcfjxq = 1, udnecprhlbgwtfjisyzoxaqmvk = 1, jcfpzqyirwotbsehdngauxlkvm = 1, ... 4: eval(expr, envir, enclos) 3: eval(ei, envir) 2: withVisible(eval(ei, envir)) 1: source("traceback.R", keep.source = TRUE) > sessionInfo() R version 3.1.0 (2014-04-10) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 [6] LC_MESSAGES=en_US.UTF-8LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C [11] 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
[Rd] Is it possible to make install.packages compile source code on Unix but use shipped binary on Windows?
Hi, is it possible to make install.packages install a source package by compiling it on Unix, but skip compilation and use a pre-built windows binary (shipped in exec/) if installing on Windows? The package should be installable on Windows machines that do not have Rtools installed. This is to make the update process easier for users, because the C++ code does not change often, meaning that I can just send source packages built on Linux, with a binary executable built once in a while on win-builder. Note that this is for a package that is not meant for CRAN, so no policy issue here. Thank you. Bests, Renaud __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Is it possible to make install.packages compile source code on Unix but use shipped binary on Windows?
Thank you for the replies and hints. > A 'pre-built windows binary' of what? Sorry this was not clear, src/ contains source code for a binary executable, which produces no .lib or .dll. It is all fine in a R development environment: * On Linux, the executable is compiled and copied to R_PACKAGE_DIR/binR_ARCH using a custom install.libs.R script. * Same thing on Windows, if Rtools is installed, install.packages compiles and installs both 32 and 64 bits .exe. > You can easily ship a DLL or .exe for use on Windows: just make use of > configure.win and/or Makefile.win. If you have a Makefile.win it will > override the normal procedures for directory src. I have tried using Makevars.win, but this requires make to be installed (as by Rtools). So I guess using Makefile.win would also not work, on a classic non-development geared Windows host. Would using configure.win work without Rtools? > OTOH, shipping something in exec will be installed everwhere. True, although it seems that sub-directories of exec/ are actually not installed though. Is this intentional? > Watch out for sub-architectures: 'Windows' is in fact two platforms. We > have over the years seen a lot of problem with people shipping 64-bit > Windows binaries: 32-bit Windows does not recognize those. Indeed, and I think I properly take care of this in install.libs.R. @Grabriel: the package is provided as a source package. This one is installable locally from file, although in may case users actually get it through a personal CRAN-like repository, using argument type='both'. Thank you. Bests, Renaud __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Is it possible to make install.packages compile source code on Unix but use shipped binary on Windows?
> Maybe. Read the documentation and sources for yourself (see below). Not working, at least in my hands, as it requires `sh`. > Yes, *and documented* True. I overlooked the beginning of the NB point. > (including that it should not be used for Windows executables). Yes, that's why I use the suggested procedure that uses src/install.libs.R to copy compiled .exe files into bin/. So, eventually, I guess the answer to the original question is: no, one cannot make install.packages skip compilation of a source package, only if on Windows, without having Rtools installed -- and in PATH. Renaud __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Is it possible to make install.packages compile source code on Unix but use shipped binary on Windows?
Hi Martyn, > It isn't hard to set up Rtools on Windows and you only need to do it > once. Then you build a binary package on your development system to > distribute to your users. Yes, but since I am working on Linux, it is slightly more steps involved in order to generate a windows binary (even using a virtual machine), compared to build and push source packages to my repository, for which I have shell scripts and make files that do that in seconds and in batch mode. When working in a fast bug fix-test cycle with windows users testing things out often times a day, these extra steps take much time overall. > Without even considering any technical details there is a purely > strategic issue here. If a system has been set up that is robust and > widely tested, like the R packaging system, you are much better off > working with it than trying to subvert it. Agreed completely. I really like R cross-platform packaging and checking system, and was just wondering if this conditional compilation option was possible using the flexibility of this very system. Renaud __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] install.packages deletes PACKAGES file in local repo
Hi, running install.packages() to install a package from a local repository (i.e., starts with file:///) appears to delete the PACKAGES file that is in the src/contrib/ directory. This happens on a cluster running Scientific Linux release 6.4 (Carbon), but not on my Ubuntu local machine. Subsequent calls to install.packages() complain about src/contrib/PACKAGES not existing, although there still is a src/contrib/PACKAGES.gz file. Is this a know issue? Thank you. Bests, Renaud [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] install.packages deletes PACKAGES file in local repo
Hi, I was only doing install.packages('pkgname'), with the local repo being defined in the default repos option. After retrying it just now, this issue mysteriously suddenly disappeared, and things work as expected whether on the front node or in a job on a node. Really no idea of what happened. Closing the thread. Thanks. On 6 December 2014 at 02:23, Gabriel Becker wrote: > Can you post exact code, i have not seen this behavior, and I work with > local repositories quite extensively on my current project. > > ~G > > On Fri, Dec 5, 2014 at 7:45 AM, Renaud Gaujoux < > ren...@mancala.cbio.uct.ac.za> wrote: > >> Hi, >> >> running install.packages() to install a package from a local repository >> (i.e., starts with file:///) appears to delete the PACKAGES file that is >> in >> the src/contrib/ directory. >> This happens on a cluster running Scientific Linux release 6.4 (Carbon), >> but not on my Ubuntu local machine. >> >> Subsequent calls to install.packages() complain about src/contrib/PACKAGES >> not existing, although there still is a src/contrib/PACKAGES.gz file. >> >> Is this a know issue? >> Thank you. >> >> Bests, >> Renaud >> >> [[alternative HTML version deleted]] >> >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> > > > > -- > Gabriel Becker > Graduate Student > Statistics Department > University of California, Davis > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Error message library()
"BTW: an ever more intuitive solution (IMHO) would be to auto-complete package names in library( ... Deepayan?;) That is non-intrusive and in line with the general use of R." (Simon) This is indeed a long wanted feature and to my surprise it actually already exists!!! (seems that Deepayan did not tell anybody about it ;) ) The help page ?completion in the utils package explains how to enable it: utils::rc.settings(ipck=TRUE) It simply worked on my Ubuntu box -- and directly went in my .Rprofile :) Hope this helps. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Output multiline verbatim in Rd files with \Sexpr in PDF manual
Hi, I want to output some generated text in verbatim in a Rd file, but do not succeed in getting it render well in all versions (text, html and pdf). I tried something like: \Sexpr[results=verbatim, stage=render]{cat("line\nnext line")} I use Rdconv to render each version of the man page. This produced the expected effect in html, but resulted in a single line "line next line" in the pdf and text versions. Moreover, if I add an empty line as in: \Sexpr[results=verbatim, stage=render]{cat("line\nnext line\n\nyet another line")} then the html is still correctly rendered, the text version correctly shows the empty newline (but still not the firts line break), and the pdf cannot be generated from the Latex code (because \AsIs breaks on the newline). I tried several combination of options (results=text, rd) and rd commands (\cr, \preformated) but these are always somehow escaped when generating the Latex file. Is there a way to go around these issues? Maybe I am not using the correct way. Thank you. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] R CMD check and error in an \Sexpr in an Rd file
Hi, another Rd related issue I encountered is that if an error occurs in an \Sexpr in an Rd file, then on get the following error: * checking for portable compilation flags in Makevars ... OK * checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK * checking examples ... ERROR Error in paste(before, x, after, sep = "") : object 'exfile' not found Execution halted To reproduce, put a call like this in an Rd section: \Sexpr[results=verbatim, stage=render]{x <- 1; stop("sexpr error")} The strange thing is that it occurs at the example checking step. Not sure why it does not break before. Thank you. Renaud PS: I am on R version 2.13.2 (2011-09-30) - x86_64-pc-linux-gnu (64-bit) -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check and error in an \Sexpr in an Rd file
Thank you Duncan. I tried with: * using R version 2.14.0 RC (2011-10-24 r57417) * using platform: x86_64-unknown-linux-gnu (64-bit) But I still get the errors for verbatim multiline and the strange error if an error occurs in \Sexpr. Is your patch included in this version? I will try now with R-rc_2011-10-27_r57452.tar.gz. Renaud On 28/10/2011 17:25, Duncan Murdoch wrote: On 28/10/2011 10:53 AM, Duncan Murdoch wrote: On 28/10/2011 10:49 AM, Renaud Gaujoux wrote: > Hi, > > another Rd related issue I encountered is that if an error occurs in an > \Sexpr in an Rd file, then on get the following error: > > * checking for portable compilation flags in Makevars ... OK > * checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK > * checking examples ... ERROR > Error in paste(before, x, after, sep = "") : object 'exfile' not found > Execution halted > > To reproduce, put a call like this in an Rd section: > > \Sexpr[results=verbatim, stage=render]{x<- 1; stop("sexpr error")} > > The strange thing is that it occurs at the example checking step. > Not sure why it does not break before. > > Thank you. > > Renaud > > PS: I am on R version 2.13.2 (2011-09-30) - x86_64-pc-linux-gnu (64-bit) > I would update to 2.13.2 patched, or the release candidate of 2.14.0. Oops, sorry, 2.13.2 is "final", so I didn't backport the patch. 2.14.0 is what you should get. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check and error in an \Sexpr in an Rd file
I do not see it on main CRAN home page. Do you mean http://cran.r-project.org/src/base-prerelease/R-latest.tar.gz ? On 31/10/2011 14:19, Uwe Ligges wrote: On 31.10.2011 13:13, Renaud Gaujoux wrote: Thank you Duncan. I tried with: * using R version 2.14.0 RC (2011-10-24 r57417) * using platform: x86_64-unknown-linux-gnu (64-bit) But I still get the errors for verbatim multiline and the strange error if an error occurs in \Sexpr. Is your patch included in this version? I will try now with R-rc_2011-10-27_r57452.tar.gz. Try R-2.14.0, it is already released. Or R-devel. Best, Uwe Ligges Renaud On 28/10/2011 17:25, Duncan Murdoch wrote: On 28/10/2011 10:53 AM, Duncan Murdoch wrote: On 28/10/2011 10:49 AM, Renaud Gaujoux wrote: > Hi, > > another Rd related issue I encountered is that if an error occurs in an > \Sexpr in an Rd file, then on get the following error: > > * checking for portable compilation flags in Makevars ... OK > * checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK > * checking examples ... ERROR > Error in paste(before, x, after, sep = "") : object 'exfile' not found > Execution halted > > To reproduce, put a call like this in an Rd section: > > \Sexpr[results=verbatim, stage=render]{x<- 1; stop("sexpr error")} > > The strange thing is that it occurs at the example checking step. > Not sure why it does not break before. > > Thank you. > > Renaud > > PS: I am on R version 2.13.2 (2011-09-30) - x86_64-pc-linux-gnu (64-bit) > I would update to 2.13.2 patched, or the release candidate of 2.14.0. Oops, sorry, 2.13.2 is "final", so I didn't backport the patch. 2.14.0 is what you should get. Duncan Murdoch __ 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 CMD check and error in an \Sexpr in an Rd file
Thank you very much Duncan, Uwe and Peter. Sorry if I missed the announcement, I follow more r-devel than r-help, which I find a bit hard to quickly read. Will try now on the 2.14.0. Renaud On 31/10/2011 14:28, Prof Brian Ripley wrote: On Mon, 31 Oct 2011, Renaud Gaujoux wrote: I do not see it on main CRAN home page. No, but see the announcement on R-announce this morning: https://stat.ethz.ch/pipermail/r-help/2011-October/294203.html Things which need human intervention can take some hours: the CRAN front page and binary distributions are two of those. Do you mean http://cran.r-project.org/src/base-prerelease/R-latest.tar.gz ? On 31/10/2011 14:19, Uwe Ligges wrote: On 31.10.2011 13:13, Renaud Gaujoux wrote: Thank you Duncan. I tried with: * using R version 2.14.0 RC (2011-10-24 r57417) * using platform: x86_64-unknown-linux-gnu (64-bit) But I still get the errors for verbatim multiline and the strange error if an error occurs in \Sexpr. Is your patch included in this version? I will try now with R-rc_2011-10-27_r57452.tar.gz. Try R-2.14.0, it is already released. Or R-devel. Best, Uwe Ligges Renaud On 28/10/2011 17:25, Duncan Murdoch wrote: On 28/10/2011 10:53 AM, Duncan Murdoch wrote: On 28/10/2011 10:49 AM, Renaud Gaujoux wrote: > Hi, > > another Rd related issue I encountered is that if an error occurs in an > \Sexpr in an Rd file, then on get the following error: > > * checking for portable compilation flags in Makevars ... OK > * checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK > * checking examples ... ERROR > Error in paste(before, x, after, sep = "") : object 'exfile' not found > Execution halted > > To reproduce, put a call like this in an Rd section: > > \Sexpr[results=verbatim, stage=render]{x<- 1; stop("sexpr error")} > > The strange thing is that it occurs at the example checking step. > Not sure why it does not break before. > > Thank you. > > Renaud > > PS: I am on R version 2.13.2 (2011-09-30) - x86_64-pc-linux-gnu (64-bit) > I would update to 2.13.2 patched, or the release candidate of 2.14.0. Oops, sorry, 2.13.2 is "final", so I didn't backport the patch. 2.14.0 is what you should get. Duncan Murdoch __ 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 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check and error in an \Sexpr in an Rd file
Getting back to the \Sexpr issue, I tried with R-2.14.0 and I still see the following issues: - verbatim multiline is not shown properly on PDF (\Sexpr[results=verbatim, stage=render]{cat("line\nnext line")}) - verbatim with empty lines breaks PDF generation (\Sexpr[results=verbatim, stage=render]{cat("line\nnext line\n\nyet another line")}). Would there be an issue in using a plain Latex verbatim environment for \Sexpr[results=verbatim]? - an error in an \Sexpr (\Sexpr[results=verbatim, stage=render]{stop("error in sexpr")}) gives the following in R CMD check: * checking examples ... ERROR Error in paste(before, x, after, sep = "") : object 'exfile' not found Execution halted The two first issues can be reproduced with a call to R CMD Rd2pdf on the Rd code below. Thank you. Renaud. %%% \name{Sexpr} \alias{Sexpr} \title{Error and verbatim in Sexpr} \description{ Testing Sexpr in Rd files %\Sexpr[results=verbatim, stage=render]{stop("error in sexpr")} \Sexpr[results=verbatim, stage=render]{cat("line\nnext line")} %\Sexpr[results=verbatim, stage=render]{cat("line\nnext line\n\nyet another line")} } %%% -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 28/10/2011 17:25, Duncan Murdoch wrote: On 28/10/2011 10:53 AM, Duncan Murdoch wrote: On 28/10/2011 10:49 AM, Renaud Gaujoux wrote: > Hi, > > another Rd related issue I encountered is that if an error occurs in an > \Sexpr in an Rd file, then on get the following error: > > * checking for portable compilation flags in Makevars ... OK > * checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK > * checking examples ... ERROR > Error in paste(before, x, after, sep = "") : object 'exfile' not found > Execution halted > > To reproduce, put a call like this in an Rd section: > > \Sexpr[results=verbatim, stage=render]{x<- 1; stop("sexpr error")} > > The strange thing is that it occurs at the example checking step. > Not sure why it does not break before. > > Thank you. > > Renaud > > PS: I am on R version 2.13.2 (2011-09-30) - x86_64-pc-linux-gnu (64-bit) > I would update to 2.13.2 patched, or the release candidate of 2.14.0. Oops, sorry, 2.13.2 is "final", so I didn't backport the patch. 2.14.0 is what you should get. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check and error in an \Sexpr in an Rd file
Georgi, I tried with paste() instead of cat(), but I then get the following in my PDF manual: [1] "line\nnext line" i.e. what would be printed in the R console, which is not what I want. I would like to get something like this in the Latex code: \begin{verbatim} line next line \end{verbatim} Using cat() I get the following in the Latex code: \AsIs{ line next line} which does not render as a new line in the PDF and breaks if empty lines are present in the output text. Besides it will also break on \Sexpr[results=verbatim, stage=render]{list("text", 3)}. But maybe this is not what 'results=verbatim' is supposed to do nor to be used for? Renaud Another test Rd file. % \name{Sexpr} \alias{Sexpr} \title{Error and verbatim in Sexpr} \description{ Testing Sexpr in Rd files %\Sexpr[results=verbatim, stage=render]{stop("error in sexpr")} Verbatim: 1: \Sexpr[results=verbatim, stage=render]{cat("line\nnext line\n")} 2: \Sexpr[results=verbatim, stage=render]{"line\nnext line\n"} 3: \Sexpr[results=verbatim, stage=render]{list("line\nnext line", 3)} Text: 1: \Sexpr[results=text, stage=render]{cat("line\nnext line\n")} 2: \Sexpr[results=text, stage=render]{"line\nnext line\n"} 3: \Sexpr[results=text, stage=render]{list("line\nnext line", 3)} } % __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check and error in an \Sexpr in an Rd file
Although I use Latex quite a lot, I am not literate in Latex macro languages (e.g. the definition of AsIs). Is there (I am sure there is) a reason why a plain verbatim environment is not used in this case? On 03/11/2011 14:19, Duncan Murdoch wrote: On 11-11-03 7:58 AM, Renaud Gaujoux wrote: Georgi, I tried with paste() instead of cat(), but I then get the following in my PDF manual: [1] "line\nnext line" i.e. what would be printed in the R console, which is not what I want. I would like to get something like this in the Latex code: \begin{verbatim} line next line \end{verbatim} I don't think you want that: it forces display mode. You might want verbatim text displayed inline, like \verb does. Using cat() I get the following in the Latex code: \AsIs{ line next line} which does not render as a new line in the PDF and breaks if empty lines are present in the output text. So the problem is with the \AsIs macro. You can see the definition in the Rd.sty file in R_HOME/share/texmf/tex/latex. Can you suggest an improvement? Duncan Murdoch Besides it will also break on \Sexpr[results=verbatim, stage=render]{list("text", 3)}. But maybe this is not what 'results=verbatim' is supposed to do nor to be used for? Renaud Another test Rd file. % \name{Sexpr} \alias{Sexpr} \title{Error and verbatim in Sexpr} \description{ Testing Sexpr in Rd files %\Sexpr[results=verbatim, stage=render]{stop("error in sexpr")} Verbatim: 1: \Sexpr[results=verbatim, stage=render]{cat("line\nnext line\n")} 2: \Sexpr[results=verbatim, stage=render]{"line\nnext line\n"} 3: \Sexpr[results=verbatim, stage=render]{list("line\nnext line", 3)} Text: 1: \Sexpr[results=text, stage=render]{cat("line\nnext line\n")} 2: \Sexpr[results=text, stage=render]{"line\nnext line\n"} 3: \Sexpr[results=text, stage=render]{list("line\nnext line", 3)} } % __ 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 CMD check and error in an \Sexpr in an Rd file
Thank you Georgi. With the fix \long the output is indeed consistent with the documentation. I think my use of cat() worked by luck as its output should not have been rendered. Would a 'results=tex' (html, text) be possible? or 'results=source' that could be combined with \if{format}{text}? This would allow to generate custom Latex, or HTML code, but it might also be is hazardous... Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 03/11/2011 15:50, Georgi Boshnakov wrote: Dear Duncan and Renauld, The error caused by the empty line(s) can be removed by prefixin the macro with \long in Rd.sty: \long\def\Rd@AsIsX#1{\normalfont #1\egroup} but the slash-n's come up in the output. In "text mode" this seems not to be a problem. Following normal TeX rules one needs to enter an empty line, e.g. by \n\n. Having written that, I tried putting two \n's in the verbatim text and it seems to work (see below). I need to consult the TeX book to be sure but the problem with AsIs seems to be that by the time it starts processing its argument it has been tokenized by TeX (hence single newlines have become spaces). Further thought may be needed about the new lines in verbatim. I may have missed again something but it seems that the observed output is consistent with the documentation, which states: "results=verbatim Print the results of the code just as if it was executed at the console, and include the printed results verbatim. (Invisible results will not print.)" And the examples print on the console as they appear in output (with print, not cat). Do we need exception from the general rule? An alternative would be to introduce results=verbatimLines option. Georgi \name{Sexpr} \alias{Sexpr} \title{Error and verbatim in Sexpr} \description{ Testing Sexpr in Rd files %\Sexpr[results=verbatim, stage=render]{stop("error in sexpr")} Verbatim: 1: \Sexpr[results=verbatim, stage=render]{cat("line\n\nnext line\n\n and another")} %1a: \Sexpr[results=text, stage=render]{capture.output(cat(c("line", "next line\n"),sep="\n", collapse="\n"))} 2: \Sexpr[results=verbatim, stage=render]{"line\nnext line\n"} 3: \Sexpr[results=verbatim, stage=render]{list("line\nnext line", 3)} 4: \Sexpr[results=verbatim, stage=render]{list(c("line", "next line"), 3)} Text: 1: \Sexpr[results=text, stage=render]{cat("line\nnext line\n")} 2: \Sexpr[results=text, stage=render]{"line\nnext line\n"} 3: \Sexpr[results=text, stage=render]{list("line\n\nnext line newline and another", 3)} } -- Dr Georgi Boshnakov tel: (+44) (0)161 306 3684 School of Mathematics fax: (+44) (0)161 306 3669 Alan Turing Building 1.125 The University of Manchester email: georgi.boshna...@manchester.ac.uk Oxford Road Manchester M13 9PL UK From: Duncan Murdoch [murdoch.dun...@gmail.com] Sent: 03 November 2011 12:19 To: Renaud Gaujoux Cc: Georgi Boshnakov; r-devel@r-project.org Subject: Re: [Rd] R CMD check and error in an \Sexpr in an Rd file On 11-11-03 7:58 AM, Renaud Gaujoux wrote: Georgi, I tried with paste() instead of cat(), but I then get the following in my PDF manual: [1] "line\nnext line" i.e. what would be printed in the R console, which is not what I want. I would like to get something like this in the Latex code: \begin{verbatim} line next line \end{verbatim} I don't think you want that: it forces display mode. You might want verbatim text displayed inline, like \verb does. Using cat() I get the following in the Latex code: \AsIs{ line next line} which does not render as a new line in the PDF and breaks if empty lines are present in the output text. So the problem is with the \AsIs macro. You can see the definition in the Rd.sty file in R_HOME/share/texmf/tex/latex. Can you suggest an improvement? Duncan Murdoch Besides it will also break on \Sexpr[results=verbatim, stage=render]{list("text", 3)}. But maybe this is not what 'results=verbatim' is supposed to do nor to be used for? Renaud Another test Rd file. % \name{Sexpr} \alias{Sexpr} \title{Error and verbatim in Sexpr} \description{ Testing Sexpr in Rd files %\Sexpr[results=verbatim, stage=render]{stop("error in sexpr")} Verbatim: 1: \Sexpr[results=verbatim, stage=render]{cat("line\nnext line\n")} 2: \Sexpr[results=verbatim, stage=render]{"line\nnext line\n"} 3: \Sexpr[results=verbatim, stage=render]{list("line\nnext line", 3)} Text: 1: \Sexpr[results=text, stage=render]{cat("line\nnext line\n")} 2: \
Re: [Rd] R CMD check and error in an \Sexpr in an Rd file
On 03/11/2011 16:28, Duncan Murdoch wrote: On 03/11/2011 10:21 AM, Renaud Gaujoux wrote: Thank you Georgi. With the fix \long the output is indeed consistent with the documentation. I think my use of cat() worked by luck as its output should not have been rendered. Would a 'results=tex' (html, text) be possible? or 'results=source' that could be combined with \if{format}{text}? This would allow to generate custom Latex, or HTML code, but it might also be is hazardous... Yes, that's possible. See the manual, especially the section "2.12 conditional text". Duncan Murdoch Conditional text is possible, but latex or html code seem to be preprocessed and escaped, or maybe I am not doing the right things. To test: \name{Sexpr} \alias{Sexpr} \title{Error and verbatim in Sexpr} \description{ Testing Sexpr in Rd files \if{html}{\Sexpr[results=text, stage=render]{"text in bold"}} \if{text}{\Sexpr[results=text, stage=render]{"_text in bold_"}} \if{latex}{\Sexpr[results=text, stage=render]{"textbf{text in bold}"}} } %%% __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check and error in an \Sexpr in an Rd file
On 03/11/2011 16:33, Georgi Boshnakov wrote: Dear Renalud,, Would a 'results=tex' (html, text) be possible? or 'results=source' that could be combined with \if{format}{text}? This may well be a clean approach. After my previous email, I looked again at the definition of thr \AsIs macro. Its purpose seems to be to typeset text containing special characters in normal text mode and thus its purpose is different from \verb and ``verbatm' macros/environments in LaTeX. Maybe using an environment such as Verbatim defined in fancyvrb would solve the problem? I think you can control the font, etc... still keeping the "no formatting" of plain verbatim. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R CMD check and error in an \Sexpr in an Rd file
Thank you Duncan for pointing this out. I did have tried using the command \out with no success, but I finally manage to do what I want with: \if{html}{\Sexpr[results=rd, stage=render]{"out{line\nnewline\n\nother line}"}} \if{text}{\Sexpr[results=rd, stage=render]{"out{line\nnewline\n\nother line}"}} \if{latex}{\Sexpr[results=rd, stage=render]{"out{begin{verbatim}line\nnewline\n\nother lineend{verbatim}}"}} The only remaining issue is with format 'text', that does not show single break lines. Double break lines are shown correctly with an empty line. This can be put in a macro: \newcommand{\rdVerb}{\if{html}{\Sexpr[results=rd, stage=render]{paste("\\out{",#1,"}", sep='')}}\if{text}{\Sexpr[results=rd, stage=render]{paste("\\out{",#1,"}", sep='')}}\if{latex}{\Sexpr[results=rd,stage=render]{paste("\\out{begin{verbatim}",#1,"end{verbatim}}", sep='')}} } which can be used as: \rdVerb{"line\nnew line\n\nother paragraph"} Dynamic code works as well: \rdVerb{paste("This is the result of tools:::Rd_expr_PR(1234):", tools:::Rd_expr_PR(1234), sep="")} \rdVerb{paste("This is the result of tools:::Rd_expr_PR(1234):", tools:::Rd_expr_PR(1234), sep="\n")} But backslashes must be escaped twice: \rdVerb{"\begin{section}\ntest\nsd\n\n\end{section}"} Note that on the text version generated by the second \VERBATIM actually correctly shows the new line. Not sure why (?). Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 03/11/2011 18:28, Duncan Murdoch wrote: On 03/11/2011 10:49 AM, Renaud Gaujoux wrote: On 03/11/2011 16:28, Duncan Murdoch wrote: > On 03/11/2011 10:21 AM, Renaud Gaujoux wrote: >> Thank you Georgi. >> With the fix \long the output is indeed consistent with the >> documentation. >> I think my use of cat() worked by luck as its output should not have >> been rendered. >> >> Would a 'results=tex' (html, text) be possible? or 'results=source' that >> could be combined with \if{format}{text}? >> This would allow to generate custom Latex, or HTML code, but it might >> also be is hazardous... > > Yes, that's possible. See the manual, especially the section "2.12 > conditional text". > > Duncan Murdoch Conditional text is possible, but latex or html code seem to be preprocessed and escaped, or maybe I am not doing the right things. Not if you ask it not to do that. See the example in that section of the manual. Duncan Murdoch To test: \name{Sexpr} \alias{Sexpr} \title{Error and verbatim in Sexpr} \description{ Testing Sexpr in Rd files \if{html}{\Sexpr[results=text, stage=render]{"text in bold"}} \if{text}{\Sexpr[results=text, stage=render]{"_text in bold_"}} \if{latex}{\Sexpr[results=text, stage=render]{"textbf{text in bold}"}} } %%% __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Identify \Sexpr call?
More or less in the same vein as Henrik's post, is it possible to detect that a function is being called in an \Sexpr when generating an Rd file? Thank you -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R package BibTex entries: looking for a more general solution
Hi, I actually adapted and integrated this feature into Achim's -- nice -- function (posted on r-help). Romain included it a couple of weeks ago into the bibtex package as function write.bib, and submitted the update to CRAN, but some NOTEs in the check delayed its availability on CRAN. You can still install and try out the new version with: install.packages("bibtex", repos="http://R-Forge.R-project.org";) Keys for multiple citations are generated as "%i", which might not be ideal, but works ok though. It might be better not number the first (main) citation. Romain, I think I will submit a patch for this. Hope this helps. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R package BibTex entries: looking for a more general solution
Indeed I broke the function when adding support for bibentry objects... By the way, let's give credits back to Ceasars: I am not the author of the bibtex package, Romain Francois is. I just contributed the write.bib function, mainly inspired by Achim's function. Romain, I will send a fix for this now. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 19/12/2011 15:56, Michael Friendly wrote: On 12/19/2011 2:02 AM, Renaud Gaujoux wrote: Hi, I actually adapted and integrated this feature into Achim's -- nice -- function (posted on r-help). Romain included it a couple of weeks ago into the bibtex package as function write.bib, and submitted the update to CRAN, but some NOTEs in the check delayed its availability on CRAN. You can still install and try out the new version with: install.packages("bibtex", repos="http://R-Forge.R-project.org";) Keys for multiple citations are generated as "%i", which might not be ideal, but works ok though. It might be better not number the first (main) citation. Romain, I think I will submit a patch for this. Hope this helps. Thanks, Renaud I now have a working function, Rpackages.bib() that is roughly equivalent to your write.bib() and other related material at http://euclid.psych.yorku.ca/SCS/Private/Rbibs/ Also, see the document http://euclid.psych.yorku.ca/SCS/Private/Rbibs/Rpkg-test.pdf which reports some problems & perl fixes for the generated bibentries. These might be incorporated into the functions to make the resulting bibtex files directly usable. Your bibtex package seems the most natural place for this. Also, write.bib() doesn't seem to work unless you pass a list of package names. > write.bib() Error in is(entry, "bibentry") : argument "entry" is missing, with no default > write.bib(NULL) Error in write.bib(NULL) : Invalid argument `entry`: expected a bibentry object or a character vector of package names. > best, -Michael __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Default subset and concatenation operators for namedList
Hi, in R version 2.14.1 (2011-12-22), is it wanted that the class namedList does not overloads the '[' and 'c' operators: showMethods('c', class='namedList') showMethods('[', class='namedList') This means that if one creates a class that inherits from namedList, one has to define these operators so that they do not drop the S4 class (code below). I agree that one would probably have to define custom operators to correctly handle other possible extra slots when subsetting and concatenatiing. But it seems that namedList could at least deal with the slot `names` and not convert the object to a standard list, which is troublesome. Is there a reason why these operators are not pre-defined in namedList? Thank you. Renaud ## setClass('A', contains='namedList') a <- new('A', list(a=1,b=2,c=3)) str(a) # subset converts to standard list str(a[1:2]) str(a[2:3]) # concatenation converts to standard list str(c(a, list(d=4, e=5))) -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] url, readLines, source behind a proxy
Hi, when I run R CMD check with flag --as-cran, the process hangs at stage: * checking CRAN incoming feasibility ... I am pretty sure it is a proxy issue. I looked at the check code in the tools package and it seems that the issue is in the local function `.repository_db()` (defined in `tools:::.check_package_CRAN_incoming()`), which eventually calls `url()` with argument open="rb", that hangs probably because it does not use the proxy settings. I had a similar issue with `source()`, which apparently uses internal network functions (not as download.file), but is supposed to work behind a proxy (correct?). Does anybody else have this problem? I was wondering if there is a way around, as I would like to be able to use --as-cran for my checks. Thank you. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] url, readLines, source behind a proxy
Hi Henrik, I am sure it would time out indeed. I am fine with time out due to poor connection, but get a bit frustrated if my connection is fine and timeout occurs because proxy settings are not read. All the more if I have to run R CMD check multiple times and wait for the timeout. But the issue might also be coming from my proxy, which somehow does not like the way url() reads remote content. Could anybody behind a proxy check if the issue can be reproduced? My proxy is in fact provided by cntml, which acts as a local proxy that takes care of tricky authentication protocols with the actual university proxy, not natively supported by my system (Ubuntu). Anybody in this case? Thanks. Renaud On Tue, 17 Apr 2012, Henrik Bengtsson wrote: > On Tue, Apr 17, 2012 at 1:01 AM, Renaud Gaujoux > wrote: > > Hi, > > > > when I run R CMD check with flag --as-cran, the process hangs at stage: > > > > * checking CRAN incoming feasibility ... > > Doesn't it time-out eventually? I'm not behind a proxy but when I've > been running 'R CMD check' whenon very poor 3G connection, it had > eventually timed out. > > /Henrik > > > > > I am pretty sure it is a proxy issue. > > I looked at the check code in the tools package and it seems that the issue > > is in the local function `.repository_db()` (defined in > > `tools:::.check_package_CRAN_incoming()`), which eventually calls `url()` > > with argument open="rb", that hangs probably because it does not use the > > proxy settings. > > I had a similar issue with `source()`, which apparently uses internal > > network functions (not as download.file), but is supposed to work behind a > > proxy (correct?). > > Does anybody else have this problem? > > > > I was wondering if there is a way around, as I would like to be able to use > > --as-cran for my checks. > > Thank you. > > > > Renaud > > > > -- > > Renaud Gaujoux > > Computational Biology - University of Cape Town > > South Africa > > > > __ > > 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] url, readLines, source behind a proxy
On 23/04/2012 17:39, Prof Brian Ripley wrote: On 18/04/2012 16:04, Joshua Ulrich wrote: Hi Renaud, On Wed, Apr 18, 2012 at 12:22 AM, Renaud Gaujoux wrote: Hi Henrik, Could anybody behind a proxy check if the issue can be reproduced? My proxy is in fact provided by cntml, which acts as a local proxy that takes care of tricky authentication protocols with the actual university proxy, not natively supported by my system (Ubuntu). Anybody in this case? I can replicate this on a WinXP system, where I normally have to use the --internet2 flag to get internet access through a proxy. ?download.file has a section on "Setting Proxies", which describes how to use environment variables to set proxy information. Setting http_proxy='http://my.proxy.com/' was enough for me to get R CMD check to run successfully with the --as-cran flag. I guess that the simplest way on Windows is to ensure that --internet2 is set. In R-patched there is a new environment variable R_WIN_INTERNET2 which lets you do that (set it in ~/.R/check.Renviron). [Setting proxies is so 20th century -- even moderately competent sysadmins worked out how to use transparent caching proxies ca 1995. Which is why the R developers give it a low priority.] I completely understand the low priority -- fast-illimited-internet based -- point of view. I wish I could live without such a fussy proxy, but I have not much choice. I like to understand why things work and do not work though. Is there any special feature my proxy should have to allow readLines/source to correctly read remote data? What makes its access different from wget? Thank you for your insights on this. Thanks. Renaud Best, -- Joshua Ulrich | FOSS Trading: www.fosstrading.com R/Finance 2012: Applied Finance with R www.RinFinance.com On Tue, 17 Apr 2012, Henrik Bengtsson wrote: On Tue, Apr 17, 2012 at 1:01 AM, Renaud Gaujoux wrote: Hi, when I run R CMD check with flag --as-cran, the process hangs at stage: * checking CRAN incoming feasibility ... Doesn't it time-out eventually? I'm not behind a proxy but when I've been running 'R CMD check' whenon very poor 3G connection, it had eventually timed out. /Henrik I am pretty sure it is a proxy issue. I looked at the check code in the tools package and it seems that the issue is in the local function `.repository_db()` (defined in `tools:::.check_package_CRAN_incoming()`), which eventually calls `url()` with argument open="rb", that hangs probably because it does not use the proxy settings. I had a similar issue with `source()`, which apparently uses internal network functions (not as download.file), but is supposed to work behind a proxy (correct?). Does anybody else have this problem? I was wondering if there is a way around, as I would like to be able to use --as-cran for my checks. Thank you. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ 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 __ 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] url, readLines, source behind a proxy
Thanks Henrik for the work around. It worked perfectly and save me lots of check time. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 24/04/2012 17:57, Henrik Bengtsson wrote: Looking at the source code (src/library/tools/R/check.R and src/library/tools/R/QC.R), I found that... WORKAROUND: You can trick 'R CMD check' to quickly skip the "check_package_CRAN_incoming" test by providing it with invalid URLs to repositories by setting system environment '_R_CHECK_XREFS_REPOSITORIES_' to a non-empty URL. For example: % export _R_CHECK_XREFS_REPOSITORIES_="invalidURL" % R CMD check --as-cran ... gives: * checking CRAN incoming feasibility ...NB: need Internet access to use CRAN incoming checks OK /Henrik On Tue, Apr 24, 2012 at 5:46 AM, Renaud Gaujoux wrote: On 23/04/2012 17:39, Prof Brian Ripley wrote: On 18/04/2012 16:04, Joshua Ulrich wrote: Hi Renaud, On Wed, Apr 18, 2012 at 12:22 AM, Renaud Gaujoux wrote: Hi Henrik, Could anybody behind a proxy check if the issue can be reproduced? My proxy is in fact provided by cntml, which acts as a local proxy that takes care of tricky authentication protocols with the actual university proxy, not natively supported by my system (Ubuntu). Anybody in this case? I can replicate this on a WinXP system, where I normally have to use the --internet2 flag to get internet access through a proxy. ?download.file has a section on "Setting Proxies", which describes how to use environment variables to set proxy information. Setting http_proxy='http://my.proxy.com/' was enough for me to get R CMD check to run successfully with the --as-cran flag. I guess that the simplest way on Windows is to ensure that --internet2 is set. In R-patched there is a new environment variable R_WIN_INTERNET2 which lets you do that (set it in ~/.R/check.Renviron). [Setting proxies is so 20th century -- even moderately competent sysadmins worked out how to use transparent caching proxies ca 1995. Which is why the R developers give it a low priority.] I completely understand the low priority -- fast-illimited-internet based -- point of view. I wish I could live without such a fussy proxy, but I have not much choice. I like to understand why things work and do not work though. Is there any special feature my proxy should have to allow readLines/source to correctly read remote data? What makes its access different from wget? Thank you for your insights on this. Thanks. Renaud Best, -- Joshua Ulrich | FOSS Trading: www.fosstrading.com R/Finance 2012: Applied Finance with R www.RinFinance.com On Tue, 17 Apr 2012, Henrik Bengtsson wrote: On Tue, Apr 17, 2012 at 1:01 AM, Renaud Gaujoux wrote: Hi, when I run R CMD check with flag --as-cran, the process hangs at stage: * checking CRAN incoming feasibility ... Doesn't it time-out eventually? I'm not behind a proxy but when I've been running 'R CMD check' whenon very poor 3G connection, it had eventually timed out. /Henrik I am pretty sure it is a proxy issue. I looked at the check code in the tools package and it seems that the issue is in the local function `.repository_db()` (defined in `tools:::.check_package_CRAN_incoming()`), which eventually calls `url()` with argument open="rb", that hangs probably because it does not use the proxy settings. I had a similar issue with `source()`, which apparently uses internal network functions (not as download.file), but is supposed to work behind a proxy (correct?). Does anybody else have this problem? I was wondering if there is a way around, as I would like to be able to use --as-cran for my checks. Thank you. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ 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 __ 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 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Multiple sub-architecture: problem installing RCurl
Hi, for checking purposes, I setup a multiple sub-architecture R installation following this post from Simon Urbanek: https://stat.ethz.ch/pipermail/r-devel/2011-August/061755.html It all went fine. The only change I made to Simon's procedure was to install with: make prefix=~/bin/R/2.15 install instead of sudo make install rhome=/usr/local/R/2.15. I am now trying to install RCurl in the 32 bits architechture but get the following error, which I believe comes from the fact the wrong libraries (64 bits) are used instead of the 32 bit ones. I am on Ubuntu 11.04 (Natty) and thought I needed to install the 32 bits libxml2, but could not find a way to do so. Anybody faced a similar problem? I believe I will get into the same kind of issue with other packages that require system packages. Thank you! . libcurl version: libcurl 7.21.3 configure: creating ./config.status config.status: creating src/Makevars ** libs *** arch - i386 gcc -std=gnu99 -m32 -I/home/renaud/bin/R/2.15/lib64/R/include -I/home/renaud/bin/R/2.15/lib64/R/include/i386 -DNDEBUG -DHAVE_LIBIDN_FIELD=1 -DHAVE_CURLOPT_URL=1 -DHAVE_CURLINFO_EFFECTIVE_URL=1 -DHAVE_CURLINFO_RESPONSE_CODE=1 -DHAVE_CURLINFO_TOTAL_TIME=1 -DHAVE_CURLINFO_NAMELOOKUP_TIME=1 -DHAVE_CURLINFO_CONNECT_TIME=1 -DHAVE_CURLINFO_PRETRANSFER_TIME=1 -DHAVE_CURLINFO_SIZE_UPLOAD=1 -DHAVE_CURLINFO_SIZE_DOWNLOAD=1 -DHAVE_CURLINFO_SPEED_DOWNLOAD=1 -DHAVE_CURLINFO_SPEED_UPLOAD=1 -DHAVE_CURLINFO_HEADER_SIZE=1 -DHAVE_CURLINFO_REQUEST_SIZE=1 -DHAVE_CURLINFO_SSL_VERIFYRESULT=1 -DHAVE_CURLINFO_FILETIME=1 -DHAVE_CURLINFO_CONTENT_LENGTH_DOWNLOAD=1 -DHAVE_CURLINFO_CONTENT_LENGTH_UPLOAD=1 -DHAVE_CURLINFO_STARTTRANSFER_TIME=1 -DHAVE_CURLINFO_CONTENT_TYPE=1 -DHAVE_CURLINFO_REDIRECT_TIME=1 -DHAVE_CURLINFO_REDIRECT_COUNT=1 -DHAVE_CURLINFO_PRIVATE=1 -DHAVE_CURLINFO_HTTP_CONNECTCODE=1 -DHAVE_CURLINFO_HTTPAUTH_AVAIL=1 -DHAVE_CURLINFO_PROXYAUTH_AVAIL=1 -DHAVE_CURLINFO_OS_ERRNO=1 -DHAVE_CURLINFO_NUM_CONNECTS=1 -DHAVE_CURLINFO_SSL_ENGINES=1 -DHAVE_CURLINFO_COOKIELIST=1 -DHAVE_CURLINFO_LASTSOCKET=1 -DHAVE_CURLINFO_FTP_ENTRY_PATH=1 -DHAVE_CURLINFO_REDIRECT_URL=1 -DHAVE_CURLINFO_PRIMARY_IP=1 -DHAVE_CURLINFO_APPCONNECT_TIME=1 -DHAVE_CURLINFO_CERTINFO=1 -DHAVE_CURLINFO_CONDITION_UNMET=1 -DHAVE_CURLOPT_KEYPASSWD=1 -DHAVE_CURLOPT_DIRLISTONLY=1 -DHAVE_CURLOPT_APPEND=1 -DHAVE_CURLOPT_KRBLEVEL=1 -DHAVE_CURLOPT_USE_SSL=1 -DHAVE_CURLOPT_TIMEOUT_MS=1 -DHAVE_CURLOPT_CONNECTTIMEOUT_MS=1 -DHAVE_CURLOPT_HTTP_TRANSFER_DECODING=1 -DHAVE_CURLOPT_HTTP_CONTENT_DECODING=1 -DHAVE_CURLOPT_NEW_FILE_PERMS=1 -DHAVE_CURLOPT_NEW_DIRECTORY_PERMS=1 -DHAVE_CURLOPT_POSTREDIR=1 -DHAVE_CURLOPT_OPENSOCKETFUNCTION=1 -DHAVE_CURLOPT_OPENSOCKETDATA=1 -DHAVE_CURLOPT_COPYPOSTFIELDS=1 -DHAVE_CURLOPT_PROXY_TRANSFER_MODE=1 -DHAVE_CURLOPT_SEEKFUNCTION=1 -DHAVE_CURLOPT_SEEKDATA=1 -DHAVE_CURLOPT_CRLFILE=1 -DHAVE_CURLOPT_ISSUERCERT=1 -DHAVE_CURLOPT_ADDRESS_SCOPE=1 -DHAVE_CURLOPT_CERTINFO=1 -DHAVE_CURLOPT_USERNAME=1 -DHAVE_CURLOPT_PASSWORD=1 -DHAVE_CURLOPT_PROXYUSERNAME=1 -DHAVE_CURLOPT_PROXYPASSWORD=1 -DHAVE_CURLOPT_SSH_HOST_PUBLIC_KEY_MD5=1 -DHAVE_CURLOPT_NOPROXY=1 -DHAVE_CURLOPT_TFTP_BLKSIZE=1 -DHAVE_CURLOPT_SOCKS5_GSSAPI_SERVICE=1 -DHAVE_CURLOPT_SOCKS5_GSSAPI_NEC=1 -DHAVE_CURLOPT_PROTOCOLS=1 -DHAVE_CURLOPT_REDIR_PROTOCOLS=1 -DHAVE_CURLOPT_SSH_AUTH_TYPES=1 -DHAVE_CURLOPT_SSH_PUBLIC_KEYFILE=1 -DHAVE_CURLOPT_SSH_PRIVATE_KEYFILE=1 -DHAVE_CURLOPT_FTP_SSL_CCC=1 -DHAVE_CURLOPT_COOKIELIST=1 -DHAVE_CURLOPT_IGNORE_CONTENT_LENGTH=1 -DHAVE_CURLOPT_FTP_SKIP_PASV_IP=1 -DHAVE_CURLOPT_FTP_FILEMETHOD=1 -DHAVE_CURLOPT_LOCALPORT=1 -DHAVE_CURLOPT_LOCALPORTRANGE=1 -DHAVE_CURLOPT_CONNECT_ONLY=1 -DHAVE_CURLOPT_CONV_FROM_NETWORK_FUNCTION=1 -DHAVE_CURLOPT_CONV_TO_NETWORK_FUNCTION=1 -DHAVE_CURLOPT_CONV_FROM_UTF8_FUNCTION=1 -DHAVE_CURLOPT_MAX_SEND_SPEED_LARGE=1 -DHAVE_CURLOPT_MAX_RECV_SPEED_LARGE=1 -DHAVE_CURLOPT_FTP_ALTERNATIVE_TO_USER=1 -DHAVE_CURLOPT_SOCKOPTFUNCTION=1 -DHAVE_CURLOPT_SOCKOPTDATA=1 -DHAVE_CURLOPT_SSL_SESSIONID_CACHE=1 -I/usr/include/libxml2 -I/usr/local/include-fpic -g -O2 -c base64.c -o base64.o In file included from /usr/include/curl/curl.h:35:0, from Rcurl.h:4, from base64.c:1: /usr/include/curl/curlrules.h:142:3: error: size of array '__curl_rule_01__' is negative /usr/include/curl/curlrules.h:152:3: error: size of array '__curl_rule_02__' is negative make: *** [base64.o] Error 1 ERROR: compilation failed for package 'RCurl' * removing '/home/renaud/bin/R/2.15/lib64/R/library/RCurl' * restoring previous '/home/renaud/bin/R/2.15/lib64/R/library/RCurl' -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Multiple sub-architecture: linking issue
Hi again, following my previous post on RCurl, I cannot install Rcpp either: g++ -m32 -I/home/renaud/bin/R/2.15/lib64/R/include -I/home/renaud/bin/R/2.15/lib64/R/include/i386 -DNDEBUG -I../inst/include/ -I/usr/local/include-fpic -g -O2 -c r_cast.cpp -o r_cast.o g++ -m32 -shared -L/usr/local/lib64 -o Rcpp.so Date.o DateVector.o Datetime.o DatetimeVector.o Dimension.o DottedPair.o Environment.o Evaluator.o Formula.o Function.o Language.o Module.o Pairlist.o Promise.o RObject.o RcppCommon.o Rcpp_init.o Reference.o Rostream.o Rstreambuf.o S4.o Symbol.o WeakReference.o barrier.o cache.o coerce.o complex.o debugging.o exceptions.o posixt.o r_cast.o /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.so when searching for -lstdc++ /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.a when searching for -lstdc++ /usr/bin/ld: cannot find -lstdc++ collect2: ld returned 1 exit status There is definitely some conflict or missing libraries going on... Any help is appreciated. Thank you. PS: Dirk do you want me to post this on the Rcpp list for record? -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Multiple sub-architecture: linking issue
Thank you for your reply Simon. I have the gcc-multilib and ia32-libs packages installed (I think their installation is part of the procedure you described in your previous post). Could not find the package ia32-dev you mention. It seems to be flagged as obsolete in Natty repositories: $ sudo apt-get install ia32-libs-dev lib32readline6-dev lib32ncurses5-dev lib32icu-dev gcc-multilib gfortran-multilib [sudo] password for renaud: Reading package lists... Done Building dependency tree Reading state information... Done Package ia32-libs-dev is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source However the following packages replace it: lib32bz2-dev ia32-libs lib32z1-dev I succeeded in compiling both architecture of R without a problem though. Would that have been possible if some of the files provided by this package were missing? I can try look around for this exact package. -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa On 08/06/2012 16:22, Simon Urbanek wrote: Make sure you have installed multilib gcc and the ia32 dev packages - it seems you don't have them. I'm a Sent from my iPhone On Jun 8, 2012, at 6:27 AM, Renaud Gaujoux wrote: Hi again, following my previous post on RCurl, I cannot install Rcpp either: g++ -m32 -I/home/renaud/bin/R/2.15/lib64/R/include -I/home/renaud/bin/R/2.15/lib64/R/include/i386 -DNDEBUG -I../inst/include/ -I/usr/local/include-fpic -g -O2 -c r_cast.cpp -o r_cast.o g++ -m32 -shared -L/usr/local/lib64 -o Rcpp.so Date.o DateVector.o Datetime.o DatetimeVector.o Dimension.o DottedPair.o Environment.o Evaluator.o Formula.o Function.o Language.o Module.o Pairlist.o Promise.o RObject.o RcppCommon.o Rcpp_init.o Reference.o Rostream.o Rstreambuf.o S4.o Symbol.o WeakReference.o barrier.o cache.o coerce.o complex.o debugging.o exceptions.o posixt.o r_cast.o /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.so when searching for -lstdc++ /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/libstdc++.a when searching for -lstdc++ /usr/bin/ld: cannot find -lstdc++ collect2: ld returned 1 exit status There is definitely some conflict or missing libraries going on... Any help is appreciated. Thank you. PS: Dirk do you want me to post this on the Rcpp list for record? -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ 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] Multiple sub-architecture: linking issue
On 11/06/2012 03:43, Simon Urbanek wrote: > On Jun 10, 2012, at 9:24 PM, Dirk Eddelbuettel wrote: > >> On 8 June 2012 at 12:27, Renaud Gaujoux wrote: >> | PS: Dirk do you want me to post this on the Rcpp list for record? >> >> Yes, that generally is where Rcpp questions / comments / hints should go. >> >> As for multi-arch builds, I am not sure we even thought about supporting >> this so if >> it breaks your use of Rcpp and related packages, you get to keep the pieces. >> That said, I'd be interested in supporting it eventually but I guess I want >> to first understand better how/if it is supported (on Linux) by R itself. >> > R itself of course supports it and essentially all packages (including Rcpp > ;)) have to because we require it on Windows and OS X since all binaries > there are multi-lib. From what I understood fro R-Writing extensions, multi-arch support would generally be about following the following recommendation: "If you want to run R code inMakevars, e.g. to find configuration information, please do ensure that you use the correct copy of|R|or|Rscript|: there might not be one in the path at all, or it might be the wrong version or architecture. The correct way to do this is/via/ "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript"filename "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e 'R expression' where|$(R_ARCH_BIN)|is only needed currently on Windows." So unless different external libraries are required for the different types build (32 or 64 bits), there should be nothing special to do to ensure support of multi-arch. In particular, on Linux, "$(R_HOME)/bin/Rscript" -e 'R expression'" should work in both single and multi-arch setup, correct? > As far as R is concerned it works equally well on Linux - the problem there > is more on the side of distributions, because it is more unusual to have > multi-lib Linux (originally it was used on Linux only to get 3rd party > [mostly proprietary] 32-bit binaries working on 64-bit systems and that is > now less of an issue). As I said in the original post it works reasonably > well on Debian (not for all libraries since only a subset is available, but > all the basic ones) -- there were shakeups in Ubuntu which were messing with > the multilib support, so I don't know the current status but I can check at > work tomorrow (probably not for something as ancient as natty, though). I think you are right Simon: the issue likely comes from my Linux distrib, which I effectively should upgrade. This gives me one more reason to do it asap. If you have some -- even untested -- clues on how to get things working on Natty I am happy to test them though, as upgrades always have hidden issues and time black holes... Thank you. Bests, Renaud > > Cheers, > Simon > > >> -- >> Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com >> >> __ >> 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] Multiple sub-architecture: linking issue
Dirk, who thinks this should have been on r-sig-debian all along Moved to r-sig-debian as suggested: https://stat.ethz.ch/pipermail/r-sig-debian/2012-June/001885.html __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] "Incompatible methods" for overloaded operator
Hi, I may be mistaken here but a possible interpretation of: "If a method is found for just one argument or the same method is found for both, it is used." could be that "the same method" here does not mean identical in term of object/content (as identical tests), but means that the two arguments resolve to the same method definition, i.e. a single common method exists for both arguments. This would happen is if a single method is defined for a common parent class. Try: `+.C` <- function(x1, x2){ message("Running custom + function") } x <- structure(1, class=c('A', 'C')) y <- structure(1, class=c('B', 'C')) x + y Another work around would be to define only one method for class 'a' and do the dispatch to `plus.b` in there (might even be able to call it `+.b` if not exported). Might be a good suggestion to add a test in UseMethod to check is the methods are in fact identical. But there might be undesired side effects: two identical methods in different environment that behave differently depending on the state of the environment? By the way any way of seeing any code of primitive function or are these pure C functions, which need to be searched for in R source code? Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] [Suggestion] Installation of CRAN packages that depend on Bioconductor packages
Hi, as far as I know, calling a plain: install.packages('packageA') with packageA having a dependency to packageB from Bioconductor will not complete without having a Bioc mirror setup in options('repos') or specifying it in argument 'repos'. CRAN/R-forge checks resolve such dependencies automatically. Would it be possible (and not problematic) to also resolve such standard dependencies at install time (in fact build time) and automatically append a Bioc mirror to repos within install.package (if none is already defined)? The dependency would be hence completely transparent, which would simplify the installation of such packages, as the user would not need to know that a repository other than CRAN is required. Resolution could make use of the function chooseBioCMirror to ask the user to select her preferred mirror, as it is done for the CRAN mirror. Thank you. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Extracting srcref for S4 methods
Hi, on R version 2.15.1 (2012-06-22) (Platform: i686-pc-linux-gnu (32-bit)) sourced functions have srcref attached as an attribute. Are such data also available for S4 generics and methods? How? (See sample code below) Thank you. Bests, Renaud f <- textConnection( " f <- function(){} setGeneric('myfun', function(x, ...) standardGeneric('myfun')) setMethod('myfun', 'numeric', function(x, ...){ 'myfun,numeric' }) ") source(f, keep.source=TRUE) # there are srcref data for functions str(f) # no srcref data str(myfun) str(selectMethod(myfun, 'numeric')) -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Extracting srcref for S4 methods
Responding to my own question here. It appears I had overlooked the results from my sample script, as they in fact do contain srcref data, but simply do not show them up in str(): f <- textConnection( " f <- function(){} setGeneric('myfun', function(x, ...) standardGeneric('myfun')) setMethod('myfun', 'numeric', function(x, ...){ 'myfun,numeric' }) ") source(f, keep.source=TRUE) # there are srcref data for functions str(f) # no srcref data str(attr(myfun, 'srcref')) str(attr(selectMethod(myfun, 'numeric'), 'srcref')) So no worries. Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Call function only when running via R CMD check?
Hi Henrik (and list), I am interested in a similar feature, and would be happy to see the suggestions you got off-line :) Have you come up with a robust solution, which would work in a variety of situations (in examples, tests, \Sexpr calls, etc..)? Thank you. Bests, Renaud -- Renaud Gaujoux Computational Biology - University of Cape Town South Africa __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] removing union class
Hi, I get the following error when trying to remove a union class: > setClassUnion('a', c('matrix', 'numeric')) > removeClass('a') > sessionInfo() R version 2.15.3 (2013-03-01) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base Is this normal? Am I doing something wrong? Hadley, this is problematic for devtools, because load_all tries to cleanup S4 classes when an error occurs when loading a development package and crashes with no hint on the original error. Thank you. Bests, Renaud [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] removing union class
Late report is better than never isn't it? :) > > Well,... you forgot to show the error (and the traceback) : > Apologies, I usually include them (and sessionInfo ...). > > > Note that this problem is somewhat dependent on the use of the > > infamous "matrix" class {not properly defined as a class in S3, > > as it may or may not have dimnames, and then tried to be made S4 > > compatible "as well as possible" in the methods package, see > Ok. What I want to do is to define a class in my namespace that gather some matrix-like classes so that I can define a set of common functions for them. Initially I want matrix and ExpressionSet objects, and possibly add array objects later. Union classes seem to be exactly the way to go, but maybe there is an alternative? > > > Of course, I could not have thought of a realistic situation > > where this was a problem, but then you exemplify one : > > >> Hadley, this is problematic for devtools, because load_all tries to > cleanup > >> S4 classes when an error occurs when loading a development package > and > >> crashes with no hint on the original error. > > I guess a quick fix for devtools, would be to wrap the cleanup procedure into a try or tryCatch (Hadley?). Thanks, Renaud [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] source, sys.source and error line numbers
Hi, is there a way to retrieve the line number of where en error occurred when sourcing a file in a tryCatch statement? Is it stored somewhere accessible? It is not found in the error object. Consider the following code/output and note the difference in the traceback between source (has line number) and sys.source (has no line number). Thank you, Renaud # code codefile <- tempfile() write("# some comment # some good lines a <- 1 # a bad line stop('an error') # another good line b <- 2 ", file=codefile) # with source() the line number is displayed source(codefile) traceback() tryCatch(source(codefile), error= function(e){ str(e) }) # with sys.source() the line number is _not_ displayed e <- new.env() sys.source(codefile, e) traceback() sessionInfo() # # output # > codefile <- tempfile() > write("# some comment + # some good lines + a <- 1 + # a bad line + stop('an error') + # another good line + b <- 2 + ", file=codefile) > # with source() the line number is displayed > source(codefile) Error in eval(expr, envir, enclos) : an error > traceback() 5: stop("an error") at file46641af8754#5 4: eval(expr, envir, enclos) 3: eval(ei, envir) 2: withVisible(eval(ei, envir)) 1: source(codefile) > tryCatch(source(codefile), error= function(e){ str(e) }) List of 2 $ message: chr "an error" $ call : language eval(expr, envir, enclos) - attr(*, "class")= chr [1:3] "simpleError" "error" "condition" > > # with sys.source() the line number is _not_ displayed > e <- new.env() > sys.source(codefile, e) Error in eval(expr, envir, enclos) : an error > traceback() 4: stop("an error") 3: eval(expr, envir, enclos) 2: eval(i, envir) 1: sys.source(codefile, e) > > sessionInfo() R version 2.15.3 (2013-03-01) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] removing union class
All good then. Thanks. Renaud 2013/3/19 Martin Maechler > >>>>> "RG" == Renaud Gaujoux > >>>>> on Sun, 17 Mar 2013 10:38:44 +0200 writes: > > RG> Late report is better than never isn't it? :) > >> > Well,... you forgot to show the error (and the > >> traceback) : > >> > > RG> Apologies, I usually include them (and sessionInfo ...). > > > >> > >> > Note that this problem is somewhat dependent on the use > >> of the > infamous "matrix" class {not properly defined as > >> a class in S3, > as it may or may not have dimnames, and > >> then tried to be made S4 > compatible "as well as > >> possible" in the methods package, see > >> > > RG> Ok. What I want to do is to define a class in my > RG> namespace that gather some matrix-like classes so that I > RG> can define a set of common functions for them. > RG> Initially I want matrix and ExpressionSet objects, and > RG> possibly add array objects later. Union classes seem to > RG> be exactly the way to go, but maybe there is an > RG> alternative? > > There's really *no* problem with class unions. > They work fine and nicely... we also use them in the Matrix > package (part of the R distro). > > The problem you've reported is only a propblem of removeClass(). > > Martin > > > > >> > >> > Of course, I could not have thought of a realistic > >> situation > where this was a problem, but then you > >> exemplify one : > >> > >> >> Hadley, this is problematic for devtools, because > >> load_all tries to cleanup >> S4 classes when an error > >> occurs when loading a development package and >> crashes > >> with no hint on the original error. > >> > >> > RG> I guess a quick fix for devtools, would be to wrap the > RG> cleanup procedure into a try or tryCatch (Hadley?). > > > RG> Thanks, Renaud > > [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] source, sys.source and error line numbers
Sounds good for me. Thanks. 2013/3/27 Duncan Murdoch > On 13-03-26 6:45 PM, Hadley Wickham wrote: > >> It turns out the reason for this is pretty simple: >> >> sys.source does: >> for (i in exprs) eval(i, envir) >> >> where source basically does >> n <- length(exprs) >> for (i in seq_len(n)) eval(expr[i], envir) >> >> so the problem is presumably related to the way that for strips >> attributes. >> > > That's part of it, but there are also different defaults for keep.source. > It needs to be TRUE or the error location won't be known. > > I'll fix the difference you noticed after 3.0.0 is released; I think it is > not serious enough to slip in at this point. > > Duncan Murdoch > > > >> Hadley >> >> On Tue, Mar 19, 2013 at 4:03 AM, Renaud Gaujoux >> wrote: >> >>> Hi, >>> >>> is there a way to retrieve the line number of where en error occurred >>> when >>> sourcing a file in a tryCatch statement? Is it stored somewhere >>> accessible? >>> It is not found in the error object. >>> >>> Consider the following code/output and note the difference in the >>> traceback >>> between source (has line number) and sys.source (has no line number). >>> >>> Thank you, >>> Renaud >>> >>> >>> >>> # code >>> >>> codefile <- tempfile() >>> write("# some comment >>> # some good lines >>> a <- 1 >>> # a bad line >>> stop('an error') >>> # another good line >>> b <- 2 >>> ", file=codefile) >>> >>> # with source() the line number is displayed >>> source(codefile) >>> traceback() >>> tryCatch(source(codefile), error= function(e){ str(e) }) >>> >>> # with sys.source() the line number is _not_ displayed >>> e <- new.env() >>> sys.source(codefile, e) >>> traceback() >>> >>> sessionInfo() >>> >>> # >>> # output >>> # >>> >>> codefile <- tempfile() >>>> write("# some comment >>>> >>> + # some good lines >>> + a <- 1 >>> + # a bad line >>> + stop('an error') >>> + # another good line >>> + b <- 2 >>> + ", file=codefile) >>> >>>> # with source() the line number is displayed >>>> source(codefile) >>>> >>> Error in eval(expr, envir, enclos) : an error >>> >>>> traceback() >>>> >>> 5: stop("an error") at file46641af8754#5 >>> 4: eval(expr, envir, enclos) >>> 3: eval(ei, envir) >>> 2: withVisible(eval(ei, envir)) >>> 1: source(codefile) >>> >>>> tryCatch(source(codefile), error= function(e){ str(e) }) >>>> >>> List of 2 >>> $ message: chr "an error" >>> $ call : language eval(expr, envir, enclos) >>> - attr(*, "class")= chr [1:3] "simpleError" "error" "condition" >>> >>>> >>>> # with sys.source() the line number is _not_ displayed >>>> e <- new.env() >>>> sys.source(codefile, e) >>>> >>> Error in eval(expr, envir, enclos) : an error >>> >>>> traceback() >>>> >>> 4: stop("an error") >>> 3: eval(expr, envir, enclos) >>> 2: eval(i, envir) >>> 1: sys.source(codefile, e) >>> >>>> >>>> sessionInfo() >>>> >>> R version 2.15.3 (2013-03-01) >>> Platform: i686-pc-linux-gnu (32-bit) >>> >>> locale: >>> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C >>> [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 >>> [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 >>> [7] LC_PAPER=C LC_NAME=C >>> [9] LC_ADDRESS=C LC_TELEPHONE=C >>> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C >>> >>> attached base packages: >>> [1] stats graphics grDevices utils datasets methods base >>> >>> [[alternative HTML version deleted]] >>> >>> __** >>> R-devel@r-project.org mailing list >>> https://stat.ethz.ch/mailman/**listinfo/r-devel<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
[Rd] loadNamespace tries to load an optional dependency from a required dependency
Hi, I get an error from loadNamespace in the following situation (on R-2.15.3, R-devel 2013-03-26 r62409, and fresh R-3.0.0): - package A has an optional (suggests) dependency to package C, which is tested at load time in .onLoad, via require(). - package B depends on package A, which is loaded when B is lazy-loaded at install time. - package B is installed with package C installed If one now removes package C and try loading package B via library(B), then one gets an error such as: Error in loadNamespace(name) : there is no package called C Error: package/namespace load failed for B I guess this is because the list of namespaces to load for B is taken from the frozen list defined after lazyload at install time. Is this an intentional requirement or shouldn't the list of dependency namespaces to load be taken from the NAMESPACE and/or DESCRIPTION file, which define the true dependencies? Package B should not have to be aware of how/when the optional dependencies of package A are loaded. I believe these are legally conditionally loaded in .onLoad or should they be loaded in .onAttach? One could imagine a situation where a package actually does require the extra functionality provided by package C, at lazy-load time, which means it must be loaded via .onLoad (right?). In this case, clearly, one would have package C as Depends, which then would not give rise to the issue I have here. Thank you. Bests, Renaud [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel