[Rd] Error building R from SVN - unable to run 'pdflatex' on 'example-1.tex'
G'day, I'm trying to build R using the code from SVN. I am able to successfully build the source from here: http://cran.r-project.org/src/base/R-2/R-2.15.2.tar.gz However, when building the code checked out from SVN (either from 2.15.2 tag, or the trunk) I get the following error: Error: running Sweave on vignette '/home/jonathon/projects/R/src/library/utils/vignettes/Sweave.Rnw' failed with message: chunk 2 Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, : unable to run 'pdflatex' on 'example-1.tex' Execution halted make[1]: *** [vignettes] Error 1 Is there a way I can fix this? with thanks Jonathon Love __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [R] gettext weirdness
Hi Brian, I appreciate your clarifications. I am sending this reply to the R-devel, as per you suggestion. As mentioned in my post, I have no prior experience with this R function and logically, I looked up its help page, which states: Conventionally the domain for *R* warning/error messages in package pkg is |R-pkg|, and that for C-level messages is |pkg|. While it certainly mentions messages in the C-realm, it does not state that they cannot be translated using gettext(). This is less than obvious and could perhaps be explicitly stated. If gettext() cannot be used to get the translation for the Error in message in some supported language, then is there an alternative? Best, Florent On 04/02/13 18:27, Prof Brian Ripley wrote: The 'wierdness' is that 'R' is a domain of C messages and you are trying to use it from R. How messages are massaged before being sent for translation depends on the language, including how trailing spaces are handled. There is no reason to expect domains intended for C code to work in R-level gettext(), nor in stop() etc. This was really an R-devel question: see the posting guide. On Mon, 4 Feb 2013, Florent Angly wrote: Hi, I am trying to use the gettext() function to translate some text. I have never used this function before, so, it's entirely possible that I am doing something wrong. The issue that I am encountering is that gettext() properly translates some text, but not some other. Natural language was compiled in my R (installed from the Debian repositories): $ R R version 2.15.1 (2012-06-22) -- Roasted Marshmallows [...] Natural language support but running in an English locale [...] q() Here is some text that has some translation in the file ./po/fr.po: #: src/main/errors.c:290 msgid invalid option \warning.expression\ msgstr option incorrecte \warning.expression\ [...] #: src/main/errors.c:582 msgid Error in msgstr Erreur dans Start R in French and see if I can get something translated to French: $ LANG=fr_FR.UTF8 R stop('This is an error') Erreur : This is an error bindtextdomain(R) # does not seem necessary, but just to be safe... [1] /usr/share/R/share/locale gettext(Error in , domain=R) [1] Error in invalid option \warning.expression\ - msg; gettext(msg, domain=R) [1] option incorrecte \warning.expression\ So, the stop() function successfully translates. I can also manually translate some entries, but why can does it not work for gettext(Error in , domain=R)? Any idea? Thanks Florent __ r-h...@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Error building R from SVN - unable to run 'pdflatex' on 'example-1.tex'
On 13-02-03 9:52 PM, Jonathon Love wrote: G'day, I'm trying to build R using the code from SVN. I am able to successfully build the source from here: http://cran.r-project.org/src/base/R-2/R-2.15.2.tar.gz However, when building the code checked out from SVN (either from 2.15.2 tag, or the trunk) I get the following error: Error: running Sweave on vignette '/home/jonathon/projects/R/src/library/utils/vignettes/Sweave.Rnw' failed with message: chunk 2 Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, : unable to run 'pdflatex' on 'example-1.tex' Execution halted make[1]: *** [vignettes] Error 1 Is there a way I can fix this? Probably, but if you want help you're going to need to give some more information first, such as what exactly you installed from SVN, what OS you are using, what target you tried to build, and anything else necessary so that a potential helper can duplicate what you did. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [R] gettext weirdness
On 04/02/2013 11:14, Florent Angly wrote: Hi Brian, I appreciate your clarifications. I am sending this reply to the R-devel, as per you suggestion. As mentioned in my post, I have no prior experience with this R function and logically, I looked up its help page, which states: Conventionally the domain for *R* warning/error messages in package pkg is |R-pkg|, and that for C-level messages is |pkg|. While it certainly mentions messages in the C-realm, it does not state that they cannot be translated using gettext(). This is less than obvious and could perhaps be explicitly stated. You are asking us to state what *can not* be done? It does clearly state the the domain for *R* messages in a package is R-pkg. Domain R is not of that form. If gettext() cannot be used to get the translation for the Error in message in some supported language, then is there an alternative? You put it in a domain named R-pkg, prepared using xgetttext(). Best, Florent On 04/02/13 18:27, Prof Brian Ripley wrote: The 'wierdness' is that 'R' is a domain of C messages and you are trying to use it from R. How messages are massaged before being sent for translation depends on the language, including how trailing spaces are handled. There is no reason to expect domains intended for C code to work in R-level gettext(), nor in stop() etc. This was really an R-devel question: see the posting guide. On Mon, 4 Feb 2013, Florent Angly wrote: Hi, I am trying to use the gettext() function to translate some text. I have never used this function before, so, it's entirely possible that I am doing something wrong. The issue that I am encountering is that gettext() properly translates some text, but not some other. Natural language was compiled in my R (installed from the Debian repositories): $ R R version 2.15.1 (2012-06-22) -- Roasted Marshmallows [...] Natural language support but running in an English locale [...] q() Here is some text that has some translation in the file ./po/fr.po: #: src/main/errors.c:290 msgid invalid option \warning.expression\ msgstr option incorrecte \warning.expression\ [...] #: src/main/errors.c:582 msgid Error in msgstr Erreur dans Start R in French and see if I can get something translated to French: $ LANG=fr_FR.UTF8 R stop('This is an error') Erreur : This is an error bindtextdomain(R) # does not seem necessary, but just to be safe... [1] /usr/share/R/share/locale gettext(Error in , domain=R) [1] Error in invalid option \warning.expression\ - msg; gettext(msg, domain=R) [1] option incorrecte \warning.expression\ So, the stop() function successfully translates. I can also manually translate some entries, but why can does it not work for gettext(Error in , domain=R)? Any idea? Thanks Florent __ r-h...@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ 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] Error building R from SVN - unable to run 'pdflatex' on 'example-1.tex'
On 04/02/13 23:47, Duncan Murdoch wrote: Probably, but if you want help you're going to need to give some more information first, such as what exactly you installed from SVN, what OS you are using, what target you tried to build, and anything else necessary so that a potential helper can duplicate what you did. my bad. sorry. on ubuntu 12.10 i did a checkout of the 2.15.2 tag https://svn.r-project.org/R/tags/R-2-15-2 next i ran the tools/rsync-recommended script then i ran: ./configure (it did give me these warnings) configure: WARNING: you cannot build info or HTML versions of the R manuals configure: WARNING: inconsolata.sty not found: PDF vignettes and package manuals will not be rendered optimally then i ran: make giving me the error: building/updating vignettes for package 'utils' ... processing 'Sweave.Rnw' Error: running Sweave on vignette '/home/jonathon/projects/R/src/library/utils/vignettes/Sweave.Rnw' failed with message: chunk 2 Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, : unable to run 'pdflatex' on 'example-1.tex' Execution halted make[1]: *** [vignettes] Error 1 make[1]: Leaving directory `/home/jonathon/projects/R/src/library' make: *** [vignettes] Error 2 other things that may be helpful: gcc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2 pdfTeX 3.1415926-2.4-1.40.13 (TeX Live 2012/Debian) The problem seems to be with building vignette's for the recommended packages. Any assistance would be appreciated. with thanks Jonathon Love On 13-02-03 9:52 PM, Jonathon Love wrote: G'day, I'm trying to build R using the code from SVN. I am able to successfully build the source from here: http://cran.r-project.org/src/base/R-2/R-2.15.2.tar.gz However, when building the code checked out from SVN (either from 2.15.2 tag, or the trunk) I get the following error: Error: running Sweave on vignette '/home/jonathon/projects/R/src/library/utils/vignettes/Sweave.Rnw' failed with message: chunk 2 Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, : unable to run 'pdflatex' on 'example-1.tex' Execution halted make[1]: *** [vignettes] Error 1 Is there a way I can fix this? Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Error building R from SVN - unable to run 'pdflatex' on 'example-1.tex'
Well, if all else fails read the manual: The PDF documentation (including doc/NEWS.pdf) and building vignettes needs tex and latex, or pdftex and pdflatex. We require LaTeX version 2005/12/01 or later (for UTF-8 support). Building PDF package manuals (including the R reference manual) and vignettes is sensitive to the version of the LaTeX package hyperref and we recommend that the TeX distribution used is keep up-to-date. A number of LaTeX packages are required (including url.sty, and listings.sty) and others such as hyperref and inconsolata are desirable (and without them you will need to change R's defaults: see Making the manuals). The default can be overridden by setting the environment variable R_RD4PDF. (On Unix-alikes, this will be picked up at install time and stored in etc/Renviron, but can still be overridden when the manuals are built.) The default value for R_RD4PDF is ‘times,inconsolata,hyper’: omit ‘hyper’ if you do not want hyperlinks (e.g. for printing the manual) or do not have LaTeX package hyperref, and omit ‘inconsolata’ if you do not have LaTeX package inconsolata installed. On 04/02/2013 14:27, Jonathon Love wrote: On 04/02/13 23:47, Duncan Murdoch wrote: Probably, but if you want help you're going to need to give some more information first, such as what exactly you installed from SVN, what OS you are using, what target you tried to build, and anything else necessary so that a potential helper can duplicate what you did. my bad. sorry. on ubuntu 12.10 i did a checkout of the 2.15.2 tag https://svn.r-project.org/R/tags/R-2-15-2 next i ran the tools/rsync-recommended script then i ran: ./configure (it did give me these warnings) configure: WARNING: you cannot build info or HTML versions of the R manuals configure: WARNING: inconsolata.sty not found: PDF vignettes and package manuals will not be rendered optimally then i ran: make giving me the error: building/updating vignettes for package 'utils' ... processing 'Sweave.Rnw' Error: running Sweave on vignette '/home/jonathon/projects/R/src/library/utils/vignettes/Sweave.Rnw' failed with message: chunk 2 Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, : unable to run 'pdflatex' on 'example-1.tex' Execution halted make[1]: *** [vignettes] Error 1 make[1]: Leaving directory `/home/jonathon/projects/R/src/library' make: *** [vignettes] Error 2 other things that may be helpful: gcc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2 pdfTeX 3.1415926-2.4-1.40.13 (TeX Live 2012/Debian) The problem seems to be with building vignette's for the recommended packages. Any assistance would be appreciated. with thanks Jonathon Love On 13-02-03 9:52 PM, Jonathon Love wrote: G'day, I'm trying to build R using the code from SVN. I am able to successfully build the source from here: http://cran.r-project.org/src/base/R-2/R-2.15.2.tar.gz However, when building the code checked out from SVN (either from 2.15.2 tag, or the trunk) I get the following error: Error: running Sweave on vignette '/home/jonathon/projects/R/src/library/utils/vignettes/Sweave.Rnw' failed with message: chunk 2 Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, : unable to run 'pdflatex' on 'example-1.tex' Execution halted make[1]: *** [vignettes] Error 1 Is there a way I can fix this? Duncan Murdoch __ 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
[Rd] R-lang edit: deparse(1:2) is no longer a good example of the R parser's non-invertibility
Hello, Apparently thanks to improvements to the R parser, this example from section 6.1 of the R Language Definition no longer holds. deparse(quote(c(1, 2))) [1] c(1, 2) deparse(1:2) [1] c(1, 2) Even running R-2.14.2, I get instead deparse(1:2) [1] 1:2 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R-lang edit: deparse(1:2) is no longer a good example of the R parser's non-invertibility
On 04/02/2013 12:20 PM, Josh O'Brien wrote: Hello, Apparently thanks to improvements to the R parser, this example from section 6.1 of the R Language Definition no longer holds. deparse(quote(c(1, 2))) [1] c(1, 2) deparse(1:2) [1] c(1, 2) Thanks, I'll replace that example with this one: str(quote(c(1,2))) language c(1, 2) str(c(1,2)) num [1:2] 1 2 deparse(quote(c(1,2))) [1] c(1, 2) deparse(c(1,2)) [1] c(1, 2) Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Error building R from SVN - unable to run 'pdflatex' on 'example-1.tex'
On 5 February 2013 at 01:27, Jonathon Love wrote: | On 04/02/13 23:47, Duncan Murdoch wrote: | Probably, but if you want help you're going to need to give some more | information first, such as what exactly you installed from SVN, what OS | you are using, what target you tried to build, and anything else | necessary so that a potential helper can duplicate what you did. | | my bad. sorry. | | on ubuntu 12.10 i did a checkout of the 2.15.2 tag Try this: sudo apt-get build-dep r-base which will install what the distro itself uses to build the package. Also look into './configure --help' to learn about different aspects of the build which you can turn on or off. I keep a little shell script with my prefered configuration to create a local build of r-devel from SVN. Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Contract Syntactic Sugar
## the following is a dream: add some sugar syntax to allow for contracts with teeth (in and out checking) is.positive - function(x) (all(x0)) exponentiate - function( x ::is.data.frame , exponent ::is.numeric is.positive) :: is.vector is.numeric { x$base :: is.positive## error also if base does not exist in x; may need some special IQ x$base^exponent } should be self-explanatory. anything that has '::' means run what is before through all the functions after and barf if it is not true. any other operator rather than :: or other syntax would be as good---this is just illustratory. in the end, this code should be viewed by R as the same as exponentiate - function( x, exponent ) { stopifnot( is.data.frame(x) ) stopifnot( is.numeric(exponent) ) stopifnot( is.positive(exponent) ) stopifnot( exists(base, x) ) stopifnot( is.positive( x$base ) ) return.value - x$base^exponent stopifnot( is.vector(return.value) ) stopifnot( is.numeric(return.value) ) return.value } is this a feasible summer project for a student with a prospect of inclusion of the completed code in the R core language itself if I pay for the development time? {or does better syntax already exist and I am just ignorant (which I often am)?} regards, /iaw Ivo Welch (ivo.we...@gmail.com) __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Contract Syntactic Sugar
Ivo, Have you looked at the TypeInfohttp://www.bioconductor.org/packages/2.12/bioc/html/TypeInfo.htmlBioConductor package by Gentleman and Temple Lang? I don't use it myself and can't speak to its current state, but from its description, and having talked to one of its authors (who, for full disclosure, is my advisor), it attempts to do what you want. Also, as an aside, :: already means something else in R so I'm not sure that particular sugar would work well. ~G On Mon, Feb 4, 2013 at 1:53 PM, ivo welch ivo.we...@anderson.ucla.eduwrote: ## the following is a dream: add some sugar syntax to allow for contracts with teeth (in and out checking) is.positive - function(x) (all(x0)) exponentiate - function( x ::is.data.frame , exponent ::is.numeric is.positive) :: is.vector is.numeric { x$base :: is.positive## error also if base does not exist in x; may need some special IQ x$base^exponent } should be self-explanatory. anything that has '::' means run what is before through all the functions after and barf if it is not true. any other operator rather than :: or other syntax would be as good---this is just illustratory. in the end, this code should be viewed by R as the same as exponentiate - function( x, exponent ) { stopifnot( is.data.frame(x) ) stopifnot( is.numeric(exponent) ) stopifnot( is.positive(exponent) ) stopifnot( exists(base, x) ) stopifnot( is.positive( x$base ) ) return.value - x$base^exponent stopifnot( is.vector(return.value) ) stopifnot( is.numeric(return.value) ) return.value } is this a feasible summer project for a student with a prospect of inclusion of the completed code in the R core language itself if I pay for the development time? {or does better syntax already exist and I am just ignorant (which I often am)?} regards, /iaw Ivo Welch (ivo.we...@gmail.com) __ 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] Contract Syntactic Sugar
Ivo, You might be interested in my lambda.r package which provides syntax (using the %::% operator) for type constraints. Given a function with n arguments, the type constraint requires n + 1 types, as the last type listed is the return type. Lambda.r also provides syntax for specifying any arbitrary condition on the input arguments via the %when% operator. For your example below you could do the following: exponentiate(x, exponent) %::% data.frame : numeric : numeric exponentiate(x, exponent) %when% { is.positive(x) } %as% { x$base ^ exponent } You can see more examples in the package (available on CRAN) or in the source (https://github.com/muxspace/lambda.r). HTH, Brian On Feb 4, 2013, at 4:53 PM, ivo welch ivo.we...@anderson.ucla.edu wrote: ## the following is a dream: add some sugar syntax to allow for contracts with teeth (in and out checking) is.positive - function(x) (all(x0)) exponentiate - function( x ::is.data.frame , exponent ::is.numeric is.positive) :: is.vector is.numeric { x$base :: is.positive## error also if base does not exist in x; may need some special IQ x$base^exponent } should be self-explanatory. anything that has '::' means run what is before through all the functions after and barf if it is not true. any other operator rather than :: or other syntax would be as good---this is just illustratory. in the end, this code should be viewed by R as the same as exponentiate - function( x, exponent ) { stopifnot( is.data.frame(x) ) stopifnot( is.numeric(exponent) ) stopifnot( is.positive(exponent) ) stopifnot( exists(base, x) ) stopifnot( is.positive( x$base ) ) return.value - x$base^exponent stopifnot( is.vector(return.value) ) stopifnot( is.numeric(return.value) ) return.value } is this a feasible summer project for a student with a prospect of inclusion of the completed code in the R core language itself if I pay for the development time? {or does better syntax already exist and I am just ignorant (which I often am)?} regards, /iaw Ivo Welch (ivo.we...@gmail.com) __ 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] Contract Syntactic Sugar
hi brian---interesting and very impressive. is it possible to move everything into one definition and/or to chain multiple conditions? exponentiate(x, exponent) %::% data.frame : c(numeric,allpositive) : integer %as% { x %has% base ## my invention, since this is not checked, and R is not strict enough x$base %::% allpositive x$base ^ exponent } multiple creations as in your doc examples on the same function are a recipe for errors for me. it's also why I am not too fond of TypeInfo. chaining conditions in my c() is not important, as long as I can define my own types (which can check multiple aspects at the same time). suggestion: in your doc example, can you define a different type than an integer? it's a little confusing. how about defining a strictly positive integer? regards, /iaw Ivo Welch (ivo.we...@gmail.com) http://www.ivo-welch.info/ J. Fred Weston Professor of Finance Anderson School at UCLA, C519 Director, UCLA Anderson Fink Center for Finance and Investments Free Finance Textbook, http://book.ivo-welch.info/ Editor, Critical Finance Review, http://www.critical-finance-review.org/ On Mon, Feb 4, 2013 at 2:10 PM, Brian Lee Yung Rowe r...@muxspace.com wrote: Ivo, You might be interested in my lambda.r package which provides syntax (using the %::% operator) for type constraints. Given a function with n arguments, the type constraint requires n + 1 types, as the last type listed is the return type. Lambda.r also provides syntax for specifying any arbitrary condition on the input arguments via the %when% operator. For your example below you could do the following: exponentiate(x, exponent) %::% data.frame : numeric : numeric exponentiate(x, exponent) %when% { is.positive(x) } %as% { x$base ^ exponent } You can see more examples in the package (available on CRAN) or in the source (https://github.com/muxspace/lambda.r). HTH, Brian On Feb 4, 2013, at 4:53 PM, ivo welch ivo.we...@anderson.ucla.edu wrote: ## the following is a dream: add some sugar syntax to allow for contracts with teeth (in and out checking) is.positive - function(x) (all(x0)) exponentiate - function( x ::is.data.frame , exponent ::is.numeric is.positive) :: is.vector is.numeric { x$base :: is.positive## error also if base does not exist in x; may need some special IQ x$base^exponent } should be self-explanatory. anything that has '::' means run what is before through all the functions after and barf if it is not true. any other operator rather than :: or other syntax would be as good---this is just illustratory. in the end, this code should be viewed by R as the same as exponentiate - function( x, exponent ) { stopifnot( is.data.frame(x) ) stopifnot( is.numeric(exponent) ) stopifnot( is.positive(exponent) ) stopifnot( exists(base, x) ) stopifnot( is.positive( x$base ) ) return.value - x$base^exponent stopifnot( is.vector(return.value) ) stopifnot( is.numeric(return.value) ) return.value } is this a feasible summer project for a student with a prospect of inclusion of the completed code in the R core language itself if I pay for the development time? {or does better syntax already exist and I am just ignorant (which I often am)?} regards, /iaw Ivo Welch (ivo.we...@gmail.com) __ 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] gettext weirdness
On 05/02/13 00:02, Prof Brian Ripley wrote: On 04/02/2013 11:14, Florent Angly wrote: Hi Brian, I appreciate your clarifications. I am sending this reply to the R-devel, as per you suggestion. As mentioned in my post, I have no prior experience with this R function and logically, I looked up its help page, which states: Conventionally the domain for *R* warning/error messages in package pkg is |R-pkg|, and that for C-level messages is |pkg|. While it certainly mentions messages in the C-realm, it does not state that they cannot be translated using gettext(). This is less than obvious and could perhaps be explicitly stated. You are asking us to state what *can not* be done? It does clearly state the the domain for *R* messages in a package is R-pkg. Domain R is not of that form. If C-level messages really cannot be read from R code, then yes, it makes a lot of sense to write in the documentation of this R function that this cannot be done, e.g. the sentence could be rewritten as: Conventionally the domain for *R* messages in package pkg is |R-pkg|. Note that C-level messages are in domain |pkg| but cannot be accessed by gettext(). It does clearly state the the domain for *R* messages in a package is R-pkg. Domain R is not of that form. If gettext() cannot be used to get the translation for the Error in message in some supported language, then is there an alternative? You put it in a domain named R-pkg, prepared using xgetttext(). Thank you. I am sure that this would work but that's not really an option seeing as I do not generate any R script files. In case this is of use to others, I'll add that a solution is to using ngettext() instead of gettext() (thanks Brian Cassidy). With ngettext(), I am successful in retrieving all desired translations: |ngettext( 1, Error: , , domain = R )| Best, Florent Best, Florent On 04/02/13 18:27, Prof Brian Ripley wrote: The 'wierdness' is that 'R' is a domain of C messages and you are trying to use it from R. How messages are massaged before being sent for translation depends on the language, including how trailing spaces are handled. There is no reason to expect domains intended for C code to work in R-level gettext(), nor in stop() etc. This was really an R-devel question: see the posting guide. On Mon, 4 Feb 2013, Florent Angly wrote: Hi, I am trying to use the gettext() function to translate some text. I have never used this function before, so, it's entirely possible that I am doing something wrong. The issue that I am encountering is that gettext() properly translates some text, but not some other. Natural language was compiled in my R (installed from the Debian repositories): $ R R version 2.15.1 (2012-06-22) -- Roasted Marshmallows [...] Natural language support but running in an English locale [...] q() Here is some text that has some translation in the file ./po/fr.po: #: src/main/errors.c:290 msgid invalid option \warning.expression\ msgstr option incorrecte \warning.expression\ [...] #: src/main/errors.c:582 msgid Error in msgstr Erreur dans Start R in French and see if I can get something translated to French: $ LANG=fr_FR.UTF8 R stop('This is an error') Erreur : This is an error bindtextdomain(R) # does not seem necessary, but just to be safe... [1] /usr/share/R/share/locale gettext(Error in , domain=R) [1] Error in invalid option \warning.expression\ - msg; gettext(msg, domain=R) [1] option incorrecte \warning.expression\ So, the stop() function successfully translates. I can also manually translate some entries, but why can does it not work for gettext(Error in , domain=R)? Any idea? Thanks Florent __ r-h...@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] Contract Syntactic Sugar
Ivo, If you don't like the multipart function syntax you can write a single definition. Personally I prefer this as it isolates data management logic and control flow from model/application logic. There are duck typing operators that you can use in the guard similar to the syntax you wrote. You can also create your own types and use that in a type constraint. However the type constraint syntax must be a distinct statement although you could embed it all within a guard. Here are three different approaches using lambda.r. NaturalNumber(x) %when% { all(is.positive(x)) } %as% { x } # Using an explicit type constraint with a custom type exponentiate(x, exponent) %::% data.frame : NaturalNumber : integer exponentiate(x, exponent) %when% { x %hasa% base } %as% { x$base ^ exponent } -- or -- # Embedding everything in a guard exponentiate(x, exponent) %when% { x %hasa% base x %isa% NaturalNumber } %as% { x$base ^ exponent } -- or -- # Eschewing a custom type for explicit statements exponentiate(x, exponent) %when% { x %hasa% base all(is.positive(x$base)) } %as% { x$base ^ exponent Warm Regards, Brian • Brian Lee Yung Rowe 917 496 4583 On Feb 4, 2013, at 6:23 PM, ivo welch ivo.we...@gmail.com wrote: hi brian---interesting and very impressive. is it possible to move everything into one definition and/or to chain multiple conditions? exponentiate(x, exponent) %::% data.frame : c(numeric,allpositive) : integer %as% { x %has% base ## my invention, since this is not checked, and R is not strict enough x$base %::% allpositive x$base ^ exponent } multiple creations as in your doc examples on the same function are a recipe for errors for me. it's also why I am not too fond of TypeInfo. chaining conditions in my c() is not important, as long as I can define my own types (which can check multiple aspects at the same time). suggestion: in your doc example, can you define a different type than an integer? it's a little confusing. how about defining a strictly positive integer? regards, /iaw Ivo Welch (ivo.we...@gmail.com) http://www.ivo-welch.info/ J. Fred Weston Professor of Finance Anderson School at UCLA, C519 Director, UCLA Anderson Fink Center for Finance and Investments Free Finance Textbook, http://book.ivo-welch.info/ Editor, Critical Finance Review, http://www.critical-finance-review.org/ On Mon, Feb 4, 2013 at 2:10 PM, Brian Lee Yung Rowe r...@muxspace.com wrote: Ivo, You might be interested in my lambda.r package which provides syntax (using the %::% operator) for type constraints. Given a function with n arguments, the type constraint requires n + 1 types, as the last type listed is the return type. Lambda.r also provides syntax for specifying any arbitrary condition on the input arguments via the %when% operator. For your example below you could do the following: exponentiate(x, exponent) %::% data.frame : numeric : numeric exponentiate(x, exponent) %when% { is.positive(x) } %as% { x$base ^ exponent } You can see more examples in the package (available on CRAN) or in the source (https://github.com/muxspace/lambda.r). HTH, Brian On Feb 4, 2013, at 4:53 PM, ivo welch ivo.we...@anderson.ucla.edu wrote: ## the following is a dream: add some sugar syntax to allow for contracts with teeth (in and out checking) is.positive - function(x) (all(x0)) exponentiate - function( x ::is.data.frame , exponent ::is.numeric is.positive) :: is.vector is.numeric { x$base :: is.positive## error also if base does not exist in x; may need some special IQ x$base^exponent } should be self-explanatory. anything that has '::' means run what is before through all the functions after and barf if it is not true. any other operator rather than :: or other syntax would be as good---this is just illustratory. in the end, this code should be viewed by R as the same as exponentiate - function( x, exponent ) { stopifnot( is.data.frame(x) ) stopifnot( is.numeric(exponent) ) stopifnot( is.positive(exponent) ) stopifnot( exists(base, x) ) stopifnot( is.positive( x$base ) ) return.value - x$base^exponent stopifnot( is.vector(return.value) ) stopifnot( is.numeric(return.value) ) return.value } is this a feasible summer project for a student with a prospect of inclusion of the completed code in the R core language itself if I pay for the development time? {or does better syntax already exist and I am just ignorant (which I often am)?} regards, /iaw Ivo Welch (ivo.we...@gmail.com) __ 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