[R] Bwplot with dendrogram to indicate significant differences

2011-02-10 Thread Michael Hoffman
I would like to make a box plot with a dendogram on top that can be used 
to indicate significant differences (with an asterisk or three at a node 
depending on the p-value). I can supply the adjacency information a 
priori. Is there an easy way to do this? Other ways of presenting the 
same information would be welcome.


I am currently using lattice's bwplot, and would like to continue doing 
so as I have additional code to customize the display (displaying 
individual data points in red or black depending on whether they pass a 
predetermined threshold).


Michael

__
R-help@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.


[R] Getting Stangle to tangle Sexpr expressions

2008-02-26 Thread Michael Hoffman
Is there a way to get Stangle to print out Sexpr expressions as well as 
code chunks?

I am using weaver and when trying to debug Sweave files, it is sometimes 
difficult to figure out where the error is. The errors are hardest to 
find when they are in Sexpr expressions because stepping through the 
output produced by Stangle reveals nothing.

That said, any other suggestions on debugging Sweave would be welcome.

__
R-help@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.


[R] rapply on a data.frame

2008-02-24 Thread Michael Hoffman
Is it possible to get something like rapply for a data.frame? For 
example, if I do this:

  x - list(a=mtcars, b=mtcars)
  str(rapply(x, nrow, classes=data.frame, how=replace))
List of 2
  $ a:List of 11
   ..$ mpg : num [1:32] 21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
   ..$ cyl : num [1:32] 6 6 4 6 8 6 8 4 4 6 ...
   ..$ disp: num [1:32] 160 160 108 258 360 ...
   ..$ hp  : num [1:32] 110 110 93 110 175 105 245 62 95 123 ...
   ..$ drat: num [1:32] 3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...
   ..$ wt  : num [1:32] 2.62 2.88 2.32 3.21 3.44 ...
   ..$ qsec: num [1:32] 16.5 17.0 18.6 19.4 17.0 ...
   ..$ vs  : num [1:32] 0 0 1 1 0 1 0 1 1 1 ...
   ..$ am  : num [1:32] 1 1 1 0 0 0 0 0 0 0 ...
   ..$ gear: num [1:32] 4 4 4 3 3 3 3 4 4 4 ...
   ..$ carb: num [1:32] 4 4 1 1 2 1 4 2 2 4 ...
  $ b:List of 11
   ..$ mpg : num [1:32] 21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
   ..$ cyl : num [1:32] 6 6 4 6 8 6 8 4 4 6 ...
   ..$ disp: num [1:32] 160 160 108 258 360 ...
   ..$ hp  : num [1:32] 110 110 93 110 175 105 245 62 95 123 ...
   ..$ drat: num [1:32] 3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...
   ..$ wt  : num [1:32] 2.62 2.88 2.32 3.21 3.44 ...
   ..$ qsec: num [1:32] 16.5 17.0 18.6 19.4 17.0 ...
   ..$ vs  : num [1:32] 0 0 1 1 0 1 0 1 1 1 ...
   ..$ am  : num [1:32] 1 1 1 0 0 0 0 0 0 0 ...
   ..$ gear: num [1:32] 4 4 4 3 3 3 3 4 4 4 ...
   ..$ carb: num [1:32] 4 4 1 1 2 1 4 2 2 4 ...

I was hoping to get something like list(a=11, b=11). I suspect this is 
because the data.frame is actually implemented as a list.

__
R-help@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.


Re: [R] rapply on a data.frame

2008-02-24 Thread Michael Hoffman
Michael Hoffman wrote:
 Is it possible to get something like rapply for a data.frame?

On second thought, I can do something like this:

happly - function(x, fun) {
   if (class(x) == list) {
 lapply(x, happly, fun)
   } else {
 fun(x)
   }
}

  happly(list(a=list(c=mtcars, d=Titanic), x=mtcars), nrow)
$a
$a$c
[1] 32

$a$d
[1] 4


$x
[1] 32

Better suggestions welcome.

__
R-help@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.


[R] Automatically discovering dependencies in Sweave

2008-02-20 Thread Michael Hoffman
I am using Sweave in a Makefile-managed LaTeX project. I regenerate the 
.tex files automatically when there are changes in the Rnw files, but 
this also needs to be done when files that are sourced using source() 
are changed.

Is there something that can be done using codetools to discover all the 
sourced files?

I suppose one thing I could to would be to make a wrapper for source() 
that would log all of the files accessed. Or maybe even more generally 
for file(), but that would probably produce a lot of things I don't want 
as dependencies.

__
R-help@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.


[R] Automatic traceback

2008-01-16 Thread Michael Hoffman
I would like to have an automatic traceback printed on error. Is there
a way to do this?

options(error=traceback) seems to print the previous error, not the
current error. I'm guessing this is because the traceback is not set
until the error handler is done running.

 options(error=traceback)
 stop(1)
Error: 1
No traceback available
 stop(2)
Error: 2
1: stop(1)
 stop(3)
Error: 3
1: stop(2)

I am using R version 2.6.0 (2007-10-03).
-- 
Michael Hoffman

__
R-help@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.


Re: [R] Automatic traceback

2008-01-16 Thread Michael Hoffman
Prof Brian Ripley wrote:

 On Wed, 16 Jan 2008, Michael Hoffman wrote:

 I would like to have an automatic traceback printed on error. Is there
 a way to do this?

 There is a compact traceback printed automatically in non-interactive use,
 and you can turn that on by the following options

  'showWarnCalls', 'showErrorCalls': a logical. Should warning and
   error messages show a summary of the call stack?  By default
   error calls are shown in non-interactive sessions.

Thanks, that is very helpful. Is there a way to get something slightly
more verbose?
-- 
Michael Hoffman

__
R-help@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.


Re: [R] Java parser for R data file?

2007-12-05 Thread Michael Hoffman
David Coppit wrote:
 Hi everyone,
 
 Has anyone written a parser in Java for either the ASCII or binary format
 produced by save()?

You might want to consider using the hdf5 package to save the array in 
HDF5 format. There are HDF5 libraries for Java as well 
http://hdf.ncsa.uiuc.edu/hdf-java-html/. I have never used them, but 
it works quite well for transferring data between R and Python.

__
R-help@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.


[R] Sweave: Variables in code chunk headers

2007-12-01 Thread Michael Hoffman
I would like to be able to do something like this:

   echo=F,fig=T,width=mywidth=
   ...
   @

with mywidth set in a previous code chunk. Is there a way to do this in 
Sweave?

(Sorry for two questions in a row, I have been saving these up.)
-- 
Michael

__
R-help@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.


Re: [R] Sweave: Variables in code chunk headers

2007-12-01 Thread Michael Hoffman
Dieter Menne wrote:
 Michael Hoffman b3i4old02 at sneakemail.com writes:
 
 I would like to be able to do something like this:

echo=F,fig=T,width=mywidth=
...
@

 with mywidth set in a previous code chunk. Is there a way to do this in 
 Sweave?

 
 Not in the , but you could set a hook for fig:
 
 
From Sweave docs:
 
 If option SweaveHooks is defined as list(fig = foo), and foo is a function,
 then it would be executed before the code in each figure chunk. This is
 especially useful to set defaults for the graphical parameters in a series of
 figure chunks.

Thanks. I guess what I really want to do is switch between one of two 
settings. Only one value can be in the defaults, and I would like some 
way of setting the other value. This might not be easily possible, but I 
thought I would ask.

__
R-help@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.