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] Error in documentation of "merge"
Hi there seems to be an error in the documentation of the "merge" function: Arguments: x, y: data frames, or objects to be coerced to one. by, by.x, by.y: specifications of the common columns. See Details. all: logical; all = L is shorthand for all.x = L and all.y = L. The "L" should be a T or a TRUE. Cheers, Rainer -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax (F): +33 - (0)9 58 10 27 44 Fax (D):+49 - (0)3 21 21 25 22 44 email: rai...@krugs.de Skype: RMkrug [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Error in documentation of "merge"
On Nov 4, 2011, at 13:11 , Rainer M Krug wrote: > Hi > > there seems to be an error in the documentation of the "merge" function: > > Arguments: > >x, y: data frames, or objects to be coerced to one. > > by, by.x, by.y: specifications of the common columns. See ŒDetails‚. > > all: logical; Œall = L‚ is shorthand for Œall.x = L‚ and Œall.y = > L‚. > > > The "L" should be a T or a TRUE. I think it's on purpose: L indicates a logical value, TRUE _or_ FALSE. -pd -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Error in documentation of "merge"
On Fri, Nov 4, 2011 at 1:20 PM, peter dalgaard wrote: > > On Nov 4, 2011, at 13:11 , Rainer M Krug wrote: > > > Hi > > > > there seems to be an error in the documentation of the "merge" function: > > > > Arguments: > > > >x, y: data frames, or objects to be coerced to one. > > > > by, by.x, by.y: specifications of the common columns. See Details. > > > > all: logical; all = L is shorthand for all.x = L and all.y = > > L. > > > > > > The "L" should be a T or a TRUE. > > > I think it's on purpose: L indicates a logical value, TRUE _or_ FALSE. > Makes sense - In this case, I would suggest to add, "where L is either TRUE or FALSE" or similar to clarify. > > -pd > -- > Peter Dalgaard, Professor > Center for Statistics, Copenhagen Business School > Solbjerg Plads 3, 2000 Frederiksberg, Denmark > Phone: (+45)38153501 > Email: pd@cbs.dk Priv: pda...@gmail.com > > -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax (F): +33 - (0)9 58 10 27 44 Fax (D):+49 - (0)3 21 21 25 22 44 email: rai...@krugs.de Skype: RMkrug [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Error in documentation of "merge"
On Fri, Nov 4, 2011 at 8:20 AM, peter dalgaard wrote: > > On Nov 4, 2011, at 13:11 , Rainer M Krug wrote: > >> Hi >> >> there seems to be an error in the documentation of the "merge" function: >> >> Arguments: >> >> x, y: data frames, or objects to be coerced to one. >> >> by, by.x, by.y: specifications of the common columns. See ŒDetails‚. >> >> all: logical; Œall = L‚ is shorthand for Œall.x = L‚ and Œall.y = >> L‚. >> >> >> The "L" should be a T or a TRUE. > > > I think it's on purpose: L indicates a logical value, TRUE _or_ FALSE. I agree with Peter here. But it did make me pause the first time I read it on the help page years ago and furthermore, I think this is at least the second time where this particular formulation has been questioned on R-devel. I am not an index of R help pages, but I cannot recall seeing the 'L' as shorthand for logical. I suggest changing the formulation since it seems that several people have been confused, for example by writing out 'logical' instead of 'L'. Kasper __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Static R Build
Hello, I am trying to build a statically linked R linux binary that can be shipped around to different unknown linux environments without having to rely on its local shared libraries. However, it seems like the configure flag --enable-static doesn't produce the desired effect. How may I do this? Thank you for your help, Michael __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Static R Build
I'm not sure, but this option applies to Rblas and Rlapack. If you want R statically linked you need to add the "-static" to CFLAGS/FFLAGS etc. regards, daniel 2011/11/4 Michael Yan : > Hello, > > I am trying to build a statically linked R linux binary that can be shipped > around to different unknown linux environments without having to rely on its > local shared libraries. However, it seems like the configure flag > > --enable-static > > doesn't produce the desired effect. How may I do this? > > Thank you for your help, > Michael > > __ > 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] Static R Build
On Nov 4, 2011, at 4:37 PM, Michael Yan wrote: > Hello, > > I am trying to build a statically linked R linux binary that can be shipped > around to different unknown linux environments without having to rely on its > local shared libraries. However, it seems like the configure flag > > --enable-static > > doesn't produce the desired effect. That flag has nothing to do with that - it governs how R library will be built, not what it links against. > How may I do this? > Make sure you link against static libraries, but you must make sure they have PIC (if relevant for your platform). How you do that depends heavily on your system setup (and it gets really hard if you want to have things like Tcl/Tk, ..). The easiest is to simply install static libraries only so the linker picks them up automatically. Alternatively, you can specify static libraries directly as files (remmebr that you'll need to inslude dependecies, though, since static libraries don't have dependency chain resolution). Also depending on your compiler and/or how far you want to go, you may want to use -static-libgcc and friends (but, again, you must make sure they are PIC since they will be used from shared objects: packages). Alternative route is to put dependent shared objects into $R_HOME/lib - that's in fact by far the easiest. Cheers, Simon > Thank you for your help, > Michael > > __ > 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] Efficiency of factor objects
R factors are the natural way to represent factors -- and should be efficient since they use small integers. But in fact, for many (but not all) operations, R factors are considerably slower than integers, or even character strings. This appears to be because whenever a factor vector is subsetted, the entire levels vector is copied. For example: > i1 <- sample(1e4,1e6,replace=T) > c1 <- paste('x',i1) > f1 <- factor(c1) > system.time(replicate(1e4,{q1<-i1[100:200];1})) user system elapsed 0.030.000.04 > system.time(replicate(1e4,{q1<-c1[100:200];1})) user system elapsed 0.040.000.04 > system.time(replicate(1e4,{q1<-f1[100:200];1})) user system elapsed 0.670.000.68 Putting the levels vector in an environment speeds up subsetting: myfactor <- function(...) { f <- factor(...) g <- unclass(f) class(g) <- "myfactor" attr(g,"mylevels") <- as.environment(list(levels=attr(f,"mylevels"))) g } `[.myfactor` <- function (x, ...) { y <- NextMethod("[") attributes(y) <- attributes(x) y } > m1 <- myfactor(f1) > system.time(replicate(1e4,{q1<-m1[100:200];1})) user system elapsed 0.050.000.04 Given R's value semantics, I believe this approach can be extended to most of class factor's functionality without problems, copying the environment if necessary. Some quick tests seem to show that this is no slower than ordinary factors even for very small numbers of levels. To do this, appropriate methods for this class (print, [<-, levels<-, etc.) would have to be written. Perhaps some core R functions also have to be changed? Am I missing some obvious flaw in this approach? Has anyone already implemented a factors package using this or some similar approach? Thanks, -s __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Error in documentation of "merge"
> -Original Message- > From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] > On Behalf Of Kasper Daniel Hansen > Sent: November-04-11 5:26 AM > To: peter dalgaard > Cc: r-devel@r-project.org > Subject: Re: [Rd] Error in documentation of "merge" > > On Fri, Nov 4, 2011 at 8:20 AM, peter dalgaard wrote: > > > > On Nov 4, 2011, at 13:11 , Rainer M Krug wrote: > > > >> Hi > >> > >> there seems to be an error in the documentation of the "merge" function: > >> > >> Arguments: > >> > >> x, y: data frames, or objects to be coerced to one. > >> > >> by, by.x, by.y: specifications of the common columns. See ŒDetails‚. > >> > >> all: logical; Œall = L‚ is shorthand for Œall.x = L‚ and Œall.y = > >> L‚. > >> > >> > >> The "L" should be a T or a TRUE. > > > > > > I think it's on purpose: L indicates a logical value, TRUE _or_ FALSE. > > I agree with Peter here. But it did make me pause the first time I > read it on the help page years ago and furthermore, I think this is at > least the second time where this particular formulation has been > questioned on R-devel. I am not an index of R help pages, but I > cannot recall seeing the 'L' as shorthand for logical. I suggest > changing the formulation since it seems that several people have been > confused, for example by writing out 'logical' instead of 'L'. Seconded, as L does have another use as well now in numeric constants > 1L [1] 1 Steven McKinney > > Kasper > > __ > 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