Re: [Rd] Using unit-tests as examples

2014-01-20 Thread Alexey Sergushichev
Yes, this may work, but this way I have to have one test per file,
which is not very convenient.

---
Alexey


On Sat, Jan 18, 2014 at 7:43 PM, Hadley Wickham  wrote:
> If you're using roxygen2, you can use @example tag to include an
> external file into the examples.
>
> Hadley
>
> On Sat, Jan 18, 2014 at 7:18 AM, Alexey Sergushichev
>  wrote:
>> Hi,
>>
>> Which is the best way to use unit tests as examples for documentation?
>> I use testthat, but if there is a good way to do this, for example,
>> only with RUnit, it'd still be good to know.
>>
>> Unit-tests are usually simple and concise, so they are good candidates
>> for example code, but I don't want to copy them into documentation and
>> maintain by hands. I tried to google how people handle this, but
>> didn't find anything.
>>
>> ---
>> Best regards,
>> Alexey
>>
>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
>
> --
> http://had.co.nz/

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


Re: [Rd] [R-SIG-Mac] My first package

2014-01-20 Thread Matthew Denwood
On 20 Jan 2014, at 09:31, Federico Calboli  wrote:

> On 18 Jan 2014, at 14:31, Axel Urbiz  wrote:
> 
>> Hi All,
>> 
>> 
>> I'm planning to submit my first package to R, and although I read all the
>> documentation, I'm not very clear on the following 2 items, from which I'd
>> appreciate your guidance:
>> 
>> 
>> 1)I understand it is suggested to use the R dev version to build the
>> package.
> 
> Is it?  this is news to me.  I have a grand total of 2 packages up and I 
> never ever used R-devel, and never ever had a problem, had a report of a 
> problem or had a note from CRAn about my packages not being ok because I 
> built them with R-relase (or whatever it might be called) and not R-devel.
> 

For what it's worth, I also build my packages on the release version of R, but 
I do always first upload to the frankly invaluable win-builder service at 
http://win-builder.r-project.org  - this is mainly to check 
compatibility/issues under Windows (of which there are frequently several), but 
also checks for problems against R-devel (of which I don't think I've ever had 
any).  It is also very worthwhile checking the check logs for the current 
versions of your package on CRAN, as there are often minor issues identified on 
other systems (particularly solaris).

Cheers,

Matt


> F
> 
> 
> 
>> Which one specifically should I use to build a package on a Mac
>> OS? How about package dependencies, which version should I install on the R
>> dev version (and where should I get them)?
>> 
>> 
>> 2) Not sure if this one belongs to this list. Does licensing follow the
>> logic of "inheritance" (i.e. if all the package dependencies of my package
>> are "GPL-2 | GPL-3", does my package need to use the same license agreement?
>> 
>> 
>> 
>> Thanks!
>> 
>> Axel.
>> 
>>  [[alternative HTML version deleted]]
>> 
>> ___
>> R-SIG-Mac mailing list
>> r-sig-...@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> 
> ___
> R-SIG-Mac mailing list
> r-sig-...@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac


[[alternative HTML version deleted]]

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


Re: [Rd] [R-SIG-Mac] My first package

2014-01-20 Thread Federico Calboli
On 18 Jan 2014, at 14:31, Axel Urbiz  wrote:

> Hi All,
> 
> 
> I'm planning to submit my first package to R, and although I read all the
> documentation, I'm not very clear on the following 2 items, from which I'd
> appreciate your guidance:
> 
> 
> 1)I understand it is suggested to use the R dev version to build the
> package.

Is it?  this is news to me.  I have a grand total of 2 packages up and I never 
ever used R-devel, and never ever had a problem, had a report of a problem or 
had a note from CRAn about my packages not being ok because I built them with 
R-relase (or whatever it might be called) and not R-devel.

BW

F



> Which one specifically should I use to build a package on a Mac
> OS? How about package dependencies, which version should I install on the R
> dev version (and where should I get them)?
> 
> 
> 2) Not sure if this one belongs to this list. Does licensing follow the
> logic of "inheritance" (i.e. if all the package dependencies of my package
> are "GPL-2 | GPL-3", does my package need to use the same license agreement?
> 
> 
> 
> Thanks!
> 
> Axel.
> 
>   [[alternative HTML version deleted]]
> 
> ___
> R-SIG-Mac mailing list
> r-sig-...@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Using unit-tests as examples

2014-01-20 Thread Hadley Wickham
The problem with extracting a single test from a file is going to be
locating the relevant lines of code and cleanly pulling them out
(along with any needed supporting code). It might be better to attack
the problem in the opposite direction by having a roxygen2 directive
that inserted the block in both the examples and in a special testthat
file.

Hadley

On Mon, Jan 20, 2014 at 3:32 AM, Alexey Sergushichev
 wrote:
> Yes, this may work, but this way I have to have one test per file,
> which is not very convenient.
>
> ---
> Alexey
>
>
> On Sat, Jan 18, 2014 at 7:43 PM, Hadley Wickham  wrote:
>> If you're using roxygen2, you can use @example tag to include an
>> external file into the examples.
>>
>> Hadley
>>
>> On Sat, Jan 18, 2014 at 7:18 AM, Alexey Sergushichev
>>  wrote:
>>> Hi,
>>>
>>> Which is the best way to use unit tests as examples for documentation?
>>> I use testthat, but if there is a good way to do this, for example,
>>> only with RUnit, it'd still be good to know.
>>>
>>> Unit-tests are usually simple and concise, so they are good candidates
>>> for example code, but I don't want to copy them into documentation and
>>> maintain by hands. I tried to google how people handle this, but
>>> didn't find anything.
>>>
>>> ---
>>> Best regards,
>>> Alexey
>>>
>>> __
>>> R-devel@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>>
>>
>> --
>> http://had.co.nz/



-- 
http://had.co.nz/

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


Re: [Rd] How to debug an R package (with C code)

2014-01-20 Thread Gábor Csárdi
I don't know where you have gdb from, but it is not included in the latest
xcode, afaik.
If you install it by hand, or from brew, then you'll see what I saw.

Maybe you have a gdb version from an older xcode lying around, or I don't
know. See also
http://stackoverflow.com/questions/19554439/gdb-missing-in-os-x-mavericks

Gabor


On Sun, Jan 19, 2014 at 11:51 PM, Davor Cubranic wrote:

> I’m not sure what’s going on with your setup, but this is what I get on my
> machine when I press Ctrl-C just after the R prompt comes up when started
> with “R -d gdb":
>
> Program received signal SIGINT, Interrupt.
> 0x7fff874179aa in select$DARWIN_EXTSN ()
> (gdb) bt
> #0  0x7fff874179aa in select$DARWIN_EXTSN ()
> #1  0x000100178bcf in R_SelectEx (n=1, readfds=0x100316bc0,
> writefds=0x0, exceptfds=0x0, timeout=0x0, intr=0x100178800
> ) at sys-std.c:154
> #2  0x00010017960b in R_checkActivityEx [inlined] () at :331
> #3  0x00010017960b in Rstd_ReadConsole (prompt=0x7fff73ea07a8
> "P\003�s� ", buf=0x7fff5fbfe820 "`�_� ", len=1606412320,
> addtohistory=1606407976) at sys-std.c:920
> #4  0x0001000c4d19 in Rf_ReplIteration (rho=0x1018345f8,
> savestack=1606412384, browselevel=0, state=0x7fff5fbfd728) at main.c:209
> #5  0x0001000c5643 in R_ReplConsole [inlined] () at :307
> #6  0x0001000c5643 in run_Rmainloop () at main.c:984
> #7  0x00010e5b in main ()
>
> Version info:
>
> OS X: 10.9.1 (Mavericks)
> R: 3.0.2 (from CRAN)
> gdb: 6.3.50-20050815 (Apple version gdb-1824)
> Xcode: 5.0.2
>
> Davor
>
>
> On Jan 19, 2014, at 10:58 AM, Gábor Csárdi  wrote:
>
> On Sun, Jan 19, 2014 at 1:53 PM, Davor Cubranic wrote:
>
>> On Jan 17, 2014, at 6:17 AM, Gábor Csárdi  wrote:
>>
>> > Small note: if you are using a recent version of OSX, then gdb is
>> > essentially useless, but you can use llvm, which is nicer in many
>> respects,
>> > anyway.
>>
>>
>> What do you mean by this? Gdb is a debugger, and LLVM is a compiler
>> infrastructure. Perhaps you mean “lldb”?
>>
>
> Yes, I meant lldb, sorry.
>
>
>> Why do you say gdb is useless anyways? I haven’t seen any problems with
>> it on Mavericks.
>>
>
> Depends what compiler you use, I guess. On a CRAN version of R, this is
> what I get with gdb, after just pressing CTRL+C:
>
> Program received signal SIGINT, Interrupt.
> 0x7fff8fc449aa in ?? ()
> (gdb) bt
> #0  0x7fff8fc449aa in ?? ()
> #1  0x000100178bcf in ?? ()
> #2  0x04000400 in ?? ()
> #3  0x79fa5350 in ?? ()
> #4  0x000100178800 in ?? ()
> #5  0x7fff79fa57a8 in ?? ()
> #6  0x in ?? ()
> (gdb)
>
> which is not very useful. This is what I get with lldb:
>
> Process 52794 stopped
> * thread #1: tid = 0x2c0802, 0x7fff8fc449aa
> libsystem_kernel.dylib`select$DARWIN_EXTSN + 10, queue =
> 'com.apple.main-thread, stop reason = signal SIGSTOP
> frame #0: 0x7fff8fc449aa
> libsystem_kernel.dylib`select$DARWIN_EXTSN + 10
> libsystem_kernel.dylib`select$DARWIN_EXTSN + 10:
> -> 0x7fff8fc449aa:  jae0x7fff8fc449b4; select$DARWIN_EXTSN
> + 20
>0x7fff8fc449ac:  movq   %rax, %rdi
>0x7fff8fc449af:  jmpq   0x7fff8fc4119a; cerror
>0x7fff8fc449b4:  ret
> (lldb) bt
> * thread #1: tid = 0x2c0802, 0x7fff8fc449aa
> libsystem_kernel.dylib`select$DARWIN_EXTSN + 10, queue =
> 'com.apple.main-thread, stop reason = signal SIGSTOP
> frame #0: 0x7fff8fc449aa
> libsystem_kernel.dylib`select$DARWIN_EXTSN + 10
> frame #1: 0x000100178bcf libR.dylib`R_SelectEx(n=1,
> readfds=0x000100316bc0, writefds=0x,
> exceptfds=0x, timeout=, intr=) +
> 207 at sys-std.c:154
> frame #2: 0x00010017960b libR.dylib`Rstd_ReadConsole [inlined]
> R_checkActivityEx(ignore_stdin=0) + 266 at sys-std.c:331
> frame #3: 0x000100179501
> libR.dylib`Rstd_ReadConsole(prompt=0x7fff79fa57a8,
> buf=0x7fff5fbfe910, len=1606412560, addtohistory=) + 1825
> at sys-std.c:920
> frame #4: 0x0001000c4d19
> libR.dylib`Rf_ReplIteration(rho=0x0001008549f8, savestack=1606412624,
> browselevel=0, state=) + 185 at main.c:209
> frame #5: 0x0001000c5643 libR.dylib`run_Rmainloop [inlined]
> R_ReplConsole(browselevel=0, savestack=0, rho=0x0001008549f8) + 116 at
> main.c:307
> frame #6: 0x0001000c55cf libR.dylib`run_Rmainloop + 79 at
> main.c:984
> frame #7: 0x00010e5b R`main + 27
> frame #8: 0x00010e34 R`start + 52
> (lldb)
>
> I admit, "useless" was an overreaction, and maybe you can fix gdb somehow.
> I just did not spend any time on trying to fix it.
>
> Gabor
>
>
>>
>> Davor
>
>
>
>

[[alternative HTML version deleted]]

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


Re: [Rd] [R-SIG-Mac] My first package

2014-01-20 Thread Gábor Csárdi
On Mon, Jan 20, 2014 at 4:31 AM, Federico Calboli
wrote:
[...]

> Is it?  this is news to me.  I have a grand total of 2 packages up and I
> never ever used R-devel, and never ever had a problem, had a report of a
> problem or had a note from CRAn about my packages not being ok because I
> built them with R-relase (or whatever it might be called) and not R-devel.
>

>From the CRAN repository policy, that you also read and agreed to:

"Please ensure that R CMD check --as-cran has been run on the tarball to be
uploaded before submission. This should be done with the current version of
R-devel (or if that is not possible, current R-patched or the current
release of R.)"

Gabor

[...]

[[alternative HTML version deleted]]

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


Re: [Rd] [R-SIG-Mac] My first package

2014-01-20 Thread Federico Calboli

On 20 Jan 2014, at 14:51, Gábor Csárdi  wrote:

> On Mon, Jan 20, 2014 at 4:31 AM, Federico Calboli  
> wrote:
> [...]
> Is it?  this is news to me.  I have a grand total of 2 packages up and I 
> never ever used R-devel, and never ever had a problem, had a report of a 
> problem or had a note from CRAn about my packages not being ok because I 
> built them with R-relase (or whatever it might be called) and not R-devel.
> 
> From the CRAN repository policy, that you also read and agreed to:

To be honest I have little time to read the byzantine requirements of the 
policies but
> 
> "Please ensure that R CMD check --as-cran has been run on the tarball to be 
> uploaded before submission. This should be done with the current version of 
> R-devel (or if that is not possible, current R-patched or the current release 
> of R.)"

I do that *with the current release of R* and I never had an issue whatsoever.  
Incidentally the words 'This should be done with the current version of R-devel 
(or if that is not possible, current R-patched or the current release of R' 
translate in plainspeak 'run R CMD check --as-cran with whatever version of R 
provided it's not outdated'. 

F



> 
> Gabor
> 
> [...]



signature.asc
Description: Message signed with OpenPGP using GPGMail
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] [R-SIG-Mac] My first package

2014-01-20 Thread Gábor Csárdi
On Mon, Jan 20, 2014 at 9:58 AM, Federico Calboli
wrote:
[...]

> I do that *with the current release of R* and I never had an issue
> whatsoever.  Incidentally the words 'This should be done with the current
> version of R-devel (or if that is not possible, current R-patched or the
> current release of R' translate in plainspeak 'run R CMD check --as-cran
> with whatever version of R provided it's not outdated'.


That's an interesting "translation". Are you a CRAN maintainer?

I guess you were just lucky so far. Most packages are small and not
affected by changes between R-release and R-devel. But some of them are.

Also, R-devel typically has more rigorous package checks than R-release. My
package was delayed several times because it did not pass checks in R-devel
(it did in R-release). I guess this happened to other packages as well,
hence the sentence above was included in the policies.

Gabor

[[alternative HTML version deleted]]

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


[Rd] Fwd: [R-SIG-Mac] My first package

2014-01-20 Thread Gábor Csárdi
On Mon, Jan 20, 2014 at 10:34 AM, Federico Calboli  wrote:
[...]

>
> That's as interesting as the English language makes it -- please note of
> the expression 'should' as opposed to 'must', and the list of three options
> of R versions.
>

Well, my interpretation is that package maintainers are expected to make an
effort and check the package with R-devel. If they cannot for some reason,
e.g. they cannot install R-devel, then R-patched or R-release.

> Are you a CRAN maintainer?
>
> I maintain two packages on CRAN, if that's what you're asking.


No, that's not what I am asking.

 >
> > I guess you were just lucky so far. Most packages are small and not
> affected by changes between R-release and R-devel. But some of them are.
> >
> > Also, R-devel typically has more rigorous package checks than R-release.
>
> Does it?
>

E.g. in current R-devel:

* R CMD check reports namespaces imported _via_ ::: calls,
  including where this is unnecessary because :: would do or the
  code is in the namepace being imported from.

(http://stat.ethz.ch/R-manual/R-devel/NEWS)

> My package was delayed several times because it did not pass checks in
> R-devel (it did in R-release). I guess this happened to other packages as
> well, hence the sentence above was included in the policies.
>
> I presume that the issue is this: some packages are written solely in R,
> hence, unless one uses a particular and outdated syntax, there are no
> differences between R-devel and and R-current, whereas packages that call
> C/C++/Fortran code are subject to the vagaries of compilers and operating
> systems, and using R-devel should help future proofing the package, while
> maintaing compatibility with R-current.
>

Partially, but not completely. You can have issues with R code (or even the
manual!) as well, see above: if you have an unneeded ::: in your R code,
then it will pass the check in R-release, but not in R-devel.

Or, this one was new in R-3.0.2:

* R CMD check --as-cran checks the line widths in usage and
  examples sections of the package Rd files.

So again, back when this was only included in R-devel, your package with
too long lines in the manual page examples passed the check on R-release,
but not on R-devel.

Gabor

[[alternative HTML version deleted]]

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


Re: [Rd] formals() adds 0 to complex function arguments

2014-01-20 Thread peter dalgaard

On 20 Jan 2014, at 00:00 , Duncan Murdoch  wrote:
>>> 
>>> Someone might want to fix this by implementing a full syntax for complex 
>>> constants, but meanwhile, I think a passable workaround could be
>> 
>> That might be nice to do.  Not sure if it's easy or hard...
> 
> I think it's hard.  After seeing the 1, when the parser gets a "+", it's not 
> clear whether you're in the middle of a complex number or some other kind of 
> sum.  And since users can redefine "+", it could be a really different kind, 
> even if it's followed by 2i.

Yes. That's what I suspected; you may need to actually change the syntax. 

I was thinking something like a=1C+2i, or even more radically a=_Const_(1+2i) 
with the idea of evaluating the contents of _Const_() at parse time or maybe 
rather function definition time.  

The latter idea might solve some other issues where R structures can't be 
defined as constants (pretty much any nonscalar vector, for instance), and the 
associated issues with non-reversibility of deparse().

But as you say, it's likely to be hard.

-- 
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] [R-SIG-Mac] My first package

2014-01-20 Thread Simon Urbanek

On Jan 20, 2014, at 4:31 AM, Federico Calboli  wrote:

> On 18 Jan 2014, at 14:31, Axel Urbiz  wrote:
> 
>> Hi All,
>> 
>> 
>> I'm planning to submit my first package to R, and although I read all the
>> documentation, I'm not very clear on the following 2 items, from which I'd
>> appreciate your guidance:
>> 
>> 
>> 1)I understand it is suggested to use the R dev version to build the
>> package.
> 
> Is it?

Yes


>  this is news to me.  I have a grand total of 2 packages up and I never ever 
> used R-devel, and never ever had a problem, had a report of a problem or had 
> a note from CRAn about my packages not being ok because I built them with 
> R-relase (or whatever it might be called) and not R-devel.
> 

You got lucky so far ;). See earlier post - you're answering to an already 
answered thread.

Cheers,
Simon



> BW
> 
> F
> 
> 
> 
>> Which one specifically should I use to build a package on a Mac
>> OS? How about package dependencies, which version should I install on the R
>> dev version (and where should I get them)?
>> 
>> 
>> 2) Not sure if this one belongs to this list. Does licensing follow the
>> logic of "inheritance" (i.e. if all the package dependencies of my package
>> are "GPL-2 | GPL-3", does my package need to use the same license agreement?
>> 
>> 
>> 
>> Thanks!
>> 
>> Axel.
>> 
>>  [[alternative HTML version deleted]]
>> 
>> ___
>> R-SIG-Mac mailing list
>> r-sig-...@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> 
> ___
> R-SIG-Mac mailing list
> r-sig-...@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac

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


Re: [Rd] formals() adds 0 to complex function arguments

2014-01-20 Thread Hadley Wickham
On Sun, Jan 19, 2014 at 3:16 PM, peter dalgaard  wrote:
> It's not formals() that is doing you in. Rather, it is a conspiration between 
> two things:
> (a) R always displays complex constants as x+yi, even if x is zero and (b) 
> there really is no way to specify complex constants with non-zero  real part, 
> i.e. 1+2i is a sum of a real and and imaginary complex constant. You can see 
> the effect already at
>
>> quote(1+2i)
> 1 + (0+2i)

Maybe I'm missing something obvious, but why not omit the real part if
it's zero?

Hadley


-- 
http://had.co.nz/

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


Re: [Rd] Using unit-tests as examples

2014-01-20 Thread Spencer Graves
  You are probably wisest to follow Hadley's recommendation.  
[library(fortunes);  fortune(298)]



  However, my help files contain various constructs of the 
following form:



\dontshow{stopifnot(}
all.equal(fa, fa0)
\dontshow{)}


  where "fa" is returned by a function, and "fa0" is a manual 
computation of what I think the answer should be.



  Spencer Graves


On 1/20/2014 5:33 AM, Hadley Wickham wrote:

The problem with extracting a single test from a file is going to be
locating the relevant lines of code and cleanly pulling them out
(along with any needed supporting code). It might be better to attack
the problem in the opposite direction by having a roxygen2 directive
that inserted the block in both the examples and in a special testthat
file.

Hadley

On Mon, Jan 20, 2014 at 3:32 AM, Alexey Sergushichev
 wrote:

Yes, this may work, but this way I have to have one test per file,
which is not very convenient.

---
Alexey


On Sat, Jan 18, 2014 at 7:43 PM, Hadley Wickham  wrote:

If you're using roxygen2, you can use @example tag to include an
external file into the examples.

Hadley

On Sat, Jan 18, 2014 at 7:18 AM, Alexey Sergushichev
 wrote:

Hi,

Which is the best way to use unit tests as examples for documentation?
I use testthat, but if there is a good way to do this, for example,
only with RUnit, it'd still be good to know.

Unit-tests are usually simple and concise, so they are good candidates
for example code, but I don't want to copy them into documentation and
maintain by hands. I tried to google how people handle this, but
didn't find anything.

---
Best regards,
Alexey

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



--
http://had.co.nz/



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