[Rd] RFC: more generous print.table(*, zero.print = .) behavior

2006-07-06 Thread Martin Maechler
Hmm,
I'm replying once more to myself  (as popular wisdom says, talking to
 oneself is probably a dangerous sign of increasing mental
 disorder ;-()

 MM == Martin Maechler [EMAIL PROTECTED]
 on Tue, 4 Jul 2006 17:40:31 +0200 writes:

 MM == Martin Maechler [EMAIL PROTECTED]
 on Fri, 30 Jun 2006 17:09:32 +0200 writes:

 PD == Peter Dalgaard [EMAIL PROTECTED]
 on 29 Jun 2006 12:18:13 +0200 writes:

PD BXC (Bendix Carstensen) [EMAIL PROTECTED] writes:

BXC The function addmargins() adds margins to a table, but returns a 
matrix.
BXC But even after converted to a table the print.zero=. option of
BXC print.table() does not work:
BXC 
BXC  x - sample( 1:7, 20, replace=T )
BXC  y - sample( 1:7, 20, replace=T )
BXC  tt - table( x, y )
BXC  tx - as.table( addmargins( table( x, y ) ) )
BXC  print( tt, zero.print=. )
BXC y
BXC x   1 2 3 4 5 6 7
BXC 1 1 2 2 . . 1 .
BXC 2 1 . . 1 . . .
BXC 3 . . . . . . 2
BXC 4 1 . . . . 1 .
BXC 5 1 . 1 . . 1 .
BXC 6 . 1 . 1 . . .
BXC 7 . . 1 . 1 1 .
BXC  print( tx, zero.print=. )
BXC y
BXC x  1  2  3  4  5  6  7 Sum
BXC 11  2  2  0  0  1  0   6
BXC 21  0  0  1  0  0  0   2
BXC 30  0  0  0  0  0  2   2
BXC 41  0  0  0  0  1  0   2
BXC 51  0  1  0  0  1  0   3
BXC 60  1  0  1  0  0  0   2
BXC 70  0  1  0  1  1  0   3
BXC Sum  4  3  4  2  1  4  2  20
BXC 
BXC Is this a facility of print.table?
BXC The attributes() of tt and tx have identical stucture. 

PD It appears to be intentional.
PD 
PD print.table has
PD 
PD if (is.integer(x)  zero.print != 0  any(i0 - !ina 
PD x == 0))
PD xx[i0] - sub(0, zero.print, xx[i0])
PD 
PD and of course,
PD 
PD  storage.mode(tx)
PD [1] double
PD  storage.mode(tt)
PD [1] integer
PD 
PD The reason could be that it is not entirely clear what to expect for
PD values that are zero up to round-off.
PD 
PD storage.mode(tx) - integer fixes things up.

MM On the other hand, I'm pretty sure I was the one who added
MM 'zero.print' and I don't oppose at all to change

MM is.integer(x)   to   all(x == round(x))

MM {and then for efficiency swap the *order* of the tests inside that 
if(.)}
MM which I think would be a bit more convenient and still ok (*)
MM here.

MM Martin Maechler, ETH Zurich

MM (*) yes, one could then construct artificial cases where the
MM if(.) test would ``conceptually'' be wrong, but I think that
MM would not matter for all practical cases.

MM In R-devel,  

MM -  addmargins(x, ...) now returns a table when 'x' was one.

MM -  print.table(x, zero.print = ch) now also ``zero-prints'' when
MM 'x' is not integer but numeric with integer values.

I still wonder now about the originaly reason why such a test
should be done at all.  If   'zero.print = ch' is explicitly
specified shouldn't it be used in any case, even in those cases
where a value ``accidentally became 0'' ?

I'm currently tending to think that we should drop that test 
[ 'all(x == round(x))'  which originally was 'is.integer(x)' ]
entirely.

What do others think?

MM Bendix' original example can now be slightly shortened *and*
MM works as desired (in R-devel, aka 2.4.0 -- to-be):

 set.seed(1)
 x - sample( 1:7, 20, replace=TRUE)
 y - sample( 1:7, 20, replace=TRUE)
 tx - addmargins( table(x, y) )
 print(tx, zero.print = .)
MM y
MM x  1  2  3  4  5  6  7 Sum
MM 1.  .  1  .  .  .  .   1
MM 2.  1  .  1  1  .  1   4
MM 3.  2  .  .  .  1  .   3
MM 4.  .  .  .  1  .  .   1
MM 5.  .  1  1  1  .  1   4
MM 6.  .  1  .  .  2  .   3
MM 73  .  1  .  .  .  .   4
MM Sum  3  3  4  2  3  3  2  20
 

MM Hoping, this will be useful..
MM Martin Maechler, ETH Zurich

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

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


[Rd] R installation glitches.

2006-07-06 Thread Bo Peng
Dear list,

I installed R 2.3.1 on a solaris machine. The first time, I used the
wrong option --enable-shlib,  the installation went smoothly (glitch
1), but of course did not generate libR.so. So, I ran ./configure
again with --enable-R-shlib, make and make install went well but still
there was no libR.so generated (glitch 2). Finally, I removed the
build directory and started fresh, and everything went well.

I should have used the correct options, or should have used make
distclean afterwards, but the fact that configure/make did not
complain may be considered as bugs.

Regards,
Bo

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


[Rd] comment causes browser() to exit (PR#9063)

2006-07-06 Thread timh
I'm trying to step through some code using browser(),
executing one line at a time.
Unfortunately, whenever I execute a comment line, the browser exits.

I previously reported a similar problem with blank lines.

These problems are a strong incentive to write poor code 
-- uncommented code with no blank lines to improve readability --
so that I can use browser() without it exiting at inconvenient times.

Additional detail:  
(1) I'm running R inside emacs, with R in one buffer
and a file containing code in another, using a macro to copy and paste
a line at a time from the file to the R buffer.
(2) The browser() call is inside a function.  
Right now the lines I'm sending to the browser are not part of the function,
though usually they are.


--please do not edit the information below--

Version:
 platform = i386-pc-mingw32
 arch = i386
 os = mingw32
 system = i386, mingw32
 status = 
 major = 2
 minor = 3.1
 year = 2006
 month = 06
 day = 01
 svn rev = 38247
 language = R
 version.string = Version 2.3.1 (2006-06-01)

Windows XP Professional (build 2600) Service Pack 2.0

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

Search Path:
 .GlobalEnv, package:methods, package:stats, package:graphics, 
package:grDevices, package:utils, package:datasets, Autoloads, package:base

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