[Rd] Milestone: 2000 packages on CRAN

2009-10-05 Thread Henrik Bengtsson
Today, 2009-10-04, from http://cran.r-project.org/web/packages/

Currently, the CRAN package repository features 1997 objects
including 1993 packages and 4 bundles containing 15 packages, for a
total of 2008 available packages.

It was 1.5 years ago (2007-04-12) we were at 1000 packages, cf.

  https://stat.ethz.ch/pipermail/r-devel/2007-April/045359.html

From my previous in-house statistics there were ~500 packages in Oct
2004, and ~250 in April 2003.

So, roughly, the number of packages doubles every 18 months.

My daily procrastination

/Henrik

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


[Rd] exTremes and ismev (PR#13981)

2009-10-05 Thread mzukisi . gwata
Greetings

I am attempting to load exTremes and this is what I get...

* utils:::menuInstallPkgs()
--- Please select a CRAN mirror for use in this session ---
trying URL '
http://cran.uk.r-project.org/bin/windows/contrib/2.9/extRemes_1.60.zip'
Content type 'application/zip' length 676182 bytes (660 Kb)
opened URL
downloaded 660 Kb

package 'extRemes' successfully unpacked and MD5 sums checked

The downloaded packages are in
C:\Users\Mzukisi\AppData\Local\Temp\RtmpDk0EBq\downloaded_packages
updating HTML package descriptions
Warning message:
In file.create(f.tg) :
  cannot create file 'C:\PROGRA~1\R\R-29~1.2/doc/html/packages.html', reason
'Permission denied'


*What could be the cause of this?

Mzukisi Gwata
Pretoria
South Africa

[[alternative HTML version deleted]]

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


Re: [Rd] exTremes and ismev (PR#13981)

2009-10-05 Thread Uwe Ligges



mzukisi.gw...@gmail.com wrote:

Greetings

I am attempting to load exTremes and this is what I get...

* utils:::menuInstallPkgs()
--- Please select a CRAN mirror for use in this session ---
trying URL '
http://cran.uk.r-project.org/bin/windows/contrib/2.9/extRemes_1.60.zip'
Content type 'application/zip' length 676182 bytes (660 Kb)
opened URL
downloaded 660 Kb

package 'extRemes' successfully unpacked and MD5 sums checked

The downloaded packages are in
C:\Users\Mzukisi\AppData\Local\Temp\RtmpDk0EBq\downloaded_packages
updating HTML package descriptions
Warning message:
In file.create(f.tg) :
  cannot create file 'C:\PROGRA~1\R\R-29~1.2/doc/html/packages.html', reason
'Permission denied'

*What could be the cause of this?



This is not bug in R!!!
Please read what a bug is in the FAQs.

For questionsabout R, please ask on the R-help mailing list.

In this case, there is not even an error anywhere, just a warning, that 
the given file that contains the list of installed packages could not be 
updated after the package's installatio, probably because auf limited 
permissions.


Uwe Ligges




Mzukisi Gwata
Pretoria
South Africa

[[alternative HTML version deleted]]

__
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] suggest enhancement to segments and arrows to facilitate horizontal and vertical segments

2009-10-05 Thread Prof Brian Ripley
This isn't a one-way street, as it means that some erroneous calls 
will not be detected, and code written to take advantage of this will 
only work under R = 2.10.0.


I think we should probably insist that one of x1 and y1 is supplied: 
if both are omitted arrows() would give a warning, but segments() 
would not.


On Fri, 2 Oct 2009, Tim Hesterberg wrote:


I suggest a simple enhancement to segments() and arrows() to
facilitate drawing horizontal and vertical segments --
set default values for the second x and y arguments equal to the first set.
This is handy, especially when the expressions for coordinates are long.

Compare:

Segments:
 function (x0, y0, x1 = x0, y1 = y0, col = par(fg), lty = par(lty),
---

function (x0, y0, x1, y1, col = par(fg), lty = par(lty),


Arrows:
 function (x0, y0, x1 = x0, y1 = y0, length = 0.25, angle = 30, code = 2,
---

function (x0, y0, x1, y1, length = 0.25, angle = 30, code = 2,


Tim Hesterberg


--
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] R 2.9.2 crashes when sorting latin1-encoded strings

2009-10-05 Thread Prof Brian Ripley

This was a missing PROTECT() in do_order.

But I'll echo what Simon Urbanek said: don't do that but rather use 
the documented ways to re-encode the file as you read it.  (Latin-1 
used to be needed for collation on Mac OS X as C-level collation in 
UTF-8 was completely broken -- but we have worked around that.)


We provided fileEncoding= in read.table for those who failed to RTFM 
and thought encoding= was to set the file encoding, but it seems that 
encodings are simply too hard a concept for some R users.


On Wed, 30 Sep 2009, Stefan Evert wrote:


Hi everyone!

I think I stumbled over a bug in the latest R 2.9.2 patched for OS X:


R version 2.9.2 Patched (2009-09-24 r49861)
i386-apple-darwin9.8.0



When I try to sort latin1-encoded character vectors, R sometimes crashes with 
a segmentation fault.  I'm running OS X 10.5.8 and have observed this
behaviour both with the i386 and x86_64 builds, in the R.app GUI as well as 
on the command line.


Here's a minimal example that reliably triggers the crash on my machine:

=
print(sessionInfo())

words - c(aa, ab, a\xfc, a\xe4, b\xe4, b\xfc, \xe4\xfc)
str(words)

print(table(Encoding(words)))
Encoding(words) - latin1  # this is the correct encoding!
print(table(Encoding(words)))

N - 1000
words - rep(words, length.out=N)

print(N)
for (i in 1:N) {
x - words[1:i]
# the following line will crash for some i, depending on the particular
# strings in words and the subset selected for x above
order(x)
}
=

The output I get from this code is appended at the end of the mail. Note that 
R incorrectly declares the latin1 strings in word to have UTF-8 encoding 
(this seems wrong to me because the \x escapes insert raw bytes into the 
string). The crash only occurs if the correct latin1 encoding (or 
unknown) is explicitly specified. Otherwise the string handling code 
appears to ignore everything after the first invalid multibyte character.


I haven't been able to trigger the bug without some kind of loop.  The crash 
always occurs at the same iteration, but this changes depending on the 
contents of words and the specific subset selected in each loop iteration. 
Also note that the 64-bit version of R gives a different error message.  If I 
omit the unrelated statement print(N), the 64-bit version segfaults and the 
32-bit version just hangs with high CPU load. All this suggests to me that 
there must be some insidious memory corruption or stack/range overflow in the 
internal ordering code.


Can other people reproduce this problem on different platforms and possibly 
with different versions of R?



BTW, I ran into the crash when trying to read.delim() a file in latin1 
encoding, using either encoding=latin1 or fileEncoding=latin1, and then 
converting it back and forth between a character vector and a factor.  I 
still don't understand what's going on there.  The behaviour of read.delim() 
seems to depend very much on my locale settings when running R, which is 
rather unpleasant.  Is there a way to find out how strings are stored 
internally (i.e. getting the exact byte representation) and whether R 
believes them to be in UTF-8 or latin1 encoding?



Best regards,
Stefan Evert

[ stefan.ev...@uos.de | http://purl.org/stefan.evert ]





Output of sample code on my machine:


print(sessionInfo())

R version 2.9.2 Patched (2009-09-24 r49861)
i386-apple-darwin9.8.0

locale:
en_GB/en_GB/C/C/en_GB/en_GB

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base


words - c(aa, ab, a\xfc, a\xe4, b\xe4, b\xfc, \xe4\xfc)
str(words)

chr [1:7] aa ab a\xfc a\xe4 b\xe4 b\xfc ...

print(table(Encoding(words)))


unknown   UTF-8
   2   5


Encoding(words) - latin1  # this is the correct encoding!
print(table(Encoding(words)))


latin1 unknown
   5   2


N - 1000
words - rep(words, length.out=N)

print(N)

[1] 1000

for (i in 1:N) {

+   x - words[1:i]
+   # the following line will crash for some i, depending on the particular
+   # strings in words and the subset selected for x above
+   order(x)
+ }

*** caught bus error ***
address 0x86, cause 'non-existent physical address'

Traceback:
1: order(x)
aborting ...
Bus error


64-bit version:


print(sessionInfo())

R version 2.9.2 Patched (2009-09-24 r49861)
x86_64-apple-darwin9.8.0

locale:
en_GB/en_GB/C/C/en_GB/en_GB

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base


words - c(aa, ab, a\xfc, a\xe4, b\xe4, b\xfc, \xe4\xfc)
str(words)

chr [1:7] aa ab a\xfc a\xe4 b\xe4 b\xfc ...

print(table(Encoding(words)))


unknown   UTF-8
   2   5


Encoding(words) - latin1  # this is the correct encoding!
print(table(Encoding(words)))


latin1 unknown
   5   2


N - 1000
words - rep(words, length.out=N)

print(N)

[1] 1000

for (i in 1:N) {

+   x - words[1:i]
+   # the following line will crash for some i, depending on the particular
+   # strings in words and the subset selected for x above
+   order(x)
+ }
Error in order(x) : 

[Rd] how to document stuff most users don't want to see

2009-10-05 Thread Charles Geyer
The functions metrop and temper in the mcmc package have a debug = FALSE
argument that when TRUE adds a lot of debugging information to the returned
list.  This is absolutely necessary to test the functions, because one
generally knows nothing about the simulated distribution except what what
one learns from MCMC samples.  Hence you must expose all details of the
simulation to have any hope of checking that it is doing what it is supposed
to do.  However, this information is of interested mostly (perhaps solely)
to developers.  So I didn't document it in the Rd files for these functions.

But it has ocurred to me that people might be interested in how these functions
are validated, and I would like to document the debug output somewhere, but I
don't want to clutter up the documentation that ordinary users see.  That
suggests a separate help page for debugging.  Looking at Writing R Extensions
it doesn't seem like there is a type of Rd file for this purpose.  I suppose
it could be added in (fairly long) sections titled Debug Output in metrop.Rd
and temper.Rd or it could be put in a package help page (although that's not
what that kind of page is really for).  Any other possibilities to consider?
-- 
Charles Geyer
Professor, School of Statistics
University of Minnesota
char...@stat.umn.edu

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


Re: [Rd] how to document stuff most users don't want to see

2009-10-05 Thread Duncan Murdoch

On 10/5/2009 1:50 PM, Charles Geyer wrote:

The functions metrop and temper in the mcmc package have a debug = FALSE
argument that when TRUE adds a lot of debugging information to the returned
list.  This is absolutely necessary to test the functions, because one
generally knows nothing about the simulated distribution except what what
one learns from MCMC samples.  Hence you must expose all details of the
simulation to have any hope of checking that it is doing what it is supposed
to do.  However, this information is of interested mostly (perhaps solely)
to developers.  So I didn't document it in the Rd files for these functions.

But it has ocurred to me that people might be interested in how these functions
are validated, and I would like to document the debug output somewhere, but I
don't want to clutter up the documentation that ordinary users see.  That
suggests a separate help page for debugging.  Looking at Writing R Extensions
it doesn't seem like there is a type of Rd file for this purpose.  I suppose
it could be added in (fairly long) sections titled Debug Output in metrop.Rd
and temper.Rd or it could be put in a package help page (although that's not
what that kind of page is really for).  Any other possibilities to consider?


I think writing it up in a vignette would probably be most appropriate. 
 You can link directly to a vignette from a man page (though not, 
unfortunately, vice versa).  For example, if you look at

package?grid, you'll see a list that was generated by this code:

Further information is available in the following
\link{vignettes}:
\tabular{ll}{
\code{grid} \tab Introduction to \code{grid} (\url{../doc/grid.pdf})\cr
\code{displaylist} \tab Display Lists in \code{grid} 
(\url{../doc/displaylist.pdf})\cr


...

Duncan Murdoch

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


Re: [Rd] how to document stuff most users don't want to see

2009-10-05 Thread spencerg
There are many arguments in many functions that are rarely used.  I 
prefer to see it all documented in the help pages.  If they are not 
documented in the help pages (and sometimes even if they are), a user 
who wants them can invent other ways to get similar information with 
much greater effort, and do so for years only to eventually find a much 
easier way buried in the documentation.  Example:  I was frustrated for 
years that nls would refuse to produce output if it did not converge.  
I often used optim instead of nls for that reason.  However, the 
list returned by optim does not have the nice methods that one can use 
with an nls object.  Eventually, I found the warnOnly option 
documented under nls.control, which has made nls easier for me to use. 


Spencer Graves


William Dunlap wrote:

There are several help files in the R sources that
describe concepts and not particular R objects.
E.g., help(Methods), help(Syntax), and help(regex).
They don't have a docType  entry and their alias
entries do not refer to functions.  Perhaps your
debugging documentation could go into a similar
*.Rd file.

Does check balk at such help files in a package? Should it?
Should there be a special docType for such help files?

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

  

-Original Message-
From: r-devel-boun...@r-project.org 
[mailto:r-devel-boun...@r-project.org] On Behalf Of Charles Geyer

Sent: Monday, October 05, 2009 10:51 AM
To: r-devel@r-project.org
Subject: [Rd] how to document stuff most users don't want to see

The functions metrop and temper in the mcmc package have a 
debug = FALSE
argument that when TRUE adds a lot of debugging information 
to the returned

list.  This is absolutely necessary to test the functions, because one
generally knows nothing about the simulated distribution 
except what what
one learns from MCMC samples.  Hence you must expose all 
details of the
simulation to have any hope of checking that it is doing what 
it is supposed
to do.  However, this information is of interested mostly 
(perhaps solely)
to developers.  So I didn't document it in the Rd files for 
these functions.


But it has ocurred to me that people might be interested in 
how these functions
are validated, and I would like to document the debug output 
somewhere, but I
don't want to clutter up the documentation that ordinary 
users see.  That
suggests a separate help page for debugging.  Looking at 
Writing R Extensions
it doesn't seem like there is a type of Rd file for this 
purpose.  I suppose
it could be added in (fairly long) sections titled Debug 
Output in metrop.Rd
and temper.Rd or it could be put in a package help page 
(although that's not
what that kind of page is really for).  Any other 
possibilities to consider?

--
Charles Geyer
Professor, School of Statistics
University of Minnesota
char...@stat.umn.edu

__
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

  



--
Spencer Graves, PE, PhD
President and Chief Operating Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567

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


Re: [Rd] unit testing for R packages?

2009-10-05 Thread Duncan Murdoch

On 10/5/2009 3:01 PM, Blair Christian wrote:

Hi All,

I'm interested in putting some unit tests into an R package I'm
building.  I have seen assorted things such as Runit library, svUnit
library, packages
with 'tests' directories, etc

I grep'd unit test through the writing R extensions manual but didn't find
anything.  Are there any suggestions out there?  



Nothing very specific, but what there is is described in that manual in 
the discussion of the tests subdirectory.


Duncan Murdoch

Currently I have

several (a lot?) classes/methods that I keep tinkering with, and I'd
like to run a script frequently to check that I don't cause any
unforeseen problems.

Right now I'm writing the classes/methods, but will be packaging it up soon.

Thx,
Blair

__
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] unit testing for R packages?

2009-10-05 Thread Seth Falcon
Hi,

On Mon, Oct 5, 2009 at 12:01 PM, Blair Christian
blair.christ...@gmail.com wrote:
 I'm interested in putting some unit tests into an R package I'm
 building.  I have seen assorted things such as Runit library, svUnit
 library, packages
 with 'tests' directories, etc

 I grep'd unit test through the writing R extensions manual but didn't find
 anything.  Are there any suggestions out there?  Currently I have
 several (a lot?) classes/methods that I keep tinkering with, and I'd
 like to run a script frequently to check that I don't cause any
 unforeseen problems.

I've had good experiences using RUnit.  To date, I've mostly used
RUnit by putting tests in inst/unitTests and creating a Makefile there
to run the tests.  You should also be able to use RUnit in a more
interactive fashion inside an interactive R session in which you are
doing development.

The vignette in svUnit has an interesting approach for integrating
unit testing into R CMD check via examples in an Rd file within the
package.

+ seth

-- 
Seth Falcon | @sfalcon | http://userprimary.net/user

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


Re: [Rd] unit testing for R packages?

2009-10-05 Thread Paul Gilbert
Seth

I should look at RUnit more carefully sometime, but having had my own system in 
place from much earlier, I've never made the move. Basically I just use files 
in the tests/ directory which are run by a makefile in the package directory 
above. Roughly, this just means that I can run the tests quickly before 
building and checking the package. Is there a (very short) explanation of the 
main things that RUnit gives beyond this?

Thanks,
Paul

 -Original Message-
 From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-
 project.org] On Behalf Of Seth Falcon
 Sent: October 5, 2009 3:48 PM
 To: Blair Christian
 Cc: r-devel@r-project.org
 Subject: Re: [Rd] unit testing for R packages?
 
 Hi,
 
 On Mon, Oct 5, 2009 at 12:01 PM, Blair Christian
 blair.christ...@gmail.com wrote:
  I'm interested in putting some unit tests into an R package I'm
  building.  I have seen assorted things such as Runit library, svUnit
  library, packages
  with 'tests' directories, etc
 
  I grep'd unit test through the writing R extensions manual but
 didn't find
  anything.  Are there any suggestions out there?  Currently I have
  several (a lot?) classes/methods that I keep tinkering with, and I'd
  like to run a script frequently to check that I don't cause any
  unforeseen problems.
 
 I've had good experiences using RUnit.  To date, I've mostly used
 RUnit by putting tests in inst/unitTests and creating a Makefile there
 to run the tests.  You should also be able to use RUnit in a more
 interactive fashion inside an interactive R session in which you are
 doing development.
 
 The vignette in svUnit has an interesting approach for integrating
 unit testing into R CMD check via examples in an Rd file within the
 package.
 
 + seth
 
 --
 Seth Falcon | @sfalcon | http://userprimary.net/user
 
 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel


La version française suit le texte anglais.



This email may contain privileged and/or confidential information, and the Bank 
of
Canada does not waive any related rights. Any distribution, use, or copying of 
this
email or the information it contains by other than the intended recipient is
unauthorized. If you received this email in error please delete it immediately 
from
your system and notify the sender promptly by email that you have done so. 



Le présent courriel peut contenir de l'information privilégiée ou 
confidentielle.
La Banque du Canada ne renonce pas aux droits qui s'y rapportent. Toute 
diffusion,
utilisation ou copie de ce courriel ou des renseignements qu'il contient par une
personne autre que le ou les destinataires désignés est interdite. Si vous 
recevez
ce courriel par erreur, veuillez le supprimer immédiatement et envoyer sans 
délai à
l'expéditeur un message électronique pour l'aviser que vous avez éliminé de 
votre
ordinateur toute copie du courriel reçu.
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Wish for stripchart to handle pch %in% 21:25 with bg (PR#13984)

2009-10-05 Thread lobry
Full_Name: Jean Lobry
Version: 2.9.0
OS: i386-apple-darwin8.11.1
Submission from: (NULL) (83.197.82.45)


Dear R-core,

I have posted a 
href=http://finzi.psych.upenn.edu/Rhelp08/2009-September/212688.html;this/a
on R-help, and then a
href=http://finzi.psych.upenn.edu/R/R-devel/2009-September/054929.html;that/a
on R-Dev.

Looks for me as a documentation bug for the naive user: the documentation for
function stripchart() should state more explicitly that it does not handle
colorized points (i.e. pch in 21:25). I agree that the documentation is
perfectly correct for advanced users, but this is not cristal clear, under
2.9.0, try:

###
x - round(rnorm(50))
stripchart(x,  pch = 21, col = black, bg = pink, method = jitter)
points(0.5, 1, pch = 21, col = black, bg = pink, cex = 2)
###

My wish is either for stripchart() to handle this case or for the documentation
of stripchart() to say more explicitly that it does not handle this case.

Not very important, but this is a real end-user casework. Hope you enjoy how
I was reluctant to submit a documentation bug report in this case.

HTH,

Best,

Z.

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


[Rd] R's --enable-threads does nothing?; gdb needs -lpthread

2009-10-05 Thread Andrew Piskorski
In the R-2-9-branch (svn revision 49914, 2009-09-24), R's configure
script has an --enable-threads option.  But, does it do anything
useful?  When I use --enable-threads=posix, some of the configure
output changes slightly, but it seems to have no effect on the actual
link commands used when building R.  Is that a bug, or am I
misunderstanding what it's supposed to do?

Btw, ldd said that exactly these 4 objects are linked against
libpthread.so.0, regardless of whether I use --enable-threads or not:
 
  ./lib/R/modules/x86_64/R_X11.so
  ./lib/R/library/tcltk/libs/x86_64/tcltk.so
  ./lib/R/site-library/bigmemory/libs/x86_64/bigmemory.so
  ./lib/R/site-library/Rmpi/libs/x86_64/Rmpi.so

Next I tried setting the LIBS=-lpthread environment variable when
calling configure - that works.  (Perhaps I should have also set
FLIBS, I'm not sure.)  The generated Makeconf file now has this:

  LIBS =  -ldl -lm -lpthread 

and building with that links my libR.so against libpthread.so.0, which
fixes the gdb problem described below.  Is there any reason you know
of NOT to link R with -lpthread on Linux, any potential downside?

Now, why do I care about this -lpthread stuff in the first place?
It's to work around a gdb limitation.

I have a custom library of C code which I use from R, and my library
needs to be linked with -lpthread.  I know that R isn't thread-safe,
and my code is not itself using threads, but it in turn statically
links in some lower level libraries which insist on having the
-lpthread.

That has worked fine for me for a long time, no problems, except that
gdb won't work!  When I run R under the debugger with R -d gdb, gdb
only works if my own linked-with-pthread package is NOT loaded.  As
soon as I load it, gdb stops with this error:

   [Thread debugging using libthread_db enabled] 
   Error while reading shared library symbols: 
   Cannot find new threads: generic error 

Googling says that happens because the R binary starts out without
thread support, and gdb doesn't know what to do when my *.so suddenly
brings in the thread stuff.  Since I can't stop using -lpthread in my
library, the obvious fix is for me to build R itself with -lpthread,
so gdb doesn't get confused.

-- 
Andrew Piskorski a...@piskorski.com
http://www.piskorski.com/

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


Re: [Rd] unit testing for R packages?

2009-10-05 Thread Duncan Murdoch

On 05/10/2009 4:39 PM, spencerg wrote:
I put unit test in the examples, using \dontshow to hide stopifnot.  
Many help pages I've written contain code like the following: 



A - functionDocumentedHere()
B - manuallyComputedAnswer

\dontshow{stopifnot(}
all.equal(A, B)
\dontshow{)}


This will fail in a future release of R, because those aren't valid 
expressions within \dontshow{}, which expects R code.  You can achieve 
the same effect using the clearer


all.equal(A,B)
\dontshow{ stopifnot(isTrue(.Last.value)) }

Duncan Murdoch




  I think it helps the documentation to include an example comparing 
a special case computed using a function with a manual computation.  
However, stopifnot contributes nothing to user understanding, so I 
hide it.  One could also use \dontshow to hide entire examples that 
check trivial details you think would not interest users. 



  Spencer


Seth Falcon wrote:

Hi,

On Mon, Oct 5, 2009 at 12:01 PM, Blair Christian
blair.christ...@gmail.com wrote:
  

I'm interested in putting some unit tests into an R package I'm
building.  I have seen assorted things such as Runit library, svUnit
library, packages
with 'tests' directories, etc

I grep'd unit test through the writing R extensions manual but didn't find
anything.  Are there any suggestions out there?  Currently I have
several (a lot?) classes/methods that I keep tinkering with, and I'd
like to run a script frequently to check that I don't cause any
unforeseen problems.


I've had good experiences using RUnit.  To date, I've mostly used
RUnit by putting tests in inst/unitTests and creating a Makefile there
to run the tests.  You should also be able to use RUnit in a more
interactive fashion inside an interactive R session in which you are
doing development.

The vignette in svUnit has an interesting approach for integrating
unit testing into R CMD check via examples in an Rd file within the
package.

+ seth

  





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


Re: [Rd] unit testing for R packages?

2009-10-05 Thread Duncan Murdoch

On 05/10/2009 6:06 PM, spencerg wrote:
Hi, Duncan: 



  Thanks for the warning.  Can you give me a hint of which release 
might require this?  In particular, will it be R 2.10.0, coming quite 
soon? 


The alpha version of 2.10.0 lets this pass, and I can't see changing 
that now.  But 2.11.0 (due next spring) may well enforce the rules that 
have been documented but unenforced since before the release of 2.9.0.


Duncan Murdoch



  Thanks,
  Spencer


Duncan Murdoch wrote:

On 05/10/2009 4:39 PM, spencerg wrote:
I put unit test in the examples, using \dontshow to hide 
stopifnot.  Many help pages I've written contain code like the 
following:


A - functionDocumentedHere()
B - manuallyComputedAnswer

\dontshow{stopifnot(}
all.equal(A, B)
\dontshow{)}
This will fail in a future release of R, because those aren't valid 
expressions within \dontshow{}, which expects R code.  You can achieve 
the same effect using the clearer


all.equal(A,B)
\dontshow{ stopifnot(isTrue(.Last.value)) }

Duncan Murdoch



  I think it helps the documentation to include an example 
comparing a special case computed using a function with a manual 
computation.  However, stopifnot contributes nothing to user 
understanding, so I hide it.  One could also use \dontshow to hide 
entire examples that check trivial details you think would not 
interest users.


  Spencer


Seth Falcon wrote:

Hi,

On Mon, Oct 5, 2009 at 12:01 PM, Blair Christian
blair.christ...@gmail.com wrote:
 

I'm interested in putting some unit tests into an R package I'm
building.  I have seen assorted things such as Runit library, svUnit
library, packages
with 'tests' directories, etc

I grep'd unit test through the writing R extensions manual but 
didn't find

anything.  Are there any suggestions out there?  Currently I have
several (a lot?) classes/methods that I keep tinkering with, and I'd
like to run a script frequently to check that I don't cause any
unforeseen problems.


I've had good experiences using RUnit.  To date, I've mostly used
RUnit by putting tests in inst/unitTests and creating a Makefile there
to run the tests.  You should also be able to use RUnit in a more
interactive fashion inside an interactive R session in which you are
doing development.

The vignette in svUnit has an interesting approach for integrating
unit testing into R CMD check via examples in an Rd file within the
package.

+ seth

  









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


[Rd] str() gives odd looking output on complex vectors that are not purely imaginary (PR#13985)

2009-10-05 Thread richcalaway
Full_Name: Rich Calaway
Version: R 2.9.2
OS: Windows Vista
Submission from: (NULL) (65.47.30.18)


Try this:

x - rnorm(25)
y - rnorm(25)*1i
z - x+y
str(z)
str(y)

When I try this, I see the following:

 str(z)
 cplx [1:25] 0.0102+ 0.9463-1 -1.+ ...
 str(y)
 cplx [1:25] 0+0.0975i 0-1.5060i 0+0.4071i ...

I see this in 2.9.2 and in the alpha build of 2.10.0:
 sessionInfo()
R version 2.9.2 (2009-08-24) 
i386-pc-intel32 
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base 
other attached packages:
[1] Revobase_0.2-1
loaded via a namespace (and not attached):
[1] pkgXMLBuilder_1.0 XML_2.6-0

 sessionInfo()
R version 2.10.0 alpha (2009-10-04 r49926) 
i386-pc-mingw32 

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C  
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

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


[Rd] Characters vs. factors

2009-10-05 Thread hadley wickham
It seems like a recent trend in R has been to make character vectors
and factors almost equivalent (apart from the way that factors always
remember their original range).  There are a few exceptions:

 * summary.character != summary.factor
 * table(x, exclude = NULL) != table(factor(x), exclude=NULL) when x
includes missing values

 * strsplit on a factor

 strsplit(factor(c(a, a b)),  )
Error in strsplit(factor(c(a, a b)),  ) : non-character argument

 * nchar on a factor:

 nchar(factor(c(abc, d, defgh)))
[1] 1 1 1

 * : with two character strings

 a:b
Error in a:b : NA/NaN argument
In addition: Warning messages:
1: NAs introduced by coercion
2: NAs introduced by coercion
 factor(a):factor(b)
[1] a:b
Levels: a:b

Regards,

Hadley

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

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


Re: [Rd] unit testing for R packages?

2009-10-05 Thread Philippe Grosjean

Hi,

I am the writer of svUnit. My initial goal was to build functions on top
of RUnit which is older, and certainly deserves all the credit for core
test unit functions. Unfortunately, the way RUnit is working internally
did not allowed me to build the extensions I needed.

Now, as Seth already told, there are several functions in svUnit that
ease interactive use of the tests in an R session. What he did not told
is that RUnit has some nice code coverage functions that svUnit does not
have.

Thus, not easy to decide... The good news is that both RUnit and svUnit
are almost completely compatible with test unit code, that is, the same
code put in inst/unitTests should run with both packages. So, you could
write your test units, try both approaches in practice, and finally
decide after a little bit of experiment which one you prefer (at least,
read the vignette of each packages).

In case you use Komodo Edit as R code editor, there is a nice GUI
interactive panel to svUnit available (see
http://www.sciviews.org/SciViews-K).

Best,

Philippe Grosjean

Seth Falcon wrote:

Hi,

On Mon, Oct 5, 2009 at 12:01 PM, Blair Christian
blair.christ...@gmail.com wrote:

I'm interested in putting some unit tests into an R package I'm
building.  I have seen assorted things such as Runit library, svUnit
library, packages
with 'tests' directories, etc

I grep'd unit test through the writing R extensions manual but didn't find
anything.  Are there any suggestions out there?  Currently I have
several (a lot?) classes/methods that I keep tinkering with, and I'd
like to run a script frequently to check that I don't cause any
unforeseen problems.


I've had good experiences using RUnit.  To date, I've mostly used
RUnit by putting tests in inst/unitTests and creating a Makefile there
to run the tests.  You should also be able to use RUnit in a more
interactive fashion inside an interactive R session in which you are
doing development.

The vignette in svUnit has an interesting approach for integrating
unit testing into R CMD check via examples in an Rd file within the
package.

+ seth



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


Re: [Rd] unit testing for R packages?

2009-10-05 Thread Peter Cowan
On Mon, Oct 5, 2009 at 5:44 PM, hadley wickham h.wick...@gmail.com wrote:
 Now, as Seth already told, there are several functions in svUnit that
 ease interactive use of the tests in an R session. What he did not told
 is that RUnit has some nice code coverage functions that svUnit does not
 have.

 What are those? I've skimmed through the documentation and couldn't
 see anything?

The R wiki has information about both RUnit and svUnit.  I'm not sure
that it details all of the differences.  I have successfully used the
methodology of the gdata package described there.

http://wiki.r-project.org/rwiki/doku.php?id=developers:runit

Peter



 Hadley

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

 __
 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] unit testing for R packages?

2009-10-05 Thread hadley wickham
On Mon, Oct 5, 2009 at 8:48 PM, Peter Cowan cowan...@gmail.com wrote:
 On Mon, Oct 5, 2009 at 5:44 PM, hadley wickham h.wick...@gmail.com wrote:
 Now, as Seth already told, there are several functions in svUnit that
 ease interactive use of the tests in an R session. What he did not told
 is that RUnit has some nice code coverage functions that svUnit does not
 have.

 What are those? I've skimmed through the documentation and couldn't
 see anything?

 The R wiki has information about both RUnit and svUnit.  I'm not sure
 that it details all of the differences.  I have successfully used the
 methodology of the gdata package described there.

Sorry, I should have been more explicit.  I was interested
particularly in the code coverage functions.

Hadley


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

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


Re: [Rd] Characters vs. factors

2009-10-05 Thread David M Smith
On Mon, Oct 5, 2009 at 4:33 PM, hadley wickham h.wick...@gmail.com wrote:
 It seems like a recent trend in R has been to make character vectors
 and factors almost equivalent (apart from the way that factors always
 remember their original range).  There are a few exceptions:

A related issue is that modeling functions throw a warning when
character objects are used in place of factors:

 shopping - 
 read.csv(http://spreadsheets.google.com/pub?key=tE9pXlYLwTAeiDWxL8h_viAsingle=truegid=0range=A1%3AE37output=csv;,
  as.is=TRUE)
 shopping$seconds - as.numeric(as.difftime(shopping$Total.Time))
 fit - lm(seconds ~ Number.of.Items + Payment - 1, shopping,subset=-8)
Warning message:
In model.matrix.default(mt, mf, contrasts) :
  variable 'Payment' converted to a factor

The warning doesn't affect R's behaviour, of course, but it does make
it difficult to sanction the otherwise sensible advice to R beginners
to read in data files with as.it=TRUE. (The warning leads to
difficult-to-answer questions.) For similar reasons  I deleted the
warning from this post:
http://blog.revolution-computing.com/2009/09/is-the-express-line-really-faster-1.html

In general the trend towards equivalence of factors and character
vectors is welcome, though.

# David

On Mon, Oct 5, 2009 at 4:33 PM, hadley wickham h.wick...@gmail.com wrote:

 It seems like a recent trend in R has been to make character vectors
 and factors almost equivalent (apart from the way that factors always
 remember their original range).  There are a few exceptions:

  * summary.character != summary.factor
  * table(x, exclude = NULL) != table(factor(x), exclude=NULL) when x
 includes missing values

  * strsplit on a factor

  strsplit(factor(c(a, a b)),  )
 Error in strsplit(factor(c(a, a b)),  ) : non-character argument

  * nchar on a factor:

  nchar(factor(c(abc, d, defgh)))
 [1] 1 1 1

  * : with two character strings

  a:b
 Error in a:b : NA/NaN argument
 In addition: Warning messages:
 1: NAs introduced by coercion
 2: NAs introduced by coercion
  factor(a):factor(b)
 [1] a:b
 Levels: a:b

 Regards,

 Hadley

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

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



--
David M Smith da...@revolution-computing.com
Director of Community, REvolution Computing www.revolution-computing.com
Tel: +1 (206) 577-4778 x3203 (San Francisco, USA)

Check out our upcoming events schedule at www.revolution-computing.com/events

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