Re: [R-pkg-devel] Data for unit testing in packages

2016-05-20 Thread Ben Bolker

  I usually put it in inst/testdata and access it via system.file()


On 16-05-20 01:45 PM, carlos cinelli wrote:
> Do you guys have any suggestions on how to store data for unit testing?
> 
> I am implementing some methods to estimate matrix entries from the
> marginals.  The input of the function is the row and column sums and the
> output is a N x N matrix.
> 
> What I am doing today is constructing the expected output by hand.
> 
> One example I am testing is a 7 x 7 matrix, which is fine to just put the
> code to create it on the test script.
> 
> However, I also want to create tests on larger examples, say a 1000 x 1000
> matrix, in which it would not be very handy to leave the code on the script.
> 
> Do you have any suggestions or best practices for that?
> 
> Best,
> 
> Carlos
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Data for unit testing in packages

2016-05-20 Thread Kasper Daniel Hansen
Very similar here.  I use the RUnit framework, which has testing scripts in
  inst/unitTests

I put scripts for creating the test data in
  inst/testData
and save rda files into
  inst/unitTests

I create the data set by R CMD BATCH and I save the .Rout file which
creates the test data, so I have a record of which packages / versions was
used to create it.

Kasper

On Fri, May 20, 2016 at 2:34 PM, Ben Bolker  wrote:

>
>   I usually put it in inst/testdata and access it via system.file()
>
>
> On 16-05-20 01:45 PM, carlos cinelli wrote:
> > Do you guys have any suggestions on how to store data for unit testing?
> >
> > I am implementing some methods to estimate matrix entries from the
> > marginals.  The input of the function is the row and column sums and the
> > output is a N x N matrix.
> >
> > What I am doing today is constructing the expected output by hand.
> >
> > One example I am testing is a 7 x 7 matrix, which is fine to just put the
> > code to create it on the test script.
> >
> > However, I also want to create tests on larger examples, say a 1000 x
> 1000
> > matrix, in which it would not be very handy to leave the code on the
> script.
> >
> > Do you have any suggestions or best practices for that?
> >
> > Best,
> >
> > Carlos
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-package-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-package-devel
> >
>
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Data for unit testing in packages

2016-05-20 Thread Hadley Wickham
If you're using testthat, check out expect_equal_to_reference.

Hadley

On Fri, May 20, 2016 at 7:45 PM, carlos cinelli
 wrote:
> Do you guys have any suggestions on how to store data for unit testing?
>
> I am implementing some methods to estimate matrix entries from the
> marginals.  The input of the function is the row and column sums and the
> output is a N x N matrix.
>
> What I am doing today is constructing the expected output by hand.
>
> One example I am testing is a 7 x 7 matrix, which is fine to just put the
> code to create it on the test script.
>
> However, I also want to create tests on larger examples, say a 1000 x 1000
> matrix, in which it would not be very handy to leave the code on the script.
>
> Do you have any suggestions or best practices for that?
>
> Best,
>
> Carlos
>
> [[alternative HTML version deleted]]
>
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel



-- 
http://hadley.nz

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] Bilingual (English and Portuguese) documentation in an R package

2016-05-20 Thread Lucas Ferreira Mation
Note: this was posted in this Stack Overflow

question, where I was advised to cross post here.


I am writing a package to facilitate importing Brazilian socio-economic
microdata sets (Census, PNAD, etc). I foresee two distinct groups of users
of the package:

   -

   Users in Brazil, who may feel more at ease with the documentation in
   Portuguese. The probably can understand English to some extent, but a
   foreign language would probably make the package feel less "ergonomic".
   -

   The broader international users community, from whom English
   documentation may be a necessary condition.

Is it possible to write a package in a way that the documentation is
"bilingual" (English and Portuguese), and that the language shown to the
user will depend on their country/language settings?

Also,

Is that doable within the roxygen2 documentation framework?

I realise there is a tradeoff of making the package more user-friendly by
making it bilingual vs. the increased complexity and difficulty to
maintain. General comments on this tradeoff from previous expirience are
also welcome.

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Bilingual (English and Portuguese) documentation in an R package

2016-05-20 Thread Duncan Murdoch

On 20/05/2016 3:39 PM, Lucas Ferreira Mation wrote:

Note: this was posted in this Stack Overflow

question, where I was advised to cross post here.


I am writing a package to facilitate importing Brazilian socio-economic
microdata sets (Census, PNAD, etc). I foresee two distinct groups of users
of the package:

   -

   Users in Brazil, who may feel more at ease with the documentation in
   Portuguese. The probably can understand English to some extent, but a
   foreign language would probably make the package feel less "ergonomic".
   -

   The broader international users community, from whom English
   documentation may be a necessary condition.

Is it possible to write a package in a way that the documentation is
"bilingual" (English and Portuguese), and that the language shown to the
user will depend on their country/language settings?

Also,

Is that doable within the roxygen2 documentation framework?

I realise there is a tradeoff of making the package more user-friendly by
making it bilingual vs. the increased complexity and difficulty to
maintain. General comments on this tradeoff from previous expirience are
also welcome.


I don't think so.  It is possible (and has been supported for a long 
time, due to work by Brian Ripley) to have error and warning messages 
translated, but we don't currently have a way to have other 
documentation in multiple languages.


I would suggest that you write a vignette in Portuguese, which is 
definitely possible, though there is no special support for that.


There has been some effort among the translation teams to implement 
regular help files in other languages, but I don't know if it has 
progressed.


You could also write all your documentation in Portuguese in a separate 
version of the package, and your Brazilian users would install that version.


Duncan Murdoch

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel