Re: [Rd] Question about writing portable packages
Kevin Ushey: (12:10AM on Fri, Jun 07) I think the key word here is _other_ packages. It's entirely okay to call your package's own compiled code through the .Call interface (and the code you write may link to other packages; the obvious example being Rcpp code you write); however, it is not portable to use .Call to call compiled code from another package directly. This is because package authors are not required to maintain a consistent .Call interface to their compiled code; rather, they just have to make sure the direct user-facing R exported functions retain a stable interface over different versions (or, if changed, are done so with prior warning etc.) Also remember that, as long as you obey all of the licenses, you can simply copy the source code that needs to be compiled into your own package. You'll obviously need to track development of the other package (which you'll need to do anyway) but then you can be sure that the calls you want to use work. -- Gray Calhoun, Assistant Professor of Economics at Iowa State http://gray.clhn.co (web) __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] legitimate use of :::
Peter Meilstrup: (05:01PM on Thu, Aug 22) One most often encounters namespace conflicts at the user level, when loading two packages that have no logical connection other than both bearing on your problem of the moment. Unless I'm mistaken, you can reassign the hidden functions, ie fna <- joespackage:::usefulfunction fnb <- janespackage:::usefulfunction which is a little bit of a pain, but makes the user's code unambiguous. This also works with two colons for explicitly exported functions. -- Gray Calhoun, Assistant Professor of Economics at Iowa State http://gray.clhn.co (web) __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] declaring package dependencies
John Fox: (12:15PM on Fri, Sep 13) [...cut...] I think that most users -- as opposed to R developers -- will find the package::function( ... ) syntax in examples not so much ugly as cryptic. I think that we have ample recent evidence on this list that even developers (I don't exempt myself) are confused by namespace issues. On balance, I prefer if (require(MASS)) { loglm( ...) } which tells the user that it's necessary to load MASS before using loglm(). It would be nice if examples ran in a "sandbox," so that an example could read something like library(MASS) loglm( ... ) . . . without affecting the path in the current session, and fail gracefully if the MASS package weren't available (unlikely, of course, in the case of MASS, but not more generally). Does assigning loglm <- MASS::loglm loglm( ... ) not work in examples anymore? (with MASS listed under 'Suggests'.) That seems like it could address both concerns, but it would mask loglm if it were already defined. -- Gray Calhoun, Assistant Professor of Economics at Iowa State http://gray.clhn.co // (515) 294-6271 // 467 Heady Hall __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Problem with & question about \preformatted in .Rd
Hi, The "\preformatted" environment in Rd files doesn't seem to escape long sequences of backslashes properly when converted to pdf (LaTeX) documentation. I'm running R version 2.14 (from subversion, revision 57751) on Linux (RHEL). Here's an example from the command line: echo "\title{test}\name{test}\section{problems}{\preformatted{print('begin\{block\}')}}" > temp.Rd R CMD Rdconv --type=latex temp.Rd which outputs: \inputencoding{utf8} \HeaderA{test}{test}{test} % \begin{Section}{problems} \begin{alltt}print('begin\\{block\\}')\end{alltt} \end{Section} and the double backslashes become newlines when this text is embedded in a complete document and converted to pdf. I expected from the documentation to get this: \inputencoding{utf8} \HeaderA{test}{test}{test} % \begin{Section}{problems} \begin{alltt}print('\bsl{}\bsl{}\bsl{}\begin\bsl{}\bsl{}\{block\bsl{}\bsl{}\}')\end{alltt} \end{Section} The problem seems to come from tools:::Rd2latex as this R code indicates: library(tools) tools:::Rd2latex(textConnection("\\title{test}\\name{test} \\section{problems}{ \\preformatted{ print('begin\\{block\\}') }}")) (the output is the same as from the command line above) I can get the behavior that I want by removing a few lines from the relevant part of tools:::Rd2latex and I provide a patch below, but I assume that the code that I removed was put there for a good reason so this isn't a good fix. make check-devel didn't find any errors, though. I'm happy to fill out a bug report for this if that's the next appropriate step. A question: why is there special code to handle "\var" inside \preformatted environments? The documentation reads: "\preformatted{text} Indicate text that is a literal example of a piece of a program. Text is displayed using typewriter font if possible. Formatting, e.g. line breaks, is preserved. Due to limitations in LaTeX as of this writing, this macro may not be nested within other markup macros other than \dQuote and \sQuote, as errors or bad formatting may result." which doesn't indicate that \var should be handled any differently than any other macro, but the code makes me think that R is trying to pass the macro through to LaTeX. Thanks! --Gray -- Gray Calhoun Assistant Professor of Economics, Iowa State University http://www.econ.iastate.edu/~gcalhoun patch: Index: src/library/tools/R/Rd2latex.R === --- src/library/tools/R/Rd2latex.R (revision 57751) +++ src/library/tools/R/Rd2latex.R (working copy) @@ -163,10 +163,7 @@ BSL = '@BSL@'; BSL2 = '@BSLBSL@'; #x <- fsub("\\dots", "...", x) - ## escape any odd \, e.g. \n - x <- fsub("", BSL, x) # change even ones x <- fsub("\\", BSL2, x) # odd ones - x <- fsub(BSL, "", x) # change back x <- psub("(?https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Problem with & question about \preformatted in .Rd
I need to correct one minor typo below: On Fri, Nov 25, 2011 at 6:12 PM, Gray Calhoun wrote: (cut a lot) > I expected from the documentation to get this: > > \inputencoding{utf8} > \HeaderA{test}{test}{test} > % > \begin{Section}{problems} > \begin{alltt}print('\bsl{}\bsl{}\bsl{}\begin\bsl{}\bsl{}\{block\bsl{}\bsl{}\}')\end{alltt} > \end{Section} The second to last line should read: \begin{alltt}print('\bsl{}\bsl{}\bsl{}\bsl{}begin\bsl{}\bsl{}\{block\bsl{}\bsl{}\}')\end{alltt} Sorry about that. --Gray -- Gray Calhoun Assistant Professor of Economics, Iowa State University http://www.econ.iastate.edu/~gcalhoun __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] unsplit list of data.frames with one column
Perhaps this is the intended behavior, but I discovered that unsplit throws an error when it tries to set rownames of a variable that has no dimension. This occurs when unsplit is passed a list of data.frames that have only a single column. An example: df <- data.frame(letters[seq(25)]) fac <- rep(seq(5), 5) unsplit(split(df, fac), fac) For reference, I'm using R version 2.9.0 (2009-04-17), subversion revision 48333, on Ubuntu 8.10. -- William H. Gray, III Computer Systems Analyst Biostatistics Shared Resource Vanderbilt-Ingram Cancer Center 571 Preston Building Nashville, TN 37232-6848 Ph. 615.936.0563 Fax 615.936.2602 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] schoolmath (PR#11488)
Full_Name: Will Gray Version: 2.7.0 OS: GNU/Linux (Debian) Submission from: (NULL) (160.129.18.69) The schoolmath package has several inaccuracies in it. Here is just a sample of some ways to get prime numbers between 1,000,000 and 1,000,100. Each method returns a different set and each result contains non-primes. data(primlist) (a <- primlist[primlist > 100 & primlist < 1000100]) (b <- is.prim(a)) which(!b) (c <- primes(100,1000100)) (d <- is.prim(c)) which(!d) Even the example for the function 'primes' gives some bad results. example(primes) -> x (y <- is.prim(x$value)) which(!y) I've tried contacting the maintainer(s) to let them know, but have not received a reply. In the meantime, I suggest this package be removed from CRAN. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel