[R] [R-pkgs] new version of package distr available

2004-09-27 Thread Peter Ruckdeschel
We would like to announce the availability on CRAN of a new version (1.4)
of our package distr .
-
Changes from 1.3 to 1.4
-To avoid name collisions with short forms for TRUE and FALSE: classes T
 and F (T- and F-distributions) renamed to Td and Fd
-The package is now loaded as a binary = considerable speed gain
-Using subsititute, the bodies of the r,d,p,q-function-slots
 distributions show the parameter values with which they were 
 generated
-Convolutions and applications of the math group may now be traced in
 r-slot of a distribution object, compare
  r(sin(Norm()) + cos(Unif() * 3 + 2))
-Parameters of a distribution (mean, sd, etc) are now tested on length 1
  *we see the objects as implementations of univariate distributions, so
   vectors  make  no sense here; rather one could gather several objects 
   with possibly different parameters to a vector of distributions.
   Of course, the original R-functions rnorm etc remain unchanged and
   still allow for vector-valued parameters.
  *
-Classes Parameter , Distribution , UnivariateDistribution are no
 longer VIRTUAL
-AbscontParameter and DiscreteParameter are replaced by Parameter
-Type of slots d,p,q  and param is changed to OptionalFunction and
 OptionalParameter respectively

-
Short Description of distr:
distr is to provide a conceptual treatment of random variables
(r.v.'s) by means of S4--classes. A virtual mother class Distribution 
is introduced.
All distributions of the base package are implemented as subclasses of
either AbscontDistribution or DiscreteDistribution.

Using these classes, we also provide (default) methods to automatically
generate the image distributions under unary mathematical operations as
well as a general convolution algorithm.

Additionally, we also provide classes for a standardized treatment of
simulations (also under contaminations) and evaluations of statistical
procedures on such simulations.
-


DESCRIPTION:

Package: distr
Version: 1.4
Date: 2004/09/23
Title: distr
Authors: Peter Ruckdeschel [EMAIL PROTECTED],
Matthias Kohl [EMAIL PROTECTED],
Thomas Stabla [EMAIL PROTECTED],
Florian Camphausen [EMAIL PROTECTED]
Maintainer: Peter Ruckdeschel [EMAIL PROTECTED]
Description: S4 Classes for Distributions
Depends: R (= 1.9.0),  (versions for =1.8.x, on URL cited below),
setRNG (= 2004.3-1)
License: GPL version 2 or later
URL: http://www.uni-bayreuth.de/departments/math/org/mathe7/DISTR/

Reference:  
http://www.uni-bayreuth.de/departments/math/org/mathe7/DISTR/distr.pdf

We look forward to receiving questions, comments and suggestions

Peter Ruckdeschel
Matthias Kohl
Thomas Stabla
Florian Camphausen

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Re: cannot assign dimnames

2004-09-27 Thread Gabor Grothendieck
Dan Bebber danbebber at forestecology.co.uk writes:


: Please ignore my earlier message on this topic. I was under the mistaken
: impression that dimnames() named the dimensions themselves, rather than the
: indices within the dimensions.

What you are referring to is done in R by referring to the names of
the dimnames, as opposed to the dimnames, themselves.  Here is an
example:

R mat - matrix(1:12,4, dimnames = list(letters[1:4],LETTERS[1:3]))
R names(dimnames(mat)) - c(FirstDim, SecondDim)
R mat
SecondDim
FirstDim A B  C
   a 1 5  9
   b 2 6 10
   c 3 7 11
   d 4 8 12

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Re: cannot assign dimnames

2004-09-27 Thread Gabor Grothendieck
Gabor Grothendieck ggrothendieck at myway.com writes:

: 
: Dan Bebber danbebber at forestecology.co.uk writes:
: 
: : Please ignore my earlier message on this topic. I was under the mistaken
: : impression that dimnames() named the dimensions themselves, rather than the
: : indices within the dimensions.
: 
: What you are referring to is done in R by referring to the names of
: the dimnames, as opposed to the dimnames, themselves.  Here is an
: example:
: 
: R mat - matrix(1:12,4, dimnames = list(letters[1:4],LETTERS[1:3]))
: R names(dimnames(mat)) - c(FirstDim, SecondDim)
: R mat
: SecondDim
: FirstDim A B  C
:a 1 5  9
:b 2 6 10
:c 3 7 11
:d 4 8 12

Perhaps I should have also mentioned that the above could be done
in a single line like this:

R mat - matrix(1:12,4, dimnames = list(FirstDim = letters[1:4], SecondDim = 
LETTERS[1:3]))
R mat
SecondDim
FirstDim A B  C
   a 1 5  9
   b 2 6 10
   c 3 7 11
   d 4 8 12

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Re: cannot assign dimnames

2004-09-27 Thread Peter Dalgaard
Dan Bebber [EMAIL PROTECTED] writes:

 Dear list,
 
 Please ignore my earlier message on this topic. I was under the mistaken
 impression that dimnames() named the dimensions themselves, rather than the
 indices within the dimensions.

The dimnames list can be named though:

 matrix(1:4,2,dimnames=list(foo=1:2,bar=c(10,20)))
   bar
foo 10 20
  1  1  3
  2  2  4


-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Looking for .Call functions

2004-09-27 Thread Nathaniel B. Derby
Hi,
In my ongoing quest to track down the source of an error (see message [R] optim error in 
arima above), I find in the cource code for arima0 the following:
arma0f - function(p) {
par - as.double(fixed)
par[mask] - p
.Call(arma0fa, G, par, PACKAGE = stats)
}
I would like to know what the function arma0f does.  Does the above mean that there is a 
function called arma0fa somewhere in R?  Where is it?  I couldn't find anything in 
Rinternals.h.
Thanks,
Nate
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] multinom object :way of plotting??

2004-09-27 Thread John Fox
Dear Camille,

You might be interested in a paper (available at
http://socserv.socsci.mcmaster.ca/jfox/logit-effect-displays.pdf) that
Bob Andersen and I wrote on this topic. The paper deals with graphing
multinomial-logit and proportional-odds models.

Regards,
 John

On 27 Sep 2004 18:16:53 +0100
 Camille Szmaragd [EMAIL PROTECTED] wrote:
 Dear all,
 
 I'm fitting a multinom function to my dataset
 (multinom(outcome~age+K+D)) and I need to present my results on a
 poster. Does someone know a nice way of doing that? I think I saw in
 an archive that you cannot plot a multinom.object, is it true?
 
 Thank you by advance for your help,
 
 Cheers
 
 Camille
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Looking for .Call functions

2004-09-27 Thread Douglas Bates
Nathaniel B. Derby wrote:
Hi,
In my ongoing quest to track down the source of an error (see message 
[R] optim error in arima above), I find in the cource code for arima0 
the following:

arma0f - function(p) {
par - as.double(fixed)
par[mask] - p
.Call(arma0fa, G, par, PACKAGE = stats)
}
I would like to know what the function arma0f does.  Does the above 
mean that there is a function called arma0fa somewhere in R?  Where is 
it?  I couldn't find anything in Rinternals.h.
It means that in one of the .c source files in 
$RSRC/src/library/stats/src there will be a C function declared as

SEXP arma0fa(SEXP, SEXP);
(In fact it is declared in ts.h and defined in pacf.c in that directory)
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Gridbase basic question

2004-09-27 Thread Paul Murrell
Hi
Sean Davis wrote:
All,
I have a simple plot(x,y) and I would like to then insert rectangles of  
some length (in native coordinates) and height fixed to 0.5 in native  
coordinates.  I can't quite get the code right to do this.  Can anyone  
give me a quick example of how to do this?  I looked the gridBase index  
and the tutorial (from R-news?) but just haven't gotten it down yet.

  plot(1:10,1:10)
  par(new=T);vps - baseViewports()
  pushViewport(vps$inner,vps$figure,vps$plot)
viewport[GRID.VP.28]

At this point you are within a viewport which has x- and y-scales 
corresponding to the plot(1:10, 1:10).


  pushViewport(viewport(x=unit(1,native),y=unit(2,native)))
viewport[GRID.VP.29]

You have just created a new viewport at location (1, 2) in the plot, but 
 the scales on this new viewport are the default (0, 1).  i.e., you are 
now in a completely different coordinate system.  Also, this new 
viewport is as wide and as high as the plot region -- for example, it 
extends well beyong the left edge of the window/page.


grid.rect(height=unit(0.5,native),width=unit(1.5,native),just='botto 
m')

This draws a rectangle half as high as the current viewport and 1.5 
times as wide (the native scale in the current viewport is (0, 1) in 
both dimensions).  Importantly, the native coordinate systems you are 
referring to no longer correspond to the scales on the plot.


This draws a very large rectangle going from 2 to 7 (y) and to 8 (x).

Three things:
(i) If drawing rectangles relative to the current native (or user) 
coordinates is all you want to do then you could just use rect() and 
ignore gridBase altogether.  For example, ...

x - sample(1:10, 10)
y - 1:10
w - runif(10)
h - 0.5
plot(1:10,1:10)
rect(x - w/2, y - h/2, x + w/2, y + h/2)
(ii) Using grid and gridBase, the above example becomes ...
plot(1:10,1:10)
par(new=T);vps - baseViewports()
pushViewport(vps$inner,vps$figure,vps$plot)
grid.rect(x=x, y=y, width=w, height=h, default.units=native)
popViewport(3)
... but as mentioned, this is like using a sledge hammer to kill a cat 
or whatever the expression is.

(iii) There would be justification in using grid and gridBase if you 
want to draw more than just a rectangle, especially if you want to use 
coordinates other than native.  Here's a trivial example (adds fixed 
size whiskers to the corners of the rectangles) ...

plot(1:10,1:10)
par(new=T);vps - baseViewports()
pushViewport(vps$inner,vps$figure,vps$plot)
for (i in 1:10) {
  pushViewport(viewport(x=x[i], y=y[i], width=w[i], height=h,
default.units=native))
  grid.rect()
  grid.segments(0, 0, unit(-1, mm), unit(-1, mm))
  grid.segments(0, 1, unit(-1, mm),
unit(1, npc) + unit(1, mm))
  grid.segments(1, 1,
unit(1, npc) + unit(1, mm),
unit(1, npc) + unit(1, mm))
  grid.segments(1, 0,
unit(1, npc) + unit(1, mm),
unit(-1, mm))
  popViewport()
}
... (but pushing a viewport per data point like this is a LOT slower).
Hope that helps
Paul
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] passing formula arg to mgcv::gam

2004-09-27 Thread Vadim Ogranovich
Hi,

I have a function, callGam, that fits a gam model to a subset of a dataframe. The 
argument to callGam is a formula, the subset is determined inside the function itself. 
My naïve approach generates and error, see below. I guess this is because 'idx' is 
loocked up in the environment of 'formula', but I am too ignorant about environments 
to be able to tell for sure. Could someone please suggest a way around?

Thanks,
Vadim

 library(mgcv)
 
 callGam - function(formula) {
+   idx - seq(10)
+   gam(formula, data=data.frame(x=rnorm(100), y=rnorm(100)), subset=idx)
+ }
 
 gam.fit - callGam(y ~ x)
Error in eval(expr, envir, enclos) : Object idx not found


__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] passing formula arg to mgcv::gam

2004-09-27 Thread Vadim Ogranovich
This is a self-response :-).

It was indeed a problem with environments. One way to get around is to reset the 
environment, e.g. inside callGam do
formula - as.formula(unclass(formula)) 


Not too aesthetic, but works. Is there a less kludgy way to do this?

BTW, forgot to mention. This is R-1.9.1 on RH-7.3.

Thanks,
Vadim

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Vadim 
 Ogranovich
 Sent: Monday, September 27, 2004 3:24 PM
 To: [EMAIL PROTECTED]
 Subject: [R] passing formula arg to mgcv::gam 
 
 Hi,
 
 I have a function, callGam, that fits a gam model to a subset 
 of a dataframe. The argument to callGam is a formula, the 
 subset is determined inside the function itself. My naïve 
 approach generates and error, see below. I guess this is 
 because 'idx' is loocked up in the environment of 'formula', 
 but I am too ignorant about environments to be able to tell 
 for sure. Could someone please suggest a way around?
 
 Thanks,
 Vadim
 
  library(mgcv)
  
  callGam - function(formula) {
 +   idx - seq(10)
 +   gam(formula, data=data.frame(x=rnorm(100), y=rnorm(100)), 
 + subset=idx) }
  
  gam.fit - callGam(y ~ x)
 Error in eval(expr, envir, enclos) : Object idx not found
 
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html


__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] sapply behavior

2004-09-27 Thread Elizabeth Purdom
Hi,
I use sapply very frequently, but I have recently noticed a behavior of 
sapply which I don't understand and have never seen before. Basically, 
sapply returns what looks like a matrix,  says it a matrix, and appears to 
let me do matrix things (like transpose). But it is also a list and behaves 
like a list when I subset it, not a vector (so I can't sort a row for 
instance). I don't know where this is coming from so as to avoid it, nor 
how to handle the beast that sapply is returning. I double checked my old 
version of R and apparently this same thing happens in 1.8.0, though I 
never experienced it. I had a hard time reproducing it, and I don't know 
what's setting it off, but the code below seems to do it for me. (I'm using 
R on Windows XP, either 1.8.0 or 1.9.1)

Thanks for any help,
Elizabeth Purdom
 temp2-matrix(sample(1:6,6,replace=F),byrow=F,nrow=6,ncol=4)
 colnames(temp2)-paste(A,as.character(1:4),sep=)
 temp2-as.data.frame(temp2)
 
newtemp2-sapply((1:6),function(x){xmat-temp2[temp2[,1]==x,,drop=F];return(xmat[1,])})
 print(newtemp2) #looks like matrix
   [,1] [,2] [,3] [,4] [,5] [,6]
A1 123456
A2 123456
A3 123456
A4 123456
 is.matrix(newtemp2) #says it's matrix
[1] TRUE
 class(newtemp2)
[1] matrix
 is.list(newtemp2) #but also list
[1] TRUE
 newtemp2[,1] #can't subset and get a vector back; same thing happens for 
rows.
$A1
[1] 1

$A2
[1] 1
$A3
[1] 1
$A4
[1] 1
#other things about it:
 names(newtemp2)
NULL
 dimnames(newtemp2)
[[1]]
[1] A1 A2 A3 A4
[[2]]
NULL
 dim(newtemp2)
[1] 4 6
 length(newtemp2)
[1] 24
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] using tcltk in R under ESS/XEmacs on Windows

2004-09-27 Thread Shawn Boles
Tony:

It is indeed most amazing that you have been able to get ESS/Emacs
running under Windows.  And much appreciated by those of us who have to
moil around 
with MessySoft machines.

Thanks to all who have contributed to the effort.

Cheers,

Shawn Boles




-Original Message-
From: A.J. Rossini [mailto:[EMAIL PROTECTED] 
Sent: Saturday, September 25, 2004 8:04 PM
To: Liaw, Andy
Cc: R-Help; [EMAIL PROTECTED]; ESS (Help list)
Subject: Re: [R] using tcltk in R under ESS/XEmacs on Windows

It most likely is Windows specific.  It's most amazing that we
actually have ESS/(X)Emacs working under windows in the first place.

Unfortunately, I'm in transit for the next few weeks, but I'll
probably have a windows machine on my desk sometime after that.  Argh.

best,
-tony


On Fri, 24 Sep 2004 17:48:18 -0400, Liaw, Andy [EMAIL PROTECTED]
wrote:
  From: Marc Schwartz
 
  On Fri, 2004-09-24 at 15:02, Liaw, Andy wrote:
   Sorry for the cross-post.  Not sure where the problem is...
  
   A while back I posted an R function to R-help:
  
   cd - function (dir = tclvalue(tkchooseDirectory()),
  saveOld = FALSE,
   loadNew = TRUE) {
   stopifnot(require(tcltk))
   if (saveOld)
   save.image(compress = TRUE)
   setwd(dir)
   rm(list = ls(all = TRUE, envir = .GlobalEnv), envir =
  .GlobalEnv)
   if (loadNew  file.exists(.RData)) {
   loaded - load(.RData, envir = .GlobalEnv)
   return(invisible(loaded))
   }
  
   where the default value for the `dir' argument is to run
  the tcltk directory
   chooser and get the directory name chosen.  (Thanks to
  Prof. John Fox for
   the tcltk part!!)  While this function works fine under
  Rgui on Windows, it
   doesn't work when running R within ESS (5.2.3) and XEmacs
  (21.4.13).  The
   directory chooser never shows up, and dir just gets the
  empty string.  Does
   anyone have any idea what could be the problem?  I'd very
  much appreciate
   any pointers.
  
   Best,
   Andy
 
  Andy,
 
  This works under FC2 using ESS 5.2.3 with XEmacs version 21.4.15, so
  presumably there is something specific to the Windows
implementation?
 
 Given Prof. Fox's follow-up and your obvservation, I guess the problem
_is_
 Windows-specific. 8-(
 
  Also, two things:
 
  1. You are missing a closing brace above, which I presume may be a
  simple copy and paste issue.
 
 Yes.  My apologies.
 
  2. If you successfully change the directory, the cd()
  function itself is
  deleted from the global environment via your rm(...), as you
currently
  have it implemented. I am not sure if this is intentional or not.
 
 Well, sort of.  I've placed it in a small package along with other
handy
 stuff, so that won't be a problem.
 
 Best,
 Andy
 
 
 
  HTH,
 
  Marc
 
 
 
 
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
 



-- 
A.J. Rossini
[EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] sapply behavior

2004-09-27 Thread Liaw, Andy
The problem is that temp2 is a data frame, and the function you are
sapply()ing to returns a row from a data frame.  A data frame is really a
list, with each variable corresponding to a component.  If you extract a row
of a data frame, you get another data frame, not a vector, even if all
variables are the same type.  sapply() can really `simplify' the right way
if it's given a vector (or matrix).  Consider:

 str(temp2)
`data.frame':   6 obs. of  4 variables:
 $ A1: int  5 2 4 6 1 3
 $ A2: int  5 2 4 6 1 3
 $ A3: int  5 2 4 6 1 3
 $ A4: int  5 2 4 6 1 3
 temp2 - as.matrix(temp2)
 str(temp2)
 int [1:6, 1:4] 5 2 4 6 1 3 5 2 4 6 ...
 - attr(*, dimnames)=List of 2
  ..$ : chr [1:6] 1 2 3 4 ...
  ..$ : chr [1:4] A1 A2 A3 A4
 str(sapply(1:6,function(x){xmat-temp2[temp2[,1]==x,,drop=F]; xmat[1,]}))
 int [1:4, 1:6] 1 1 1 1 2 2 2 2 3 3 ...
 - attr(*, dimnames)=List of 2
  ..$ : chr [1:4] A1 A2 A3 A4
  ..$ : NULL

(The is.matrix() function probably just check whether the dim attribute is a
vector of length 2, and not a data frame (as it says in ?is.matrix).  The
newtemp2 object you get is a list with 24 components, each component is a
vector of one integer, and has a dim attribute of c(4, 6).  Not what I would
call a matrix.)

HTH,
Andy


 From: Elizabeth Purdom
 
 Hi,
 
 I use sapply very frequently, but I have recently noticed a 
 behavior of 
 sapply which I don't understand and have never seen before. 
 Basically, 
 sapply returns what looks like a matrix,  says it a matrix, 
 and appears to 
 let me do matrix things (like transpose). But it is also a 
 list and behaves 
 like a list when I subset it, not a vector (so I can't sort a row for 
 instance). I don't know where this is coming from so as to 
 avoid it, nor 
 how to handle the beast that sapply is returning. I double 
 checked my old 
 version of R and apparently this same thing happens in 1.8.0, 
 though I 
 never experienced it. I had a hard time reproducing it, and I 
 don't know 
 what's setting it off, but the code below seems to do it for 
 me. (I'm using 
 R on Windows XP, either 1.8.0 or 1.9.1)
 
 Thanks for any help,
 Elizabeth Purdom
 
 
   temp2-matrix(sample(1:6,6,replace=F),byrow=F,nrow=6,ncol=4)
   colnames(temp2)-paste(A,as.character(1:4),sep=)
   temp2-as.data.frame(temp2)
   
 newtemp2-sapply((1:6),function(x){xmat-temp2[temp2[,1]==x,,d
 rop=F];return(xmat[1,])})
   print(newtemp2) #looks like matrix
 [,1] [,2] [,3] [,4] [,5] [,6]
 A1 123456
 A2 123456
 A3 123456
 A4 123456
   is.matrix(newtemp2) #says it's matrix
 [1] TRUE
   class(newtemp2)
 [1] matrix
   is.list(newtemp2) #but also list
 [1] TRUE
   newtemp2[,1] #can't subset and get a vector back; same 
 thing happens for 
 rows.
 $A1
 [1] 1
 
 $A2
 [1] 1
 
 $A3
 [1] 1
 
 $A4
 [1] 1
 #other things about it:
   names(newtemp2)
 NULL
   dimnames(newtemp2)
 [[1]]
 [1] A1 A2 A3 A4
 
 [[2]]
 NULL
   dim(newtemp2)
 [1] 4 6
   length(newtemp2)
 [1] 24
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 


__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] sapply behavior

2004-09-27 Thread Douglas Bates
Elizabeth Purdom wrote:
I use sapply very frequently, but I have recently noticed a behavior of 
sapply which I don't understand and have never seen before. Basically, 
sapply returns what looks like a matrix,  says it a matrix, and appears 
to let me do matrix things (like transpose). But it is also a list and 
behaves like a list when I subset it, not a vector (so I can't sort a 
row for instance). I don't know where this is coming from so as to avoid 
it, nor how to handle the beast that sapply is returning. I double 
checked my old version of R and apparently this same thing happens in 
1.8.0, though I never experienced it. I had a hard time reproducing it, 
and I don't know what's setting it off, but the code below seems to do 
it for me. (I'm using R on Windows XP, either 1.8.0 or 1.9.1)

Thanks for any help,
Elizabeth Purdom
  temp2-matrix(sample(1:6,6,replace=F),byrow=F,nrow=6,ncol=4)
  colnames(temp2)-paste(A,as.character(1:4),sep=)
  temp2-as.data.frame(temp2)
It is this coercion to the data frame that is injecting a list-like 
property into the result.  Try your script without that line and it will 
work as you expect.

  newtemp2-sapply((1:6),function(x){xmat-temp2[temp2[,1]==x,,drop=F];return(xmat[1,])}) 
  print(newtemp2) #looks like matrix
   [,1] [,2] [,3] [,4] [,5] [,6]
A1 123456
A2 123456
A3 123456
A4 123456
The best thing to do in a situation like this is to use the str function 
to see the details of the structure of the object.

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] sapply behavior

2004-09-27 Thread Gabor Grothendieck
Elizabeth Purdom epurdom at stanford.edu writes:

: 
: Hi,
: 
: I use sapply very frequently, but I have recently noticed a behavior of 
: sapply which I don't understand and have never seen before. Basically, 
: sapply returns what looks like a matrix,  says it a matrix, and appears to 
: let me do matrix things (like transpose). But it is also a list and behaves 
: like a list when I subset it, not a vector (so I can't sort a row for 
: instance). I don't know where this is coming from so as to avoid it, nor 
: how to handle the beast that sapply is returning. I double checked my old 
: version of R and apparently this same thing happens in 1.8.0, though I 
: never experienced it. I had a hard time reproducing it, and I don't know 
: what's setting it off, but the code below seems to do it for me. (I'm using 
: R on Windows XP, either 1.8.0 or 1.9.1)
: 
: Thanks for any help,
: Elizabeth Purdom
: 
: 
:   temp2-matrix(sample(1:6,6,replace=F),byrow=F,nrow=6,ncol=4)
:   colnames(temp2)-paste(A,as.character(1:4),sep=)
:   temp2-as.data.frame(temp2)
:   
: newtemp2-sapply((1:6),function(x){xmat-temp2[temp2[,1]==x,,drop=F];return
(xmat[1,])})
:   print(newtemp2) #looks like matrix
: [,1] [,2] [,3] [,4] [,5] [,6]
: A1 123456
: A2 123456
: A3 123456
: A4 123456
:   is.matrix(newtemp2) #says it's matrix
: [1] TRUE
:   class(newtemp2)
: [1] matrix
:   is.list(newtemp2) #but also list
: [1] TRUE
:   newtemp2[,1] #can't subset and get a vector back; same thing happens for 
: rows.
: $A1
: [1] 1
: 
: $A2
: [1] 1
: 
: $A3
: [1] 1
: 
: $A4
: [1] 1
: #other things about it:
:   names(newtemp2)
: NULL
:   dimnames(newtemp2)
: [[1]]
: [1] A1 A2 A3 A4
: 
: [[2]]
: NULL
:   dim(newtemp2)
: [1] 4 6
:   length(newtemp2)
: [1] 24


The problem is that your function is returning a one row data frame
and when sapply tries to simplify the resulting list of 6 data frames 
that gives a list with dimensions rather what you were expecting
which is a vector with dimensions.

Let us call the original anonymous function in your post (i.e. the one
passed to sapply there), f.  We can modify it to produce f2 which is like
f except that we wrap the return expression in c() to turn it into a
vector:

  f2 - function(x){xmat-temp2[temp2[,1]==x,,drop=F];return(c(xmat[1,]))}
  sapply(1:6, f2)

If you really do want to return a one row data frame then
use rbind to bind the data frames together rather than sapply:

   do.call(rbind, lapply(1:6, f))

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] passing formula arg to mgcv::gam

2004-09-27 Thread Gabor Grothendieck

How about

   environment(formula) - environment()


Vadim Ogranovich vograno at evafunds.com writes:

: 
: This is a self-response .
: 
: It was indeed a problem with environments. One way to get around is 
to reset the environment, e.g. inside
: callGam do
: formula - as.formula(unclass(formula)) 
: 
: Not too aesthetic, but works. Is there a less kludgy way to do this?
: 
: BTW, forgot to mention. This is R-1.9.1 on RH-7.3.
: 
: Thanks,
: Vadim
: 
:  -Original Message-
:  From: r-help-bounces at stat.math.ethz.ch 
:  [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Vadim 
:  Ogranovich
:  Sent: Monday, September 27, 2004 3:24 PM
:  To: r-help at stat.math.ethz.ch
:  Subject: [R] passing formula arg to mgcv::gam 
:  
:  Hi,
:  
:  I have a function, callGam, that fits a gam model to a subset 
:  of a dataframe. The argument to callGam is a formula, the 
:  subset is determined inside the function itself. My nave 
:  approach generates and error, see below. I guess this is 
:  because 'idx' is loocked up in the environment of 'formula', 
:  but I am too ignorant about environments to be able to tell 
:  for sure. Could someone please suggest a way around?
:  
:  Thanks,
:  Vadim
:  
:   library(mgcv)
:   
:   callGam - function(formula) {
:  +   idx - seq(10)
:  +   gam(formula, data=data.frame(x=rnorm(100), y=rnorm(100)), 
:  + subset=idx) }
:   
:   gam.fit - callGam(y ~ x)
:  Error in eval(expr, envir, enclos) : Object idx not found

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] smoothing noisy data with a twist

2004-09-27 Thread Matt Gibbs
Hi,
I have a set of observations (x,y), derived from a previous estimation. 
For each observation I also have an estimated variance s(y) derived from 
the first stage.

The problem is that I need to smooth the data (x,y) while taking into 
account the fact that the y's have been estimated at a previous stage 
and thus already come with a variance. So, if I smooth the data I 
somehow need to take into account *two errors*, one from the smoothing 
and the other from the already noisy data that I start off with.

Does anyone have any idea how to do this?
thanks, matt.
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] private on site R training solicited

2004-09-27 Thread Vadim Ogranovich
Hi,
 
R is catching up even with the hardest Excelists. At our company we are
exploring the possibility of having some of the RD staff introduced to
R during a short on site class in San-Francisco, California. The number
of people in the group will be about 5 - 7. If you are interested in
delivering the class please e-mail me the info for consideration.
 
Thanks,
Vadim Ogranovich
Evnine  Vaughan Assoc.

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] smoothing noisy data with a twist

2004-09-27 Thread Liaw, Andy
One thing I would try is to supply 1/sd(y) as the weights to smoothers that
can accept them; e.g., loess().

Andy

 From: Matt Gibbs
 
 Hi,
 
 I have a set of observations (x,y), derived from a previous 
 estimation. 
 For each observation I also have an estimated variance s(y) 
 derived from 
 the first stage.
 
 The problem is that I need to smooth the data (x,y) while taking into 
 account the fact that the y's have been estimated at a previous stage 
 and thus already come with a variance. So, if I smooth the data I 
 somehow need to take into account *two errors*, one from the 
 smoothing 
 and the other from the already noisy data that I start off with.
 
 Does anyone have any idea how to do this?
 
 thanks, matt.
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 


__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Course***Splus/R: Complementing and Extending Statistical Computing for SAS Users

2004-09-27 Thread elvis
XLSolutions Corporation (www.xlsolutions-corp.com) is pleased to 
announce a two-day course, Splus/R: Complementing and Extending
Statistical Computing for SAS Users www.xlsolutions-corp.com/Rsas.htm

Dates/City: October 28-29  Raleigh, NC
 November 4-5  Boston, MA


This course is designed for SAS users who want to learn how to
complement 
and extend statistical computing with Splus and/or R system. 
The course will give participants a strong foundation for becoming 
a versatile programmer. 

Course Description:

This two-day course focuses on a broad spectrum of topics:

*Data manipulations in S and R (data frame and matrix operations) 
and SAS (the data step) -- issues of importing, formatting,
transformation,
cataloging, exporting 
*Splus/R Functions vs macros in SAS for programming repetitive
processes. 
*The iteration models of SAS vs whole-object modeling 
*Specific comparison: linear modeling, glms, gees, lmes.
*etc

Complete course description: www.xlsolutions-corp.com/Rsas.htm


Earlybird ends October 10th. 

Ask for group discount!

Registration: 

Email Sue Turner: [EMAIL PROTECTED]
Phone: 206-686-1578




Share Your Thoughts:

Are there any additional topics you would like for this course to
address?
Would you like for this course to be offered in another city? 

Please let us know by contributing to our recommendation list: 
[EMAIL PROTECTED]


Elvis Miller, PhD
Manager Training and Technical Support
North American Division
XLSolutions Corporation
Email: [EMAIL PROTECTED]
Phone: 206-686-1578
Web: www.xlsolutions-corp.com

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] An index of all possible combinations of variables in a data fram e

2004-09-27 Thread Alan Simpson
Hello list
 
Does anybody know of any way to create an index of all the possible
combinations of variables (factors) in a data frame? ie for 3 factors A, B 
C we have 
 
A
B
C
AB
AC
BC
ABC
 
which equates to columns 1, 2, 3, 1:2, (1,3), 2:3 and 1:3.
 
I realise that a function like model.matrix does this, but how to get the
seqence of the index?
 
Any help would be greatly appreciated.
 
Regards
 
Alan Simpson
Roberts Research Group
 

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] KS test

2004-09-27 Thread Vaidotas Zemlys
Hi,


 I have a sample, and I want to test if its distribution is normal. So I
 would like to perform a one sample KS test but I cannot find the y
 argument representing  the character string naming a distribution
 function according to the ?ks.test help page.
 It is impossible forme to have a list of these character strings naming a
 distribution function.
 
 I think it is pnorm for a normal distribution, bu I would like to be sure...
 

From examples in ks.test manual:
# Does x come from a shifted gamma distribution with shape 3 and scale 2?
 ks.test(x+2, pgamma, 3, 2) # two-sided
 ks.test(x+2, pgamma, 3, 2, alternative = gr)

So you can be sure, that it will be pnorm for normal distribution.

Vaidotas

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Re: tseries Package for R

2004-09-27 Thread Adrian Trapletti
Wizon wrote:
I am using Mac OSX.  I am first starting to use R and have not 
installed any packages yet.  I searched through the CRAN site for a 
Mac OSX version, but did not find one.  I downloaded the tar.gz 
package.  Will this work on the Mac?  Is there a way to get a package 
that I don't have to compile?  Thanks in advance for your help.

Adam

Dear Adam
Sorry, I can't help you since I never used R under MacOS. However, I cc 
your mail to R-help. Maybe you get some feedback from there.

Best regards
Adrian
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] (no subject)

2004-09-27 Thread YiYao_Jiang
Hello everybody:

I can't setup a library for some functions.
Can anybody kindly give me an example about setup a library. From build a package to 
library.

Thanks!


Best Regards

YiYao Jiang

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[Hmisc] proposal for change in latex.summary.formula.reverse (was: [R] Sweave: superfluous newline (`\\') in tex file)

2004-09-27 Thread Patrick Drechsler
Hi,

well, it wasn't a Sweave problem after all. Seems to have
something to do with the function
`latex.summary.formula.reverse' in the package Hmisc.

Following change seems to help (at least for my purpose):

--8schnipp-8---
*** /usr/local/lib/R/library/Hmisc/R/Hmisc  2004-09-28 07:37:26.0 +0200
--- /usr/local/lib/R/library/Hmisc/R/Hmisc.original 2004-09-28 07:38:28.0 
+0200
***
*** 16156,16162 
'Numbers after percents are frequencies.',
sep=\n)
if(length(testUsed))
! legend -paste(legend,'\n\n',
 if(length(testUsed)==1)'Test used:' else 'Tests used:',
 if(length(testUsed)==1) paste(testUsed,'test') else
 paste(paste('$^{',1:length(testUsed),'}$',testUsed,
--- 16156,16162 
'Numbers after percents are frequencies.',
sep=\n)
if(length(testUsed))
! legend -paste(legend,'\n','\n\n',
 if(length(testUsed)==1)'Test used:' else 'Tests used:',
 if(length(testUsed)==1) paste(testUsed,'test') else
 paste(paste('$^{',1:length(testUsed),'}$',testUsed,
--8schnapp-8---

But since my knowledge of R is rather small I have no idea if
these has any other drawbacks.

Any comments?

How would I go about changing this for my setup only? Is
renaming Hmisc to something like pdHmisc ok?

Patrick
-- 
Do you remember when you only had to pay
for windows when *you* broke them?

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html