Re: [R] prediction with nnet function for regression in R

2005-10-04 Thread Prof Brian Ripley
On Wed, 5 Oct 2005 [EMAIL PROTECTED] wrote:

>
> Hi,
> Good Day Everybody.
> Can anybody help me
> I am working with R ...and i am using nnet() function for regression, but
> after trained model, i m getting all predictions as 0.99 or 1.,
> why is so, i dont understand?

As a guess, you failed to specify linear output units.  But as you have 
not shown us what you did do, we can only guess.

> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

please do.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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-help@stat.math.ethz.ch 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] prediction with nnet function for regression in R

2005-10-04 Thread uttam . phulwale

Hi,
Good Day Everybody.
Can anybody help me
I am working with R ...and i am using nnet() function for regression, but 
after trained model, i m getting all predictions as 0.99 or 1., 
why is so, i dont understand?

can anybody suggest something...???

Thanks & Regards,

Uttam Phulwale
Tata Consultancy Services Limited
Mailto: [EMAIL PROTECTED]
Website: http://www.tcs.com

Notice: The information contained in this e-mail message and/or attachments to 
it may contain confidential or privileged information.   If you are not the 
intended recipient, any dissemination, use, review, distribution, printing or 
copying of the information contained in this e-mail message and/or attachments 
to it are strictly prohibited.   If you have received this communication in 
error, please notify us by reply e-mail or telephone and immediately and 
permanently delete the message and any attachments.  Thank you
[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] sampling vectors

2005-10-04 Thread ecatchpole
Eric,

Following on from Ravi's suggestion, try

ex <- c(30,13,9,8,7,7,7,6,6,5,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1)
tot <- sum(ex)
N <- length(ex)
rmultinom(n=3, size=tot, prob=rep(1,N))

Ted.

On 05/10/05 06:07,  Nordlund, Dan wrote,:
> Eric,
> 
> 
>>-Original Message-
>>From: [EMAIL PROTECTED] [mailto:r-help-
>>[EMAIL PROTECTED] On Behalf Of Eric Pante
>>Sent: Tuesday, October 04, 2005 8:47 AM
>>To: Daniel Nordlund
>>Cc: r-help@stat.math.ethz.ch
>>Subject: Re: [R] sampling vectors
>>
>>Hi Dan,
>>
>>I just tried your code with long vectors, and the sampling stops to be
>>random. Do you see any reason why this is ?
>>
>>examples:
>>
>>ex = c(30,13,9,8,7,7,7,6,6,5,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1)
>>
>> > vectorSample(ex)
>>  [1]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  3  1  7
>>6
>>[24]  4  2 75
>> > vectorSample(ex)
>>  [1]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  2  1  1  1  2
>>11
>>[24]  7  8 67
>> >
> 
> Eric,
> 
> Probably because I failed to provide a complete solution.  I had a couple
> questions while I was writing this that I didn't get clarified. One, the
> code needs to be slightly modified if you want to allow vector elements to
> be zero.  I required each element to be >= 1.  Two, I did not reorder the
> elements in the vector.  Larger counts are more likely early in the process
> than late in the process (since the partial sum is approaching the original
> total).  I just placed the counts in the vector result in reverse order of
> when they were obtained.
> 
> The fix to the "randomness" is simple.  Just return sample(v) instead of v
> as the function result (see below).  If you want to allow zero elements I
> think you can just change the lower limit on the sampling to be 0 rather
> than 1 (not thoroughly tested)
> 
> vectorSample <- function(vec) {
>   tot<-sum(vec)
>   Len<-length(vec)
>   v <-rep(0,Len)
>   for(i in Len:2) {
> UL <- tot - sum(v) - i + 1
> v[i]<-sample(1:UL,1) 
> #change preceding statement to 
> #v[i]<-sample(0:UL,1)
> #if you want to allow zeros
> }
>   v[1] <- tot - sum(v)
>   sample(v) #return vector in random order
>   }
> 
> Dan Nordlund
> Bothell, WA
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


-- 
Dr E.A. Catchpole
Visiting Fellow
Univ of New South Wales at ADFA, Canberra, Australia
and University of Kent, Canterbury, England
- www.ma.adfa.edu.au/~eac
- fax: +61 2 6268 8786  
- ph:  +61 2 6268 8895

__
R-help@stat.math.ethz.ch 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] Rcmdr and scatter3d

2005-10-04 Thread ecatchpole
Niara,

Alternatively, instead of scatter3d, the analogy to "hold on" in Matlab 
is to use plot() for the first set of data, then points() for the 
remainder. See

?plot
?points

Ted.

On 05/10/05 11:18,  John Fox wrote,:
> Dear Naiara,
> 
> Combine the data sets and differentiate among them with a factor. Then use
> the groups argument to scatter3d (see ?scatter3d). If you're using the R
> Commander to make the plot, the 3D scatterplot dialog box as a plot by
> groups button. You can also fit colour-coded regression surfaces by group.
> 
> I've appended a new version of the scatter3d function, not yet in the Rcmdr
> package, which will also plot data ellipsoids (for the whole data set or by
> groups).
> 
> I hope this helps,
>  John
> 
> --- snip --

> 
> John Fox
> Department of Sociology
> McMaster University
> Hamilton, Ontario
> Canada L8S 4M4
> 905-525-9140x23604
> http://socserv.mcmaster.ca/jfox 
>  
> 
>>-Original Message-
>>From: [EMAIL PROTECTED] 
>>[mailto:[EMAIL PROTECTED] On Behalf Of Naiara S. Pinto
>>Sent: Tuesday, October 04, 2005 6:13 PM
>>To: r-help@stat.math.ethz.ch
>>Subject: [R] Rcmdr and scatter3d
>>
>>Hi folks,
>>
>>I'd like to use scatter3d (which is in R commander) to plot 
>>more than one dataset in the same graph, each dataset with a 
>>different color. The kind of stuff you would do with "holdon" 
>>in Matlab.
>>
>>I read a recent message that was posted to this list with a 
>>similar problem, but I couldn't understand the reply. Could 
>>someone give me one example? How do you plot subgroups using 
>>scatter3d?
>>
>>Thanks a lot!
>>
>>Naiara.
>>
>>
>>
>>Naiara S. Pinto
>>Ecology, Evolution and Behavior
>>1 University Station A6700
>>Austin, TX, 78712
>>
>>__
>>R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


-- 
Dr E.A. Catchpole
Visiting Fellow
Univ of New South Wales at ADFA, Canberra, Australia
and University of Kent, Canterbury, England
- www.ma.adfa.edu.au/~eac
- fax: +61 2 6268 8786  
- ph:  +61 2 6268 8895

__
R-help@stat.math.ethz.ch 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] grob questions

2005-10-04 Thread Paul Murrell
Hi


Gabor Grothendieck wrote:
> On 10/4/05, Paul Murrell <[EMAIL PROTECTED]> wrote:
> 
>>Hi
>>
>>
>>Gabor Grothendieck wrote:
>>
>>>On 10/4/05, Paul Murrell <[EMAIL PROTECTED]> wrote:
>>>
>>>
Hi


Gabor Grothendieck wrote:


>If I run the following example from:
>http://www.stat.auckland.ac.nz/~paul/grid/doc/grobs.pdf
>
>
>
>
>>grid.newpage()
>>pushViewport(viewport(w = 0.5, h = 0.5))
>>myplot <- gTree(name = "myplot", children = gList(rectGrob(name = "box",
>
>+ gp = gpar(col = "grey")), xaxisGrob(name = "xaxis")))
>
>
>
>>grid.draw(myplot)
>>grid.edit("myplot::xaxis", at = 1:10/11)
>>grid.edit("myplot::xaxis::labels", label = round(1:10/11, 2))
>>grid.edit("myplot::xaxis::labels", y = unit(-1, "lines"))
>
>
>then
>
>
>
>
>>str(myplot$children$xaxis)
>
>
>lists 'at' but not the 'labels'.
>
>yet if I do this then the labels are listed:
>
>
>
>
>>xx <- xaxisGrob(name = "myX", at = 1:10)
>>childNames(xx)
>
>[1] "major"  "ticks"  "labels"
>
>
>1. How do I get to labels in the first case?


First, if the xaxisGrob has at=NULL then it calculates its tick-marks at
drawing time (based on the viewport it gets drawn in).  So it does not
store any labels (it doesn't know what they are until it gets drawn). If
you specify a non-NULL 'at' then the axis creates labels.

Second, grid grobs are standard R objects (copy-on-modify) so the object
'myplot' is not the same object that is being modified by the calls to
grid.edit().  grid.edit() destructively modifies a copy of the grob that
grid has stored on its display list;  you refer to the appropriate grob
via its name (not via an R object).  By comparison, editGrob() takes a
grob and returns a modified copy of the grob, for example ...
>>>
>>>
>>>Just one clarification.  What is the scope of names?
>>>In a recent post
>>>
>>>  https://www.stat.math.ethz.ch/pipermail/r-help/2005-October/078653.html
>>>  https://www.stat.math.ethz.ch/pipermail/r-help/2005-October/078656.html
>>>
>>>it seems that one had to use absolute paths and that seems to be the
>>>case here too where as mkondrin pointed out earlier in this thread
>>>
>>>  https://www.stat.math.ethz.ch/pipermail/r-help/2005-October/078635.html
>>>
>>>that get.grid("myplot::xaxis::labels")$label works.
>>>
>>>Its not clear to me whether names:
>>>
>>>- must be in absolute paths
>>>- can be relative to some position under some conditions
>>>- are global across all grob names in use and can be referred to directly
>>>as long as they are unique among all grobs defined so far.
>>>
>>>It seems absolute path names work but I am not sure whether the
>>>other possibilities can work under some conditions too.
>>>
>>>Also what the scope of viewports?   Absolute path? Relative path?
>>>Global names?  Does it work the same way?  I think at least
>>>absolute and relative paths are avalable here but could you confirm
>>>my understanding and whether the situation is the same for
>>>viewports and grobs?
>>>
>>>(In the Windows, and analogously in UNIX, file system one can write
>>>\usr\myname or position oneself to \usr using cd and then refer to
>>>myname in a relative way:
>>>
>>>cd \usr
>>>dir myname
>>>)
>>
>>
>>The distinction is not between "relative" or "absolute" paths, but
>>between "strict" and "not strict" paths.
>>
>>Matching a path always *starts* from your current "position" (so in that
>>sense it is always "relative" and never "absolute").  When working with
>>viewports, there is a current viewport tree and it is possible to be in
>>different positions within that tree --- via [push|down|up]Viewport()
>>--- so a path may have different meanings depending on where you are.
>>(The seekViewport() function is sort of absolute because it always
>>starts from the root of the viewport tree, but a non-strict
>>seekViewport() [see below] behaves quite differently from an absolute
>>filesystem directory path.)  When working with grobs, you tend to always
>>be at the "top" or "root".  You are either: working off-screen with a
>>single specific grob (gTree) so you are always at the top of that gTree;
>> or working with the grid display list, in which case you have a list
>>of grobs and gTrees, which are searched one after the other.
>>
>>The functions that take paths for grobs, such as grid.edit(), and for
>>viewports, such as downViewport(), have an argument 'strict' which
>>controls whether the path should be matched from the current position or
>>whether the search can start from the current position and we'll match
>>the path if it occurs anywhere below the current position.  (There are
>>also 'grep' and 'global' arguments so you can get multiple matches where
>>it makes sense.)
>>
>>In some cases, grid has to make use of a path on its own, without
>>knowing explicitly whether the path is 

Re: [R] TRAMO-SEATS methodology

2005-10-04 Thread Dirk Eddelbuettel

On 4 October 2005 at 22:35, Soren Wilkening wrote:
| Dear Colleagues
| 
| would someone know a suitable online-source for information
| regarding the TRAMO SEATS method for time series ?
| (an alternative to X12 ARIMA and earlier ARIMAs used by the US census 
| bureau)

Google is your friend -- It's been a while but the last time I looked I found
documents both at the Bank of Spain's website (where A Maravall is or was)
and as I recall some code at EuroStat (by former students of his).

Also, Gretl has an interface to tramo-seats. See
http://gretl.sourceforge.net/tramo/tramo-seats.html

Gruesse, Dirk

-- 
Statistics: The (futile) attempt to offer certainty about uncertainty.
 -- Roger Koenker, 'Dictionary of Received Ideas of Statistics'

__
R-help@stat.math.ethz.ch 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] Rcmdr and scatter3d

2005-10-04 Thread John Fox
Dear Naiara,

Combine the data sets and differentiate among them with a factor. Then use
the groups argument to scatter3d (see ?scatter3d). If you're using the R
Commander to make the plot, the 3D scatterplot dialog box as a plot by
groups button. You can also fit colour-coded regression surfaces by group.

I've appended a new version of the scatter3d function, not yet in the Rcmdr
package, which will also plot data ellipsoids (for the whole data set or by
groups).

I hope this helps,
 John

--- snip --

ellipsoid <- function(center=c(0, 0, 0), radius=1, shape=diag(3), n=30){
# adapted from the shapes3d demo in the rgl package
  degvec <- seq(0, 2*pi, length=n)
  ecoord2 <- function(p) c(cos(p[1])*sin(p[2]), sin(p[1])*sin(p[2]),
cos(p[2]))
  v <- t(apply(expand.grid(degvec,degvec), 1, ecoord2))
  v <- center + radius * t(v %*% chol(shape))
  v <- rbind(v, rep(1,ncol(v))) 
  e <- expand.grid(1:(n-1), 1:n)
  i1 <- apply(e, 1, function(z) z[1] + n*(z[2] - 1))
  i2 <- i1 + 1
  i3 <- (i1 + n - 1) %% n^2 + 1
  i4 <- (i2 + n - 1) %% n^2 + 1
  i <- rbind(i1, i2, i4, i3)
  qmesh3d(v, i)
  }

scatter3d <- function(x, y, z, xlab=deparse(substitute(x)),
ylab=deparse(substitute(y)),
zlab=deparse(substitute(z)), revolutions=0, bg.col=c("white", "black"), 
axis.col=if (bg.col == "white") "black" else "white",
surface.col=c("blue", "green", "orange", "magenta", "cyan", "red",
"yellow", "gray"),
neg.res.col="red", pos.res.col="green", point.col="yellow",
text.col=axis.col, grid.col=if (bg.col == "white") "black" else "gray",
fogtype=c("exp2", "linear", "exp", "none"),
residuals=(length(fit) == 1), surface=TRUE, fill=TRUE, grid=TRUE,
grid.lines=26,
df.smooth=NULL, df.additive=NULL,
sphere.size=1, threshold=0.01, speed=1, fov=60,
fit="linear", groups=NULL, parallel=TRUE, ellipsoid=FALSE, level=0.5, 
model.summary=FALSE){
require(rgl)
require(mgcv)
summaries <- list()
if ((!is.null(groups)) && (nlevels(groups) > length(surface.col))) 
stop(sprintf(
gettextRcmdr("Number of groups (%d) exceeds number of colors
(%d)."),
nlevels(groups), length(surface.col)))
if ((!is.null(groups)) && (!is.factor(groups))) 
stop(gettextRcmdr("groups variable must be a factor."))
bg.col <- match.arg(bg.col)
fogtype <- match.arg(fogtype)
if ((length(fit) > 1) && residuals && surface)
stop(gettextRcmdr("cannot plot both multiple surfaces and
residuals"))
xlab  # cause these arguments to be evaluated
ylab
zlab
rgl.clear()
rgl.viewpoint(fov=fov)
rgl.bg(col=bg.col, fogtype=fogtype)
valid <- if (is.null(groups)) complete.cases(x, y, z)
else complete.cases(x, y, z, groups)
x <- x[valid]
y <- y[valid]
z <- z[valid]
if (!is.null(groups)) groups <- groups[valid]
x <- (x - min(x))/(max(x) - min(x))
y <- (y - min(y))/(max(y) - min(y))
z <- (z - min(z))/(max(z) - min(z))
size <- sphere.size*((100/length(x))^(1/3))*0.015
if (is.null(groups)){
if (size > threshold) rgl.spheres(x, y, z, color=point.col,
radius=size)
else rgl.points(x, y, z, color=point.col)
}
else {
if (size > threshold) rgl.spheres(x, y, z, 
color=surface.col[as.numeric(groups)], radius=size)
else rgl.points(x, y, z, color=surface.col[as.numeric(groups)])
}
rgl.lines(c(0,1), c(0,0), c(0,0), color=axis.col)
rgl.lines(c(0,0), c(0,1), c(0,0), color=axis.col)
rgl.lines(c(0,0), c(0,0), c(0,1), color=axis.col)
rgl.texts(1, 0, 0, xlab, adj=1, color=text.col)
rgl.texts(0, 1, 0, ylab, adj=1, color=text.col)
rgl.texts(0, 0, 1, zlab, adj=1, color=text.col)
if (ellipsoid) {
dfn <- 3
if (is.null(groups)){
dfd <- length(x) - 1
radius <- sqrt(dfn * qf(level, dfn, dfd))
ellips <- ellipsoid(center=c(mean(x), mean(y), mean(z)), 
shape=cov(cbind(x,y,z)), radius=radius)
if (fill) shade3d(ellips, col=surface.col[1], alpha=0.1,
lit=FALSE)
if (grid) wire3d(ellips, col=surface.col[1], lit=FALSE)
}
else{
levs <- levels(groups)
for (j in 1:length(levs)){
group <- levs[j]
select.obs <- groups == group
xx <- x[select.obs]
yy <- y[select.obs]
zz <- z[select.obs]
dfd <- length(xx) - 1
radius <- sqrt(dfn * qf(level, dfn, dfd))
ellips <- ellipsoid(center=c(mean(xx), mean(yy), mean(zz)), 
shape=cov(cbind(xx,yy,zz)), radius=radius)
if (fill) shade3d(ellips, col=surface.col[j], alpha=0.1,
lit=FALSE)
if (grid) wire3d(ellips, col=surface.col[j], lit=FALSE)
coords <- ellips$vb[, which.max(ellips$vb[1,])]
if (!surface) rgl.texts(coords[1] + 0.05, coords[2],
coords[3], group, 
  

Re: [R] grob questions

2005-10-04 Thread Gabor Grothendieck
On 10/4/05, Paul Murrell <[EMAIL PROTECTED]> wrote:
> Hi
>
>
> Gabor Grothendieck wrote:
> > On 10/4/05, Paul Murrell <[EMAIL PROTECTED]> wrote:
> >
> >>Hi
> >>
> >>
> >>Gabor Grothendieck wrote:
> >>
> >>>If I run the following example from:
> >>>http://www.stat.auckland.ac.nz/~paul/grid/doc/grobs.pdf
> >>>
> >>>
> >>>
> grid.newpage()
> pushViewport(viewport(w = 0.5, h = 0.5))
> myplot <- gTree(name = "myplot", children = gList(rectGrob(name = "box",
> >>>
> >>>+ gp = gpar(col = "grey")), xaxisGrob(name = "xaxis")))
> >>>
> >>>
> grid.draw(myplot)
> grid.edit("myplot::xaxis", at = 1:10/11)
> grid.edit("myplot::xaxis::labels", label = round(1:10/11, 2))
> grid.edit("myplot::xaxis::labels", y = unit(-1, "lines"))
> >>>
> >>>
> >>>then
> >>>
> >>>
> >>>
> str(myplot$children$xaxis)
> >>>
> >>>
> >>>lists 'at' but not the 'labels'.
> >>>
> >>>yet if I do this then the labels are listed:
> >>>
> >>>
> >>>
> xx <- xaxisGrob(name = "myX", at = 1:10)
> childNames(xx)
> >>>
> >>>[1] "major"  "ticks"  "labels"
> >>>
> >>>
> >>>1. How do I get to labels in the first case?
> >>
> >>
> >>First, if the xaxisGrob has at=NULL then it calculates its tick-marks at
> >>drawing time (based on the viewport it gets drawn in).  So it does not
> >>store any labels (it doesn't know what they are until it gets drawn). If
> >>you specify a non-NULL 'at' then the axis creates labels.
> >>
> >>Second, grid grobs are standard R objects (copy-on-modify) so the object
> >>'myplot' is not the same object that is being modified by the calls to
> >>grid.edit().  grid.edit() destructively modifies a copy of the grob that
> >>grid has stored on its display list;  you refer to the appropriate grob
> >>via its name (not via an R object).  By comparison, editGrob() takes a
> >>grob and returns a modified copy of the grob, for example ...
> >
> >
> > Just one clarification.  What is the scope of names?
> > In a recent post
> >
> >   https://www.stat.math.ethz.ch/pipermail/r-help/2005-October/078653.html
> >   https://www.stat.math.ethz.ch/pipermail/r-help/2005-October/078656.html
> >
> > it seems that one had to use absolute paths and that seems to be the
> > case here too where as mkondrin pointed out earlier in this thread
> >
> >   https://www.stat.math.ethz.ch/pipermail/r-help/2005-October/078635.html
> >
> > that get.grid("myplot::xaxis::labels")$label works.
> >
> > Its not clear to me whether names:
> >
> > - must be in absolute paths
> > - can be relative to some position under some conditions
> > - are global across all grob names in use and can be referred to directly
> > as long as they are unique among all grobs defined so far.
> >
> > It seems absolute path names work but I am not sure whether the
> > other possibilities can work under some conditions too.
> >
> > Also what the scope of viewports?   Absolute path? Relative path?
> > Global names?  Does it work the same way?  I think at least
> > absolute and relative paths are avalable here but could you confirm
> > my understanding and whether the situation is the same for
> > viewports and grobs?
> >
> > (In the Windows, and analogously in UNIX, file system one can write
> > \usr\myname or position oneself to \usr using cd and then refer to
> > myname in a relative way:
> >
> > cd \usr
> > dir myname
> > )
>
>
> The distinction is not between "relative" or "absolute" paths, but
> between "strict" and "not strict" paths.
>
> Matching a path always *starts* from your current "position" (so in that
> sense it is always "relative" and never "absolute").  When working with
> viewports, there is a current viewport tree and it is possible to be in
> different positions within that tree --- via [push|down|up]Viewport()
> --- so a path may have different meanings depending on where you are.
> (The seekViewport() function is sort of absolute because it always
> starts from the root of the viewport tree, but a non-strict
> seekViewport() [see below] behaves quite differently from an absolute
> filesystem directory path.)  When working with grobs, you tend to always
> be at the "top" or "root".  You are either: working off-screen with a
> single specific grob (gTree) so you are always at the top of that gTree;
>  or working with the grid display list, in which case you have a list
> of grobs and gTrees, which are searched one after the other.
>
> The functions that take paths for grobs, such as grid.edit(), and for
> viewports, such as downViewport(), have an argument 'strict' which
> controls whether the path should be matched from the current position or
> whether the search can start from the current position and we'll match
> the path if it occurs anywhere below the current position.  (There are
> also 'grep' and 'global' arguments so you can get multiple matches where
> it makes sense.)
>
> In some cases, grid has to make use of a path on its own, without
> knowing explicitly whether the path is strict (e.g., when you specify a
> path in a 'vp' sl

Re: [R] "Survey" package and NAMCS data... unsure of specification

2005-10-04 Thread Thomas Lumley
On Tue, 4 Oct 2005, David L. Van Brunt, Ph.D. wrote:

> Hello, all.
>
> I wanted to use the "survey" package to analyze data from the National
> Ambulatory Medical Care Survey, and am having some difficulty translating
> the analysis keywords from one package (Stata) to the other (R). The data
> were collected using a multistage probability sampling, and there are
> variables included to identify the sampling units and weights. Documentation
> from the NAMCS describes this for Stata as follows (note the variable names
> in the data are in caps):
>
> The pweight (PATWT), strata (CSTRATM), and PSU (CPSUM) are set with the
> svyset command as
> follows:
> svyset pweight PATWT
> svyset strata CSTRATM
> svyset psu CPSUM
>

Supposing your data frame is called 'namcs'

dnamcs <- svydesign(id=~CPSUM, strata=~CSTRATM, weight=~PATWT, data=namcs)

or perhaps

dnamcs <- svydesign(id=~CPSUM, strata=~CSTRATM, weight=~PATWT,
   data=namcs, nest=TRUE)

(nest=TRUE is needed if CPSUM repeats the same values in different 
strata).

Also, if you have access to design variables for the multistage design you 
can use them (but it probably won't make much difference). There's a very 
brief example using the National Health Interview Study at
  http://faculty.washington.edu/tlumley/survey/example-twostage.html


-thomas

__
R-help@stat.math.ethz.ch 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] Rcmdr and scatter3d

2005-10-04 Thread Naiara S. Pinto
Hi folks,

I'd like to use scatter3d (which is in R commander) to plot more than one
dataset in the same graph, each dataset with a different color. The kind
of stuff you would do with "holdon" in Matlab.

I read a recent message that was posted to this list with a similar
problem, but I couldn't understand the reply. Could someone give me one
example? How do you plot subgroups using scatter3d?

Thanks a lot!

Naiara.



Naiara S. Pinto
Ecology, Evolution and Behavior
1 University Station A6700
Austin, TX, 78712

__
R-help@stat.math.ethz.ch 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] Need help on ARIMA (time series analysis)

2005-10-04 Thread park
Hi, 
 
I am so novice in using R. I have some problems in my R script below
which fits time series data and predict it one-step ahead.  Here is a
brief explanation on what I try to achieve
 
Th16k is time series data (500 data points). The size of window for
fitting and predicting is 50 (data points). As you can easily discover
from my code,  (fixed) window is moving/sliding to get next one-step
ahead prediction. The predicted value will be saved in pth.
 
The problem is,  every time I execute following script, I got error
saying 
 
> source("C:\\R\\arima.R")
Error in arima(temp, order = c(1, 0, 1)) : 
non-stationary AR part from CSS
 
I think there should be better way to achieve this goal without using
for loop.  If you can share your knowledge, please advise me!!! :-)
 
<---
->
w <- 50
pth <- th16k[1:w]
limit <- length(th16k)-w
for (i in 1:limit) {
  ws <- i
  we <- i+w-1
  temp <- th16k[ws:we]
  fit <- arima(temp, order=c(1, 0, 1))
  pred <- predict(fit, n.ahead=1)
  pth[i+w] <- pred$pred
}
plot(pth)
<---
->
 

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] User error (was arima.sim bug?)

2005-10-04 Thread Brian D Ripley
On Tue, 4 Oct 2005, Rolf Turner wrote:

>
> Brian Ripley wrote (in response to S. E. Kemp):
>
> > > I am using the arima.sim function to generate some AR time series.
> > > However, the function does not seem to produce exactly the same time
> > > series when I specify the innov parameter. For example
>   
> > > Given the fact that I have provided the innovations shouldn't the time
> > > series be exactly the same?
> >
> > No.  Hint: where does the randomness for the burn-in come from?
>
>   What then, pray tell, is the point of having the
>   ``innov'' argument at all?

To allow non-Gaussian innovations, in particular for use in bootstrapping
time series.  (This started life in package boot and is used in
example(tsboot).)

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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-help@stat.math.ethz.ch 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] generalized linear model and missing handling

2005-10-04 Thread Weiwei Shi
I mean complete.cases(df) gives me all falses

On 10/4/05, Weiwei Shi <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I have a dataset and want to build a generalized linear model on it.
> Unfortunately, complete.cases(df) returns null, which means I have to find
> a way to "fill" those missings. One way is following my previous post to use
> median to replace(or use most freq. of level to replace for catergorical
> case), but I am wondering if there are other ways, when glm or something
> like it is concerned in R?
>
> Thanks,
>
> Weiwei
>
> --
> Weiwei Shi, Ph.D
>
> "Did you always know?"
> "No, I did not. But I believed..."
> ---Matrix III
>



--
Weiwei Shi, Ph.D

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] "Survey" package and NAMCS data... unsure of specification

2005-10-04 Thread David L. Van Brunt, Ph.D.
Hello, all.

I wanted to use the "survey" package to analyze data from the National
Ambulatory Medical Care Survey, and am having some difficulty translating
the analysis keywords from one package (Stata) to the other (R). The data
were collected using a multistage probability sampling, and there are
variables included to identify the sampling units and weights. Documentation
from the NAMCS describes this for Stata as follows (note the variable names
in the data are in caps):

The pweight (PATWT), strata (CSTRATM), and PSU (CPSUM) are set with the
svyset command as
follows:
svyset pweight PATWT
svyset strata CSTRATM
svyset psu CPSUM


They provide similar instructions for SUDAAN: as
SUDAAN 1-stage WR Option
The program below provides a with replacement ultimate cluster (1-stage)
estimate of standard errors for a
cross-tabulation.
PROC CROSSTAB DATA=COMB1 DESIGN=WR FILETYPE=SAS;
NEST CSTRATM CPSUM/MISSUNIT;

In R, the svydesign command is used to set the sampling scheme, but as
follows (example from the documentation):

dstrat <- svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)

 stratified on stype, with sampling weights pw. The fpc variable contains
the population size for the stratum. As the schools are sampled
independently, each record in the data frame is a separate PSU. This is
indicated by id=~1. Since the sampling weights could have been determined
from the population size an equivalent declaration would be

dstrat <- svydesign(id=~1,strata=~stype,  data=apistrat, fpc=~fpc)

I get that the "weights" should be PATWT, and it seems that the "strata"
should be CSTRATM, but I'm unsure of how to handle the primary sampling
units (CPSUM).

Does anyone have any suggestions?

--
---
David L. Van Brunt, Ph.D.
mailto:[EMAIL PROTECTED]

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] generalized linear model and missing handling

2005-10-04 Thread Weiwei Shi
Hi,
I have a dataset and want to build a generalized linear model on it.
Unfortunately, complete.cases(df) returns null, which means I have to find a
way to "fill" those missings. One way is following my previous post to use
median to replace(or use most freq. of level to replace for catergorical
case), but I am wondering if there are other ways, when glm or something
like it is concerned in R?

Thanks,

Weiwei

--
Weiwei Shi, Ph.D

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] The error message in package Mix

2005-10-04 Thread Wang, Lijun (SPRI 19)
Hi all, 
When using package MIX, I often get the error: NA/NaN/Inf in foreign
function call (arg 1). 
For example, 
> s<-prelim.mix(Y,6)
Error in prelim.mix(Y, 6) : NA/NaN/Inf in foreign function call (arg 1) 
or when I ran: 
MI<-vector("list",5) #<--vector of complete data after MI
fit.model.mi<-vector("list",5)
rngseed(1234567) #<-- set random number generator seed
margins<-c(1,2) #<-- I have two categorical variables, if I had three, the
margin=c(1,2,3)
design<-matrix(c(1,1,1,1,0,1,0,1,0,0,1,1),ncol=3)
for (i in 1:5){
cat("Doing imputation ",i,"\n")
thetahat <- ecm.mix(s,margins,design)
newtheta <- dabipf.mix(s, margins,design,thetahat, steps=2000, showits=TRUE)

MI[[i]] <- imp.mix(s, newtheta)
}
Steps of ECM: 
1...2...3...4...5...6...7...8...9...10...11...12...13...14...15...16...17...
18...19...20...21...22...23...24...25...26...
Steps of Data Augmentation-Bayesian IPF: 
1...2...Error: NA/NaN/Inf in foreign function call (arg 7) 
Does anyone know what it mean? Any help will be greatly appreciated. 
Thanks,



Lijun Wang, Ph.D.



*
This message and any attachments are solely for the intended...{{dropped}}

__
R-help@stat.math.ethz.ch 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] Joining Dataframes

2005-10-04 Thread Don MacQueen
It appears that you want to match rows by date. It also looks like 
your date information is in the row names, only, if the layout of 
your example can be trusted.

The help for merge says this:
 "By default the data frames are merged on the columns with names 
they both have..."
but the column you want to merge by, date, is not in either 
dataframe. So, obviously, it can't merge on date. Also, since your 
example has other columns with the same name that you do not want to 
merge on, you will have to tell it explicitly what columns to use for 
the merge.

So, assuming I've interpreted your example correctly, try this:
   (1) get your dates into a column
   (2) use the 'by' argument of merge to force it to merge on date only.

merge(species1.effort, species2.effort, by='date')


-Don



At 11:37 AM -0800 10/4/05, Matt Goff wrote:
>I am attempting to join several dataframes that summarize sampling effort 
>for different samples into one large data.frame/table.
>I have looked at the merge command, but have not been clever enough to 
>figure out how to get it to do what I want.
>
>A simplified example of what I am trying to do:
>
>The dataframes I have look like this (they were generated using the table 
>command)
>
>species1.effort
> site1   site2   site3
>date1 55   5
>date2 45   5
>date3 45   5
>
>species2.effort
> site1   site2   site3
>date1 786
>date3 878
>date4 888
>
>I would like to join these into a table that looks something like this:
>
>Effort
>  sp1.site1  sp1.site2  sp1.site3  sp2.site1  sp2.site2  
>sp2.site2
>date1 5   5  5 7 
>86
>date2 4   5  5NA  
>NA NA
>date3 4   5   5   8 
>7 8
>date4 NA   NANA 88 
>8
>
>
>I have many more dates and species, but I assume whatever method works for 
>this small example, would work for larger cases.
>
>Thanks,
>Matt Goff
>
>__
>R-help@stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


-- 
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA

__
R-help@stat.math.ethz.ch 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] grob questions

2005-10-04 Thread Paul Murrell
Hi


Gabor Grothendieck wrote:
> On 10/4/05, Paul Murrell <[EMAIL PROTECTED]> wrote:
> 
>>Hi
>>
>>
>>Gabor Grothendieck wrote:
>>
>>>If I run the following example from:
>>>http://www.stat.auckland.ac.nz/~paul/grid/doc/grobs.pdf
>>>
>>>
>>>
grid.newpage()
pushViewport(viewport(w = 0.5, h = 0.5))
myplot <- gTree(name = "myplot", children = gList(rectGrob(name = "box",
>>>
>>>+ gp = gpar(col = "grey")), xaxisGrob(name = "xaxis")))
>>>
>>>
grid.draw(myplot)
grid.edit("myplot::xaxis", at = 1:10/11)
grid.edit("myplot::xaxis::labels", label = round(1:10/11, 2))
grid.edit("myplot::xaxis::labels", y = unit(-1, "lines"))
>>>
>>>
>>>then
>>>
>>>
>>>
str(myplot$children$xaxis)
>>>
>>>
>>>lists 'at' but not the 'labels'.
>>>
>>>yet if I do this then the labels are listed:
>>>
>>>
>>>
xx <- xaxisGrob(name = "myX", at = 1:10)
childNames(xx)
>>>
>>>[1] "major"  "ticks"  "labels"
>>>
>>>
>>>1. How do I get to labels in the first case?
>>
>>
>>First, if the xaxisGrob has at=NULL then it calculates its tick-marks at
>>drawing time (based on the viewport it gets drawn in).  So it does not
>>store any labels (it doesn't know what they are until it gets drawn). If
>>you specify a non-NULL 'at' then the axis creates labels.
>>
>>Second, grid grobs are standard R objects (copy-on-modify) so the object
>>'myplot' is not the same object that is being modified by the calls to
>>grid.edit().  grid.edit() destructively modifies a copy of the grob that
>>grid has stored on its display list;  you refer to the appropriate grob
>>via its name (not via an R object).  By comparison, editGrob() takes a
>>grob and returns a modified copy of the grob, for example ...
> 
> 
> Just one clarification.  What is the scope of names?
> In a recent post
> 
>   https://www.stat.math.ethz.ch/pipermail/r-help/2005-October/078653.html
>   https://www.stat.math.ethz.ch/pipermail/r-help/2005-October/078656.html
> 
> it seems that one had to use absolute paths and that seems to be the
> case here too where as mkondrin pointed out earlier in this thread
> 
>   https://www.stat.math.ethz.ch/pipermail/r-help/2005-October/078635.html
> 
> that get.grid("myplot::xaxis::labels")$label works.
> 
> Its not clear to me whether names:
> 
> - must be in absolute paths
> - can be relative to some position under some conditions
> - are global across all grob names in use and can be referred to directly
> as long as they are unique among all grobs defined so far.
> 
> It seems absolute path names work but I am not sure whether the
> other possibilities can work under some conditions too.
> 
> Also what the scope of viewports?   Absolute path? Relative path?
> Global names?  Does it work the same way?  I think at least
> absolute and relative paths are avalable here but could you confirm
> my understanding and whether the situation is the same for
> viewports and grobs?
> 
> (In the Windows, and analogously in UNIX, file system one can write
> \usr\myname or position oneself to \usr using cd and then refer to
> myname in a relative way:
> 
> cd \usr
> dir myname
> )


The distinction is not between "relative" or "absolute" paths, but 
between "strict" and "not strict" paths.

Matching a path always *starts* from your current "position" (so in that 
sense it is always "relative" and never "absolute").  When working with 
viewports, there is a current viewport tree and it is possible to be in 
different positions within that tree --- via [push|down|up]Viewport() 
--- so a path may have different meanings depending on where you are. 
(The seekViewport() function is sort of absolute because it always 
starts from the root of the viewport tree, but a non-strict 
seekViewport() [see below] behaves quite differently from an absolute 
filesystem directory path.)  When working with grobs, you tend to always 
be at the "top" or "root".  You are either: working off-screen with a 
single specific grob (gTree) so you are always at the top of that gTree; 
  or working with the grid display list, in which case you have a list 
of grobs and gTrees, which are searched one after the other.

The functions that take paths for grobs, such as grid.edit(), and for 
viewports, such as downViewport(), have an argument 'strict' which 
controls whether the path should be matched from the current position or 
whether the search can start from the current position and we'll match 
the path if it occurs anywhere below the current position.  (There are 
also 'grep' and 'global' arguments so you can get multiple matches where 
it makes sense.)

In some cases, grid has to make use of a path on its own, without 
knowing explicitly whether the path is strict (e.g., when you specify a 
path in a 'vp' slot).  In those cases, grid interprets the path as 
strict (so that, for example, grid has some chance of undoing the 
navigation down to a viewport).

Regarding uniqueness of names, all viewports *which share the same 
parent viewport* must have unique names (same for g

[R] repeated measures with random effects

2005-10-04 Thread juli g. pausas
Dear all,
I'm interested in analysing a reapeated measure desing where plant
height (H) was measured 3 times (Time). The experimental design
include 2 fixed factor (say A and B) in which A is nested in B, and a
random factor (C, the plot), using the aov().

So my first idea would be something like:

aov(H ~ B * A %in% B * Time + Error(id) )

where id is the factor coded for the repeated subjects.
But my question is how to include the random factor C ?

Any help would be appreciated. Thanks

Juli


--
Juli G. Pausas
CEAM & UA
http://www.ceam.es/lass/pausas.htm

__
R-help@stat.math.ethz.ch 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] missing handling

2005-10-04 Thread Don MacQueen
At 8:35 PM +0100 10/4/05, Prof Brian Ripley wrote:
>On Tue, 4 Oct 2005, Weiwei Shi wrote:
>
>>  Hi, Jim:
>>  I tried your code and get the following error:
>>  trn1<-read.table('trn1.svm', header=F, na.string='.', sep='|')
>>  Med<-apply(trn1, 2, median, na.rm=T)
>>  Ind<-which(is.na(trn1), arr.ind=T)
>>  trn1[Ind]<-Med[Ind[,'col']]
>>  Error in "[<-.data.frame"(`*tmp*`, Ind, value = c(1.00802124455,
>>  1.00802124455, :
>>  only logical matrix subscripts are allowed in replacement
>>
>>
>>  I cannot figure out why.
>
>Read the help for "[<-.data.frame" to be told the answer.
>
>A data frame (as given by read.table) is not a matrix, as the example
>presumably was.  Indexing whole matrices at once is efficient, but it
>hides loops for data frames.
>
>You will not do better than looping over columns for a data frame, but you
>certainly do not need to loop over rows which is very inefficient.
>Something like
>
>trn2 <- trn1
>for(i in names(trn2)) {
>  Med <- median(trn2[[i]], na.rm = TRUE)
>  trn2[i, is.na(trn2[[i]])] <- Med
>}
>

But exchange the indices:

trn2[ is.na(trn2[[i]]) , i] <- Med


>  >
>>  Thanks for help,
>>
>>  On 9/27/05, jim holtman <[EMAIL PROTECTED]> wrote:
>>>
>>>  Use 'which(...arr.ind=T)'
>>>  > x.1
>>>  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
>>>  [1,] 6 10 3 4 10 7 9 8 4 10
>>>  [2,] 8 7 4 7 4 8 3 NA 3 4
>>>  [3,] 7 7 10 10 3 5 3 2 2 2
>>>  [4,] 3 4 5 10 10 2 6 9 4 5
>>>  [5,] 3 5 9 5 6 NA 3 NA 6 7
>>>  [6,] 9 6 10 5 10 4 2 10 NA 5
>>>  [7,] 5 2 5 10 3 7 6 4 6 8
>>>  [8,] 2 6 1 8 9 2 7 8 3 8
>>>  [9,] 9 1 4 9 8 10 2 NA 1 7
>>>  [10,] 2 4 8 7 NA 4 3 NA 5 5
  x.4
>>>  [1] 5.5 5.5 5.0 7.5 8.0 5.0 3.0 8.0 4.0 6.0
  Med <- apply(x.1, 2, median, na.rm=T) # get median
  Ind <- which(is.na(x.1), arr.ind=T) # determine which are NA
  x.1[Ind] <- Med[Ind[,'col']] # replace with median
  x.1
>>>  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
>>>  [1,] 6 10 3 4 10 7 9 8 4 10
>>>  [2,] 8 7 4 7 4 8 3 8 3 4
>>>  [3,] 7 7 10 10 3 5 3 2 2 2
>>>  [4,] 3 4 5 10 10 2 6 9 4 5
>>>  [5,] 3 5 9 5 6 5 3 8 6 7
>>>  [6,] 9 6 10 5 10 4 2 10 4 5
>>>  [7,] 5 2 5 10 3 7 6 4 6 8
>>>  [8,] 2 6 1 8 9 2 7 8 3 8
>>>  [9,] 9 1 4 9 8 10 2 8 1 7
>>>  [10,] 2 4 8 7 8 4 3 8 5 5

>>>
>>>
>>>   On 9/27/05, Weiwei Shi <[EMAIL PROTECTED]> wrote:
>>>
  Hi,
  I have the following codes to replace missing using median, assuming
>  >>> missing
>  >>> only occurs on continuous variables:
>  >>>
>  >>> trn1<-read.table('trn1.fv', header=F, na.string='.', sep='|')
>  >>>
>  >>> # median
>  >>> m.trn1<-sapply(1:ncol(trn1), function(i) median(trn1[,i], na.rm=T))

  #replace
  trn2<-trn1
  for (each in 1:nrow(trn1)){
  index.missing=which(is.na(trn1[each,]))
  trn2[each,]<-replace(trn1[each,], index.missing, m.trn1[index.missing])
  }


  Anyone can suggest some ways to improve it since replacing 10 
takes 1.5sec:
>  system.time(for (each in 1:10){index.missing=which(is.na
  (trn1[each,]));
  trn2[each,]<-replace(trn1[each,], index.missing, m.trn1[index.missing
  ]);})
  [1] 1.53 0.00 1.53 0.00 0.00


  Another general question is
  are there some packages in R doing missing handling?

  Thanks,

  --
  Weiwei Shi, Ph.D

  "Did you always know?"
  "No, I did not. But I believed..."
  ---Matrix III

  [[alternative HTML version deleted]]

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

>>>
>>>
>>>
>>>  --
>>>  Jim Holtman
>>>  Cincinnati, OH
>>>  +1 513 247 0281
>>>
>>>  What the problem you are trying to solve?
>>
>>
>>
>>
>>  --
>>  Weiwei Shi, Ph.D
>>
>>  "Did you always know?"
>>  "No, I did not. But I believed..."
>>  ---Matrix III
>>
>>  [[alternative HTML version deleted]]
>>
>>  __
>>  R-help@stat.math.ethz.ch mailing list
>>  https://stat.ethz.ch/mailman/listinfo/r-help
>  > PLEASE do read the posting guide! 
>http://www.R-project.org/posting-guide.html
>>
>
>--
>Brian D. Ripley,  [EMAIL PROTECTED]
>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-help@stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


-- 
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA

__
R-help@stat.math.ethz.ch mailing list
htt

[R] TRAMO-SEATS methodology

2005-10-04 Thread Soren Wilkening
Dear Colleagues

would someone know a suitable online-source for information
regarding the TRAMO SEATS method for time series ?
(an alternative to X12 ARIMA and earlier ARIMAs used by the US census 
bureau)

Cheers

-- 
-

Soren Wilkening
Principal Consultant

phone: +49-30-96080121
[EMAIL PROTECTED]

CENSIX Consulting
Statistics, Surveys, Censuses
http://www.censix.com

__
R-help@stat.math.ethz.ch 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] sampling vectors

2005-10-04 Thread Nordlund, Dan
Eric,


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:r-help-
> [EMAIL PROTECTED] On Behalf Of Eric Pante
> Sent: Tuesday, October 04, 2005 8:47 AM
> To: Daniel Nordlund
> Cc: r-help@stat.math.ethz.ch
> Subject: Re: [R] sampling vectors
> 
> Hi Dan,
> 
> I just tried your code with long vectors, and the sampling stops to be
> random. Do you see any reason why this is ?
> 
> examples:
> 
> ex = c(30,13,9,8,7,7,7,6,6,5,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1)
> 
>  > vectorSample(ex)
>   [1]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  3  1  7
> 6
> [24]  4  2 75
>  > vectorSample(ex)
>   [1]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  2  1  1  1  2
> 11
> [24]  7  8 67
>  >

Eric,

Probably because I failed to provide a complete solution.  I had a couple
questions while I was writing this that I didn't get clarified. One, the
code needs to be slightly modified if you want to allow vector elements to
be zero.  I required each element to be >= 1.  Two, I did not reorder the
elements in the vector.  Larger counts are more likely early in the process
than late in the process (since the partial sum is approaching the original
total).  I just placed the counts in the vector result in reverse order of
when they were obtained.

The fix to the "randomness" is simple.  Just return sample(v) instead of v
as the function result (see below).  If you want to allow zero elements I
think you can just change the lower limit on the sampling to be 0 rather
than 1 (not thoroughly tested)

vectorSample <- function(vec) {
  tot<-sum(vec)
  Len<-length(vec)
  v <-rep(0,Len)
  for(i in Len:2) {
UL <- tot - sum(v) - i + 1
v[i]<-sample(1:UL,1) 
#change preceding statement to 
#v[i]<-sample(0:UL,1)
#if you want to allow zeros
}
  v[1] <- tot - sum(v)
  sample(v) #return vector in random order
  }

Dan Nordlund
Bothell, WA

__
R-help@stat.math.ethz.ch 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] grob questions

2005-10-04 Thread Gabor Grothendieck
On 10/4/05, Paul Murrell <[EMAIL PROTECTED]> wrote:
> Hi
>
>
> Gabor Grothendieck wrote:
> > If I run the following example from:
> > http://www.stat.auckland.ac.nz/~paul/grid/doc/grobs.pdf
> >
> >
> >>grid.newpage()
> >>pushViewport(viewport(w = 0.5, h = 0.5))
> >>myplot <- gTree(name = "myplot", children = gList(rectGrob(name = "box",
> >
> > + gp = gpar(col = "grey")), xaxisGrob(name = "xaxis")))
> >
> >>grid.draw(myplot)
> >>grid.edit("myplot::xaxis", at = 1:10/11)
> >>grid.edit("myplot::xaxis::labels", label = round(1:10/11, 2))
> >>grid.edit("myplot::xaxis::labels", y = unit(-1, "lines"))
> >
> >
> > then
> >
> >
> >>str(myplot$children$xaxis)
> >
> >
> > lists 'at' but not the 'labels'.
> >
> > yet if I do this then the labels are listed:
> >
> >
> >>xx <- xaxisGrob(name = "myX", at = 1:10)
> >>childNames(xx)
> >
> > [1] "major"  "ticks"  "labels"
> >
> >
> > 1. How do I get to labels in the first case?
>
>
> First, if the xaxisGrob has at=NULL then it calculates its tick-marks at
> drawing time (based on the viewport it gets drawn in).  So it does not
> store any labels (it doesn't know what they are until it gets drawn). If
> you specify a non-NULL 'at' then the axis creates labels.
>
> Second, grid grobs are standard R objects (copy-on-modify) so the object
> 'myplot' is not the same object that is being modified by the calls to
> grid.edit().  grid.edit() destructively modifies a copy of the grob that
> grid has stored on its display list;  you refer to the appropriate grob
> via its name (not via an R object).  By comparison, editGrob() takes a
> grob and returns a modified copy of the grob, for example ...

Just one clarification.  What is the scope of names?
In a recent post

  https://www.stat.math.ethz.ch/pipermail/r-help/2005-October/078653.html
  https://www.stat.math.ethz.ch/pipermail/r-help/2005-October/078656.html

it seems that one had to use absolute paths and that seems to be the
case here too where as mkondrin pointed out earlier in this thread

  https://www.stat.math.ethz.ch/pipermail/r-help/2005-October/078635.html

that get.grid("myplot::xaxis::labels")$label works.

Its not clear to me whether names:

- must be in absolute paths
- can be relative to some position under some conditions
- are global across all grob names in use and can be referred to directly
as long as they are unique among all grobs defined so far.

It seems absolute path names work but I am not sure whether the
other possibilities can work under some conditions too.

Also what the scope of viewports?   Absolute path? Relative path?
Global names?  Does it work the same way?  I think at least
absolute and relative paths are avalable here but could you confirm
my understanding and whether the situation is the same for
viewports and grobs?

(In the Windows, and analogously in UNIX, file system one can write
\usr\myname or position oneself to \usr using cd and then refer to
myname in a relative way:

cd \usr
dir myname
)

Thanks.

__
R-help@stat.math.ethz.ch 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] pdf plotting of splom

2005-10-04 Thread Deepayan Sarkar
On 10/3/05, Sebastian Luque <[EMAIL PROTECTED]> wrote:
> Sebastian Luque <[EMAIL PROTECTED]> wrote:
>
> [...]
>
> > pdf("splom-test.pdf", family = "Times", bg = "white")
>
> [...]
>
> Silly me, it occurred to me to check more carefully that bg argument,
> which does something different in xyplot (namely, give a background to the
> figure region, not the plot region as it seems to in this case).
>
> So, removing that bg argument was the answer.  Sorry.

This was a bug nonetheless (which shouldn't have had any effect unless
you are using a recent r-devel), which has been fixed in the r-devel
version of lattice.

Deepayan

__
R-help@stat.math.ethz.ch 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] Animation of Mandelbrot Set

2005-10-04 Thread Romain Francois
Nice !!

Le 04.10.2005 21:04, Tuszynski, Jaroslaw W. a écrit :

>Hi,
>
>I was playing with Mandelbrot sets and come up with the following code, I
>thought I would share: 
>
>library(fields)  # for tim.colors
>library(caTools) # for write.gif
>m = 400  # grid size
>C = complex( real=rep(seq(-1.8,0.6, length.out=m), each=m ), 
> imag=rep(seq(-1.2,1.2, length.out=m),  m ) )
>C = matrix(C,m,m)
>Z = 0
>X = array(0, c(m,m,20))
>for (k in 1:20) {
>  Z = Z^2+C
>  X[,,k] = exp(-abs(Z))
>}
>image(X[,,k], col=tim.colors(256)) # show final image in R
>write.gif(X, "Mandelbrot.gif", col=tim.colors(256), delay=100)
># drop "Mandelbrot.gif" file from current directory on any web brouser to
>see the animation
>
> Jarek 
>\ 
> Jarek Tuszynski, PhD.   o / \ 
> Science Applications International Corporation  <\__,|  
> (703) 676-4192   ">  \ 
> [EMAIL PROTECTED] `   \
>
>__
>R-help@stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>  
>
-- 
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
 ~ 
~~  Romain FRANCOIS - http://addictedtor.free.fr ~~
Etudiant  ISUP - CS3 - Industrie et Services   
~~http://www.isup.cicrp.jussieu.fr/  ~~
   Stagiaire INRIA Futurs - Equipe SELECT  
~~   http://www.inria.fr/recherche/equipes/select.fr.html~~
 ~ 

__
R-help@stat.math.ethz.ch 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] Joining Dataframes

2005-10-04 Thread Matt Goff

I am attempting to join several dataframes that summarize sampling effort  
for different samples into one large data.frame/table.
I have looked at the merge command, but have not been clever enough to  
figure out how to get it to do what I want.

A simplified example of what I am trying to do:

The dataframes I have look like this (they were generated using the table  
command)

species1.effort
site1   site2   site3
date1 55   5
date2 45   5
date3 45   5

species2.effort
site1   site2   site3
date1 786
date3 878
date4 888

I would like to join these into a table that looks something like this:

Effort
 sp1.site1  sp1.site2  sp1.site3  sp2.site1  sp2.site2   
sp2.site2
date1 5   5  5 7  
86
date2 4   5  5NA   
NA NA
date3 4   5   5   8  
7 8
date4 NA   NANA 88  
8


I have many more dates and species, but I assume whatever method works for  
this small example, would work for larger cases.

Thanks,
Matt Goff

__
R-help@stat.math.ethz.ch 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] missing handling

2005-10-04 Thread Prof Brian Ripley
On Tue, 4 Oct 2005, Weiwei Shi wrote:

> Hi, Jim:
> I tried your code and get the following error:
> trn1<-read.table('trn1.svm', header=F, na.string='.', sep='|')
> Med<-apply(trn1, 2, median, na.rm=T)
> Ind<-which(is.na(trn1), arr.ind=T)
> trn1[Ind]<-Med[Ind[,'col']]
> Error in "[<-.data.frame"(`*tmp*`, Ind, value = c(1.00802124455,
> 1.00802124455, :
> only logical matrix subscripts are allowed in replacement
>
>
> I cannot figure out why.

Read the help for "[<-.data.frame" to be told the answer.

A data frame (as given by read.table) is not a matrix, as the example 
presumably was.  Indexing whole matrices at once is efficient, but it 
hides loops for data frames.

You will not do better than looping over columns for a data frame, but you 
certainly do not need to loop over rows which is very inefficient. 
Something like

trn2 <- trn1
for(i in names(trn2)) {
 Med <- median(trn2[[i]], na.rm = TRUE)
 trn2[i, is.na(trn2[[i]])] <- Med
}


>
> Thanks for help,
>
> On 9/27/05, jim holtman <[EMAIL PROTECTED]> wrote:
>>
>> Use 'which(...arr.ind=T)'
>> > x.1
>> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
>> [1,] 6 10 3 4 10 7 9 8 4 10
>> [2,] 8 7 4 7 4 8 3 NA 3 4
>> [3,] 7 7 10 10 3 5 3 2 2 2
>> [4,] 3 4 5 10 10 2 6 9 4 5
>> [5,] 3 5 9 5 6 NA 3 NA 6 7
>> [6,] 9 6 10 5 10 4 2 10 NA 5
>> [7,] 5 2 5 10 3 7 6 4 6 8
>> [8,] 2 6 1 8 9 2 7 8 3 8
>> [9,] 9 1 4 9 8 10 2 NA 1 7
>> [10,] 2 4 8 7 NA 4 3 NA 5 5
>>> x.4
>> [1] 5.5 5.5 5.0 7.5 8.0 5.0 3.0 8.0 4.0 6.0
>>> Med <- apply(x.1, 2, median, na.rm=T) # get median
>>> Ind <- which(is.na(x.1), arr.ind=T) # determine which are NA
>>> x.1[Ind] <- Med[Ind[,'col']] # replace with median
>>> x.1
>> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
>> [1,] 6 10 3 4 10 7 9 8 4 10
>> [2,] 8 7 4 7 4 8 3 8 3 4
>> [3,] 7 7 10 10 3 5 3 2 2 2
>> [4,] 3 4 5 10 10 2 6 9 4 5
>> [5,] 3 5 9 5 6 5 3 8 6 7
>> [6,] 9 6 10 5 10 4 2 10 4 5
>> [7,] 5 2 5 10 3 7 6 4 6 8
>> [8,] 2 6 1 8 9 2 7 8 3 8
>> [9,] 9 1 4 9 8 10 2 8 1 7
>> [10,] 2 4 8 7 8 4 3 8 5 5
>>>
>>
>>
>>  On 9/27/05, Weiwei Shi <[EMAIL PROTECTED]> wrote:
>>
>>> Hi,
>>> I have the following codes to replace missing using median, assuming
>>> missing
>>> only occurs on continuous variables:
>>>
>>> trn1<-read.table('trn1.fv', header=F, na.string='.', sep='|')
>>>
>>> # median
>>> m.trn1<-sapply(1:ncol(trn1), function(i) median(trn1[,i], na.rm=T))
>>>
>>> #replace
>>> trn2<-trn1
>>> for (each in 1:nrow(trn1)){
>>> index.missing=which(is.na(trn1[each,]))
>>> trn2[each,]<-replace(trn1[each,], index.missing, m.trn1[index.missing])
>>> }
>>>
>>>
>>> Anyone can suggest some ways to improve it since replacing 10 takes 1.5sec:
 system.time(for (each in 1:10){index.missing=which(is.na
>>> (trn1[each,]));
>>> trn2[each,]<-replace(trn1[each,], index.missing, m.trn1[index.missing
>>> ]);})
>>> [1] 1.53 0.00 1.53 0.00 0.00
>>>
>>>
>>> Another general question is
>>> are there some packages in R doing missing handling?
>>>
>>> Thanks,
>>>
>>> --
>>> Weiwei Shi, Ph.D
>>>
>>> "Did you always know?"
>>> "No, I did not. But I believed..."
>>> ---Matrix III
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> __
>>> R-help@stat.math.ethz.ch mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide!
>>> http://www.R-project.org/posting-guide.html
>>>
>>
>>
>>
>> --
>> Jim Holtman
>> Cincinnati, OH
>> +1 513 247 0281
>>
>> What the problem you are trying to solve?
>
>
>
>
> --
> Weiwei Shi, Ph.D
>
> "Did you always know?"
> "No, I did not. But I believed..."
> ---Matrix III
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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-help@stat.math.ethz.ch 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] grob questions

2005-10-04 Thread Paul Murrell
Hi


Gabor Grothendieck wrote:
> If I run the following example from:
> http://www.stat.auckland.ac.nz/~paul/grid/doc/grobs.pdf
> 
> 
>>grid.newpage()
>>pushViewport(viewport(w = 0.5, h = 0.5))
>>myplot <- gTree(name = "myplot", children = gList(rectGrob(name = "box",
> 
> + gp = gpar(col = "grey")), xaxisGrob(name = "xaxis")))
> 
>>grid.draw(myplot)
>>grid.edit("myplot::xaxis", at = 1:10/11)
>>grid.edit("myplot::xaxis::labels", label = round(1:10/11, 2))
>>grid.edit("myplot::xaxis::labels", y = unit(-1, "lines"))
> 
> 
> then
> 
> 
>>str(myplot$children$xaxis)
> 
> 
> lists 'at' but not the 'labels'.
> 
> yet if I do this then the labels are listed:
> 
> 
>>xx <- xaxisGrob(name = "myX", at = 1:10)
>>childNames(xx)
> 
> [1] "major"  "ticks"  "labels"
> 
> 
> 1. How do I get to labels in the first case?


First, if the xaxisGrob has at=NULL then it calculates its tick-marks at 
drawing time (based on the viewport it gets drawn in).  So it does not 
store any labels (it doesn't know what they are until it gets drawn). If 
you specify a non-NULL 'at' then the axis creates labels.

Second, grid grobs are standard R objects (copy-on-modify) so the object 
'myplot' is not the same object that is being modified by the calls to 
grid.edit().  grid.edit() destructively modifies a copy of the grob that 
grid has stored on its display list;  you refer to the appropriate grob 
via its name (not via an R object).  By comparison, editGrob() takes a 
grob and returns a modified copy of the grob, for example ...

myplot <- editGrob(myplot, at = 1:10/11)

The naming scheme for grid functions is:  grid.<*>() functions for 
producing or working with graphical *output* (drawing grobs or working 
with grobs that have been drawn) and <*>Grob() functions for working 
(off-screen) with grobs.


> 2. Is there a better construct than myplot$children$xaxis?


The getGrob(), editGrob(), etc functions for working with grobs (and 
sub-grobs) off-screen and grid.get(), grid.edit(), etc for working with 
graphical output.

"Recent changes in grid graphics". R News, 5(1):12-20, May 2005 
describes this some more.

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/

__
R-help@stat.math.ethz.ch 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] Animation of Mandelbrot Set

2005-10-04 Thread Tuszynski, Jaroslaw W.
Hi,

I was playing with Mandelbrot sets and come up with the following code, I
thought I would share: 

library(fields)  # for tim.colors
library(caTools) # for write.gif
m = 400  # grid size
C = complex( real=rep(seq(-1.8,0.6, length.out=m), each=m ), 
 imag=rep(seq(-1.2,1.2, length.out=m),  m ) )
C = matrix(C,m,m)
Z = 0
X = array(0, c(m,m,20))
for (k in 1:20) {
  Z = Z^2+C
  X[,,k] = exp(-abs(Z))
}
image(X[,,k], col=tim.colors(256)) # show final image in R
write.gif(X, "Mandelbrot.gif", col=tim.colors(256), delay=100)
# drop "Mandelbrot.gif" file from current directory on any web brouser to
see the animation

 Jarek 
\ 
 Jarek Tuszynski, PhD.   o / \ 
 Science Applications International Corporation  <\__,|  
 (703) 676-4192   ">  \ 
 [EMAIL PROTECTED] `   \

__
R-help@stat.math.ethz.ch 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] Cours***Seattle***R/Splus Advanced Programming, November 2005

2005-10-04 Thread elvis
XSolutions Corp (www.xlsolutions-corp.com) is proud to announce
our  November, 2005 "Advanced R/Splus programming" in Seattle

www.xlsolutions-corp.com/Radv.htm

* Seattle  November 10th-11th, 2005

Ask for group discount and reserve your seat Now  (payment due after
the class)

Email Sue Turner:  [EMAIL PROTECTED]

Course Outline:

- Overview of R/S fundamentals: Syntax and Semantics
- Class and Inheritance in R/S-Plus
- Concepts, Construction and good use of language objects
- Coercion and efficiency
- Object-oriented programming in R and S-Plus
- Advanced manipulation tools: Parse, Deparse, Substitute, etc.
- How to fully take advantage of Vectorization
- Generic and Method Functions; S4 (S-Plus 6)
- Search path, databases and frames Visibility
- Working with large objects
- Handling Properly Recursion and iterative calculations
- Managing loops; For (S-Plus) and for() loops
- Consequences of Lazy Evaluation
- Efficient Code practices for large computations
- Memory management and Resource monitoring
- Writing R/S-Plus functions to call compiled code
- Writing and debugging compiled code for R/S-Plus system
- Connecting R/S-Plus to External Data Sources
- Understanding the structure of model fitting functions in R/S-Plus
- Designing and Packaging efficiently a new model function

It'll also deal with lots of S-Plus efficiency issues and any special
topics
from participants is welcome.

Please let us know if you and your colleagues are interested in this
class
to take advantage of group discount.  Register now to secure your seat
in this
course!

Cheers,

Elvis Miller, PhD
Manager Training.
XLSolutions Corporation
206 686 1578
www.xlsolutions-corp.com

__
R-help@stat.math.ethz.ch 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] missing handling

2005-10-04 Thread Weiwei Shi
Hi, Jim:
I tried your code and get the following error:
trn1<-read.table('trn1.svm', header=F, na.string='.', sep='|')
Med<-apply(trn1, 2, median, na.rm=T)
Ind<-which(is.na(trn1), arr.ind=T)
trn1[Ind]<-Med[Ind[,'col']]
Error in "[<-.data.frame"(`*tmp*`, Ind, value = c(1.00802124455,
1.00802124455, :
only logical matrix subscripts are allowed in replacement


I cannot figure out why.

Thanks for help,

On 9/27/05, jim holtman <[EMAIL PROTECTED]> wrote:
>
> Use 'which(...arr.ind=T)'
>  > x.1
> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
> [1,] 6 10 3 4 10 7 9 8 4 10
> [2,] 8 7 4 7 4 8 3 NA 3 4
> [3,] 7 7 10 10 3 5 3 2 2 2
> [4,] 3 4 5 10 10 2 6 9 4 5
> [5,] 3 5 9 5 6 NA 3 NA 6 7
> [6,] 9 6 10 5 10 4 2 10 NA 5
> [7,] 5 2 5 10 3 7 6 4 6 8
> [8,] 2 6 1 8 9 2 7 8 3 8
> [9,] 9 1 4 9 8 10 2 NA 1 7
> [10,] 2 4 8 7 NA 4 3 NA 5 5
> > x.4
> [1] 5.5 5.5 5.0 7.5 8.0 5.0 3.0 8.0 4.0 6.0
> > Med <- apply(x.1, 2, median, na.rm=T) # get median
> > Ind <- which(is.na(x.1), arr.ind=T) # determine which are NA
> > x.1[Ind] <- Med[Ind[,'col']] # replace with median
> > x.1
> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
> [1,] 6 10 3 4 10 7 9 8 4 10
> [2,] 8 7 4 7 4 8 3 8 3 4
> [3,] 7 7 10 10 3 5 3 2 2 2
> [4,] 3 4 5 10 10 2 6 9 4 5
> [5,] 3 5 9 5 6 5 3 8 6 7
> [6,] 9 6 10 5 10 4 2 10 4 5
> [7,] 5 2 5 10 3 7 6 4 6 8
> [8,] 2 6 1 8 9 2 7 8 3 8
> [9,] 9 1 4 9 8 10 2 8 1 7
> [10,] 2 4 8 7 8 4 3 8 5 5
> >
>
>
>  On 9/27/05, Weiwei Shi <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> > I have the following codes to replace missing using median, assuming
> > missing
> > only occurs on continuous variables:
> >
> > trn1<-read.table('trn1.fv', header=F, na.string='.', sep='|')
> >
> > # median
> > m.trn1<-sapply(1:ncol(trn1), function(i) median(trn1[,i], na.rm=T))
> >
> > #replace
> > trn2<-trn1
> > for (each in 1:nrow(trn1)){
> > index.missing=which(is.na(trn1[each,]))
> > trn2[each,]<-replace(trn1[each,], index.missing, m.trn1[index.missing])
> > }
> >
> >
> > Anyone can suggest some ways to improve it since replacing 10 takes 1.5sec:
> > > system.time(for (each in 1:10){index.missing=which(is.na
> > (trn1[each,]));
> > trn2[each,]<-replace(trn1[each,], index.missing, m.trn1[index.missing
> > ]);})
> > [1] 1.53 0.00 1.53 0.00 0.00
> >
> >
> > Another general question is
> > are there some packages in R doing missing handling?
> >
> > Thanks,
> >
> > --
> > Weiwei Shi, Ph.D
> >
> > "Did you always know?"
> > "No, I did not. But I believed..."
> > ---Matrix III
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> >
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 247 0281
>
> What the problem you are trying to solve?




--
Weiwei Shi, Ph.D

"Did you always know?"
"No, I did not. But I believed..."
---Matrix III

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Help ...

2005-10-04 Thread Liaw, Andy
It's because you've asked R to create an object of size 5 * 4 * 12488 *
1000 * 8 bytes, or 1905.5 MB, and R failed to get that much memory from
the operating system.

Andy

> From: Gao Fay
> 
> Hi there,
> 
> When I run the following, why does it give a error like that?
> 
> > res2<-array(0,c(5,4,12488,1000))
> Error: cannot allocate vector of size 1951250 Kb
> 
> Thank you for helping me.
> Fay
> 
>

__
R-help@stat.math.ethz.ch 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] Help ...

2005-10-04 Thread Gao Fay

Hi there,

When I run the following, why does it give a error like that?


res2<-array(0,c(5,4,12488,1000))

Error: cannot allocate vector of size 1951250 Kb

Thank you for helping me.
Fay

__
R-help@stat.math.ethz.ch 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] Sending messages twice to R-help {was ... lmList error ...}

2005-10-04 Thread Hai Lin
Hello Martin and R users,

Thanks for your advice. Sorry disturbing some of you.


Kevin

--- Martin Maechler <[EMAIL PROTECTED]>
wrote:

> > "Hai" == Hai Lin <[EMAIL PROTECTED]>
> > on Tue, 4 Oct 2005 08:26:31 -0700 (PDT)
> writes:
> 
> Hai> It seems a problem sending this out. 
> 
> why do you think so??
> It was sent out to more than 3000 potential readers
> alright.
> 
> Hai> I am resending it.
> 
> which is not really polite to all the r-help
> readers...
> 
> and will probably rather decrease than increase the
> probability
> that it gets answered.
> 
> Hai> Hello Rs,
> 
>   {now who will think she / he  was meant by 'R' ?
> ;-) }
> 
> Note that you didn't follow the posting guide at
> all,
> and this is the most probable reason your e-mail
> wasn't
> answered.
> 
> Regards,
> Martin Maechler
> 
> Appended at the very end of every R-help posting and
> hence
> yours, too:
> 
> Hai> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
> 
>

__
R-help@stat.math.ethz.ch 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] Getting eps into Word documents.

2005-10-04 Thread Marc Schwartz (via MN)
On Tue, 2005-10-04 at 08:38 -0500, Robert Baer wrote:
> > > On 03-Oct-05 Marc Schwartz (via MN) wrote:
> > > > On Mon, 2005-10-03 at 16:31 -0300, Rolf Turner wrote:
> > > >> A student in one of my courses has asked me about getting R graphics
> > > >> output (under Linux) into a Word document.  I.e. she wants to do her
> > > >> R thing under Linux, but then do her word processing using Word.
> --snip--
> > > > So use something like the following:
> > > >
> > > >
> > > > postscript("RPlot.eps", height = 4, width = 4,
> > > >horizontal = FALSE, onefile = FALSE,
> > > >paper = "special")
> > > >
> > > > plot(1:5)
> > > >
> > > > dev.off()
> > > >
> > > >
> > > > You can then import the .eps file into Word or most other such
> > > > applications that can import encapsulated postscript files.
> 
> -snip
> > > > More information is available from MS here:
> > > >
> > > > http://support.microsoft.com/?kbid=290362
> > > >
> > > > HTH,
> > > >
> > > > Marc Schwartz
> --snip---
> > > b) It won't work anyway if printed to a non-PostScript printer.
> >
> > True, which is the case irrespective of Word/Windows. If you don't have
> > a PS printer locally or accessible via network, you can always install a
> > PS printer driver and print to a file, which can then be printed by a
> > third party if required.
> >
> Well, as a lowly Windows and Office user, I most often right click on R
> grahics, cut to clipboard, and paste into Word.   So one possiblility is for
> the student to install R on her own machine (Windows or Mac?).
> 
> But I just tried Marc's suggestion, and it looks VERY VIABLE to me.  I
> generated the graph from his code snippet and used "Insert picture from
> file" in Word 2003 to place the graphic in a Word document.  I then tried
> printing on both an HP 4100 TN laserjet and an HP 960c deskjet.  The image
> printed perfectly on both printers with crisp lines and text that apprear to
> be vector-based not degraded bitmapped representations.  Certainly worth the
> student trying.


Glad to hear that worked for you.

I do think that the majority of problems with importing EPS files from R
into other applications (Word, Powerpoint, Writer, Impress, etc.) are
due to not properly configuring the postscript() arguments that are on
the help page. 

I should also note that beyond plots, I use this same approach for
putting LaTeX tables into these documents as well. There are times where
I need create one or more nicely formatted tables for inclusion in
another document, to then be used by someone else.

I generate the LaTeX preamble, document and table code using R, then
run:

  latex FileName.tex
  dvips -E FileName -o FileName.ps

where the '-E' option to dvips attempts to create an EPS output file
with a tight bounding box. The result is a single EPS file with the
table (much like the plot example) ready for import.

I had been using 'epstool' to create the image preview, but now that
OO.org 2.0 has included this automatically upon import (as do the latest
versions of Word), this step is no longer required.

In this way, I can use R to create reproducible and publication ready
tables for use by others in their documents, in situations where they
are not (or cannot) use LaTeX for the entire document.

HTH,

Marc

__
R-help@stat.math.ethz.ch 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] User error (was arima.sim bug?)

2005-10-04 Thread Rolf Turner

Brian Ripley wrote (in response to S. E. Kemp):

> > I am using the arima.sim function to generate some AR time series.
> > However, the function does not seem to produce exactly the same time
> > series when I specify the innov parameter. For example

> > Given the fact that I have provided the innovations shouldn't the time
> > series be exactly the same?
>
> No.  Hint: where does the randomness for the burn-in come from?

What then, pray tell, is the point of having the
``innov'' argument at all?

cheers,

Rolf Turner
[EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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] help with loading National Comorbidity Survey

2005-10-04 Thread Thomas Lumley
On Sat, 1 Oct 2005, Jim Hurd wrote:
>
> Which provides data in DTA  (STATA), XPT (SAS), and POR (SPSS) formats all
> of which I have tried to read with the foreign package but I am not able to
> load any of them. I have 2 gb of RAM, but R crashes when the memory gets
> just over 1 GB. I am using Windows version 2.1.1. The size of the DTA file
> is 48 MB; the xpt file is 188 MB.
>

If you mean the NCS 1 data file from that link (da06694-0001.dta) then I 
don't have this problem.

I have been able to load in the .dta file under Windows on a computer with 
1Gb of RAM.  The maximum memory use was about 350Mb.  It was very slow -- 
about half an hour.  This is because the processing of missing values and 
of factor levels is very inefficient in read.dta when dealing with very 
wide data frames. It makes calls to [.data.frame, [<-.data.frame, etc, for 
each column and so the time is probably quadratic in the number of 
columns.

The call to .External that does the actual reading took less than 1% of 
the time. If you only want a hundred or so of the 3000 variables it may be 
worth just using that .External() call to read the data, then subset it 
and then work out how to apply the factor levels and so on.

read.dta clearly needs a different algorithm to handle very wide data sets 
efficiently.

-thomas

__
R-help@stat.math.ethz.ch 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] Dots in function names

2005-10-04 Thread Rolf Turner

Peter Dalgaard wrote:

>
> Well, come the S4 revolution and dots will cause trouble no more...
>

Yes but an infinite number of other things will cause infinitely more
trouble. God save us from S4.

cheers,

Rolf Turner

__
R-help@stat.math.ethz.ch 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] Select varying LS digits in long numbers?

2005-10-04 Thread Paul Johnson
Maybe this is just the brute force you want to avoid, but it works to 
coerce the integer into a string, and then back to a number.  Could 
reduce number of lines by nesting functions, of course.

y <- 1234131431
n <- 3
ychar <- as.character(y)
ydigits <- nchar(ychar)
result <- as.numeric ( substr(ychar, ydigits- n +1, ydigits) )

pj

(Ted Harding) wrote:
> Hi Folks,
> 
> I'm trying to find a neat solution to an apparently simple
> problem, but one which turns out to be a bit more intricate
> and tricky than one might expect.
> 
> Suppose I have numbers given to a large number of digits.
> For example
> 
>   1234567021
> 
> where (though I don't know this beforehand) only the last
> 3 digits will be varying (and all 3 will vary).
> 
> What I want is, give a vector x of such numbers, to extract
> the minimal set of final digits which will include the varying
> digits (i.e. in this case the last 3 digits). And there may be
> a decimal point somewhere along the line (though again I won't
> know where, nor whether).
> 



-- 
Paul E. Johnson   email: [EMAIL PROTECTED]
Dept. of Political Sciencehttp://lark.cc.ku.edu/~pauljohn
1541 Lilac Lane, Rm 504
University of Kansas  Office: (785) 864-9086
Lawrence, Kansas 66044-3177   FAX: (785) 864-5700

__
R-help@stat.math.ethz.ch 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] Problem with Matrix package

2005-10-04 Thread Johan Sandblom
Hi, if it is not essential to build the package by yourselves, why not use
the Debian package r-cran-matrix instead.

HTH, Johan Sandblom

2005/10/4, Jari Haukka <[EMAIL PROTECTED]>:
> Hello All,
>
> While trying to install Matrix package following error message came out:
>
>
> /usr/bin/ld: cannot find -lblas-3
> collect2: ld returned 1 exit status
> make: *** [Matrix.so] Error 1
> ERROR: compilation failed for package 'Matrix'
> ** Removing '/usr/lib/R/library/Matrix'
> ** Restoring previous '/usr/lib/R/library/Matrix'
>
>
> It seems that someting is missing. Have anybody idea where we can find this
> missing piece?
> We have Debian Linux.
>
>
> Jari Haukka
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>


--
Johan Sandblom  N8, MRC, Karolinska sjh
t +46851776108  17176 Stockholm
m +46735521477  Sweden
"What is wanted is not the will to believe, but the
will to find out, which is the exact opposite"
- Bertrand Russell

__
R-help@stat.math.ethz.ch 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] sampling vectors

2005-10-04 Thread Eric Pante
Hi Dan,

I just tried your code with long vectors, and the sampling stops to be 
random. Do you see any reason why this is ?

examples:

ex = c(30,13,9,8,7,7,7,6,6,5,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1)

 > vectorSample(ex)
  [1]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  3  1  7  
6
[24]  4  2 75
 > vectorSample(ex)
  [1]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  2  1  1  1  2 
11
[24]  7  8 67
 >
 > vectorSample(ex)
  [1]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  
1
[24]  1  6 87
 > vectorSample(ex)
  [1]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  2  1  1  1  1  1  2  
3
[24]  1  4 85
 > vectorSample(ex)
  [1]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1 
19
[24] 16 42 18
 > vectorSample(ex)
  [1]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  2  1  3  5  4  4 
17
[24]  2 53 10
 > vectorSample(ex)
  [1]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  3  
5
[24]  3 11 74
 > vectorSample(ex)
  [1]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  3  3  1  2  
3
[24] 21 23 43
 > vectorSample(ex)
  [1]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  5  
9
[24] 18 20 44
 > vectorSample(ex)
  [1]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  2  1  3  6 
14
[24]  8  6 59


On Oct 4, 2005, at 12:02 PM, Daniel Nordlund wrote:

>> -Original Message-
>> From: [EMAIL PROTECTED] 
>> [mailto:[EMAIL PROTECTED]
>> On Behalf Of ecatchpole
>> Sent: Monday, October 03, 2005 11:57 PM
>> To: Eric Pante
>> Cc: r-help@stat.math.ethz.ch
>> Subject: Re: [R] sampling vectors
>>
>> Eric,
>>
>> If you want samples of size 3 from 0:50, with sum==50, this seems to 
>> do
>> the job (with apologies to those who really know how to program in R):
>>
>> tot <- 50
>> ii <- 0
>> aa <- list()
>> for(i in 0:tot){
>> for(j in 0:(tot-i)){
>>k <- tot-i-j
>>ii <- ii+1
>>aa[[ii]] <- list(i=i,j=j,k=k)
>> }
>> }
>>
>> aa[sample(ii, 4)] # for a sample of 4.
>>
>> If you want a sample of size n from x[1],...x[N], such that the sample
>> sum is T, then that is much trickier!
>>
>> Ted.
>>
>> On 04/10/05 07:31,  Eric Pante wrote,:
>>> Hello Listers,
>>>
>>> I am trying to sample a vector to create a new one of sample length,
>>> witha  sum equal to the sum of the initial vector:
>>>
>>> initial = 10, 30, 10 (sum=50)
>>> sample example = 5, 35, 10 (sum=50) or 25, 15, 10  (sum=50), etc ...
>>>
>>> My problem is to control the sum, so it stays constant.
>>> Any suggestions would be very helpful !
>>>
>>> Thank you in advance,
>>> Eric
>>>
>
> Eric,
>
> Here is another solution, which allows vectors of different lengths 
> and sums.
>
> vectorSample <- function(vec) {
>   tot<-sum(vec)
>   Len<-length(vec)
>   v < -rep(0,Len)
>   for(i in Len:2) {
> UL <- tot - sum(v) - i + 1
> v[i]<-sample(1:UL,1)
> }
>   v[1] <- tot - sum(v)
>   v
>   }
>
>  vectorSample( c(10,30,10) )
>
> Hope this helps,
>
> Dan Nordlund
> Bothell, WA
>
>
>
>
Eric Pante
---
Graduate Student in Marine Biology
Grice Marine Laboratory
205 Fort Johnson Road, Charleston SC 29412
---

"On ne force pas la curiosite, on l'eveille ..."
Daniel Pennac

[[alternative text/enriched version deleted]]

__
R-help@stat.math.ethz.ch 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] heatmap ordered list

2005-10-04 Thread Martin Maechler
> "Andrea" == Andrea Zangrando <[EMAIL PROTECTED]>
> on Tue, 04 Oct 2005 15:00:27 +0200 writes:

Andrea> Hi,
Andrea> another problem on heatmaps... after generating the graph with

Andrea> myBlRd <- colorRampPalette(c("blue", "red"))
Andrea> heatmap(dataHeat[Top100, ], col=myBlRd(15))

Andrea> i need to retrieve the row names' list ordered by the dendrogram.
Andrea> I tried with   "rownames(data)[Top100]"   but the list is not 
ordered 
Andrea> (as i can see in the generated picture). Any tips?

Main tip :  do read the help page for functions you are using.
2nd  tip :  There's a section called  "Value:"
3rd  tip :  hence use
r <- heatmap(...) ## and work with 'r'

Regards,
Martin Maechler, ETH Zurich

__
R-help@stat.math.ethz.ch 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] Sending messages twice to R-help {was ... lmList error ...}

2005-10-04 Thread Martin Maechler
> "Hai" == Hai Lin <[EMAIL PROTECTED]>
> on Tue, 4 Oct 2005 08:26:31 -0700 (PDT) writes:

Hai> It seems a problem sending this out. 

why do you think so??
It was sent out to more than 3000 potential readers alright.

Hai> I am resending it.

which is not really polite to all the r-help readers...

and will probably rather decrease than increase the probability
that it gets answered.

Hai> Hello Rs,

  {now who will think she / he  was meant by 'R' ? ;-) }

Note that you didn't follow the posting guide at all,
and this is the most probable reason your e-mail wasn't
answered.

Regards,
Martin Maechler

Appended at the very end of every R-help posting and hence
yours, too:

Hai> PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch 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] boxplot statistics

2005-10-04 Thread Thomas Lumley
On Tue, 4 Oct 2005, Karin Lagesen wrote:
>
> First, how does boxplot determine the size of the box? And is the line
> inside the box the mean or the median (or something completely
> different?) And how does it determine how long out the whiskers should
> go?

Part of the problem is that there are lots of different definitions of the 
quartiles (quantile() has 9 of them). If the number of observations is one 
more than a multiple of 4 then all the definitions agree, otherwise they 
are slightly different.

For the case where the number of observations is one more than a multiple 
of 4 the line in the middle is the median, the ends of the box are the 
upper and lower quartiles, and the whiskers extend to the furthest point 
that is within 1.5 box lengths from the end of the box.

When the number of observations is not one more than a multiple of four 
this is all still true, but you have to be careful about which definition 
of "quartile" you mean, for which you can read either the book referenced on 
the help page, or the code.

-thomas

__
R-help@stat.math.ethz.ch 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] Repeated crashes on Mac

2005-10-04 Thread Martin Henry H. Stevens

Hi Folks,
R v. 2.1.1, Mac OS 10.4.2

I am just know getting repeated crashes when I try to edit script  
files. I have the base package plus odesolve open.
I have rebooted and still have problems. below I append the error  
messages from the R console on the crash and also attached a single   
text file containing  two different Crash reports generated  
automatically by some application in the OS (Tiger 10.4.2) for  
reporting to Apple.


From the R console:
2005-10-04 11:26:11.080 R[534] *** -[NSCFDictionary set]: selector  
not recognized [self = 0x6eca1d0]
2005-10-04 11:26:11.080 R[534] *** -[NSCFDictionary set]: selector  
not recognized [self = 0x6eca1d0]
2005-10-04 11:26:11.378 R[534] *** -[NSCFDictionary set]: selector  
not recognized [self = 0x6eca1d0]
2005-10-04 11:26:11.378 R[534] *** -[NSCFDictionary set]: selector  
not recognized [self = 0x6eca1d0]
2005-10-04 11:26:11.506 R[534] *** -[NSCFDictionary set]: selector  
not recognized [self = 0x6eca1d0]
2005-10-04 11:26:11.506 R[534] *** -[NSCFDictionary set]: selector  
not recognized [self = 0x6eca1d0]
2005-10-04 11:26:11.658 R[534] *** -[NSCFDictionary set]: selector  
not recognized [self = 0x6eca1d0]
2005-10-04 11:26:11.658 R[534] *** -[NSCFDictionary set]: selector  
not recognized [self = 0x6eca1d0]
2005-10-04 11:26:11.795 R[534] *** -[NSCFDictionary set]: selector  
not recognized [self = 0x6eca1d0]
2005-10-04 11:26:11.795 R[534] *** -[NSCFDictionary set]: selector  
not recognized [self = 0x6eca1d0]
2005-10-04 11:26:13.454 R[534] *** -[NSCFDictionary set]: selector  
not recognized [self = 0x6eca1d0]
2005-10-04 11:26:13.454 R[534] *** -[NSCFDictionary set]: selector  
not recognized [self = 0x6eca1d0]
2005-10-04 11:26:14.574 R[534] *** -[NSCFDictionary set]: selector  
not recognized [self = 0x6eca1d0]
2005-10-04 11:26:14.574 R[534] *** -[NSCFDictionary set]: selector  
not recognized [self = 0x6eca1d0]
2005-10-04 11:26:15.531 R[534] *** -[NSCFDictionary set]: selector  
not recognized [self = 0x6eca1d0]
2005-10-04 11:26:15.531 R[534] *** -[NSCFDictionary set]: selector  
not recognized [self = 0x6eca1d0]

>

Date/Time:  2005-10-04 10:56:45.003 -0400
OS Version: 10.4.2 (Build 8C46)
Report Version: 3

Command: R
Path:/Applications/R.app/Contents/MacOS/R
Parent:  WindowServer [71]

Version: 1.12 (1622)

PID:8483
Thread: 0

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:  KERN_PROTECTION_FAILURE (0x0002) at 0x0020

Thread 0 Crashed:
0   <<>>0xfffeff18 objc_msgSend_rtp + 24
1   com.apple.AppKit0x936ef5c4 -[NSCalibratedRGBColor isEqual:] + 80
2   com.apple.AppKit0x93679170 -[NSAttributeDictionary 
newWithKey:object:] + 364
3   com.apple.Foundation0x9288c38c -[NSConcreteMutableAttributedString 
addAttribute:value:range:] + 252
4   com.apple.AppKit0x936eeddc -[NSConcreteTextStorage 
addAttribute:value:range:] + 88
5   org.R-project.R 0x0002a9fc -[REditorTextStorage 
addAttribute:value:range:] + 48 (crt.c:300)
6   org.R-project.R 0x00028f4c -[RDocumentWinCtrl 
updateSyntaxHighlightingForRange:] + 1232 (crt.c:300)
7   org.R-project.R 0x00029700 -[RDocumentWinCtrl 
textStorageDidProcessEditing:] + 132 (crt.c:300)
8   com.apple.Foundation0x92882878 _nsnote_callback + 180
9   com.apple.CoreFoundation0x907726a0 __CFXNotificationPost + 368
10  com.apple.CoreFoundation0x9076a7c4 _CFXNotificationPostNotification + 
684
11  com.apple.Foundation0x9286cc80 -[NSNotificationCenter 
postNotificationName:object:userInfo:] + 92
12  com.apple.AppKit0x936fb8c8 -[NSTextStorage processEditing] + 148
13  com.apple.AppKit0x93698288 -[NSTextStorage 
edited:range:changeInLength:] + 284
14  org.R-project.R 0x0002a8fc -[REditorTextStorage 
replaceCharactersInRange:withString:] + 248 (crt.c:300)
15  com.apple.AppKit0x9376e968 -[NSTextView(NSPrivate) 
_userReplaceRange:withString:] + 340
16  com.apple.AppKit0x9376e560 _NSDoUserReplaceForCharRange + 444
17  com.apple.AppKit0x9376de1c -[NSTextView(NSKeyBindingCommands) 
deleteBackward:] + 512
18  com.apple.AppKit0x93753604 -[NSTextView doCommandBySelector:] + 
212
19  com.apple.AppKit0x93706e04 
-[NSKeyBindingManager(NSKeyBindingManager_MultiClients) 
interpretEventAsCommand:forClient:] + 1700
20  com.apple.AppKit0x93705500 -[NSTSMInputContext 
interpretKeyEvents:] + 1104
21  com.apple.AppKit0x937048e0 -[NSView interpretKeyEvents:] + 64
22  com.apple.AppKit0x93704734 -[NSTextView keyDown:] + 756
23  org.R-project.R 0x0002dba0 -[RTextView keyDown:] + 180 
(crt.c:300)
24  com.apple.AppKit0x936800d8 -[NSWindow sendEvent:] + 6424
25  com.apple.AppKit0x93628bfc -[NSApplication sendEvent:] + 4172
26  org.R-project.R 0x5990 -[RController handleReadConsole:] + 
84 (crt.c:300)
27  org.R-project.R 0x

[R] lmList error message

2005-10-04 Thread Hai Lin
It seems a problem sending this out. I am resending
it.

Hello Rs,

After running lmList, I've gotten an error message
"Error in lm.fit(x, y, offset = offset, singular.ok =
singular.ok, ...) : NA/NaN/Inf in foreign function
call (arg 4)"  I'm not able to understand what it
means.  Could anyone help me with it?  

Thanks all in advance.

Kevin 

### commands and output ###

##
lm.S <- lmList(Log2CM ~~ Strain | reporterID,
data=data.tall, pool=F)

> length(levels(data.tall$reporterID))
[1] 6513

> levels(data.tall$Strain)
[1] "WT" "KO"

>datatall[1:20,]
Log2CM reporterID Strain
3.430192973 IMAGE:1260690 KO
6.420003752 IMAGE:481703 KO
-2.135514971 IMAGE:1432976 KO
-2.321928095 IMAGE:959862 KO
1.370837695 IMAGE:1038124 KO
1.063264893 IMAGE:519411 KO
2.378511623 IMAGE:2101947 KO
-0.688055994 IMAGE:1260374 KO
1.389946518 IMAGE:522799 KO
-0.565199246 IMAGE:480815 KO
0.979962247 IMAGE:1430827 KO
-2.273018494 IMAGE:658095 KO
1.581642142 IMAGE:314290 KO
-0.857980995 IMAGE:1478681 KO
-1.894506871 IMAGE:1260277 KO
-0.804869659 IMAGE:480596 KO
-1.451988635 IMAGE:652861 KO
6.208242769 IMAGE:1038010 KO
5.951626379 IMAGE:519074 KO
-0.237394585 IMAGE:960834 KO

__
R-help@stat.math.ethz.ch 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] Getting eps into Word --- thanks.

2005-10-04 Thread Rolf Turner

Many thanks to all who responded to my inquiry about getting
(R-generated) *.eps files into a Word document.  I have passed
the suggestions on to my student in the hope that at least
one of them will work for her.

Thanks again.

cheers,

Rolf Turner

__
R-help@stat.math.ethz.ch 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] Problem reading in external data and assigning data.frames within R

2005-10-04 Thread Peter Dalgaard
Nathan Dieckmann <[EMAIL PROTECTED]> writes:

>   Hey there,
> 
> I apologize if this is an irritatingly simple question ... I'm a
> new user.  I can't understand why R flips the sign of all data values
> when reading in external text files (tab delimited or csv) with the
> read.delim or read.csv functions.  The signs of data values also seem
> to be flipped after assigning a new data.frame from within R (xnew <--

If you think the assignment operator is "<--", then that could well be
the cause

> edit(data.frame()).  What am I doing wrong?
> 
>Any help would be greatly appreciated.  Thanks in advance.
> 
>  -- Nate


-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@stat.math.ethz.ch 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] Getting eps into Word documents.

2005-10-04 Thread Robert Baer
> > On 03-Oct-05 Marc Schwartz (via MN) wrote:
> > > On Mon, 2005-10-03 at 16:31 -0300, Rolf Turner wrote:
> > >> A student in one of my courses has asked me about getting R graphics
> > >> output (under Linux) into a Word document.  I.e. she wants to do her
> > >> R thing under Linux, but then do her word processing using Word.
--snip--
> > > So use something like the following:
> > >
> > >
> > > postscript("RPlot.eps", height = 4, width = 4,
> > >horizontal = FALSE, onefile = FALSE,
> > >paper = "special")
> > >
> > > plot(1:5)
> > >
> > > dev.off()
> > >
> > >
> > > You can then import the .eps file into Word or most other such
> > > applications that can import encapsulated postscript files.

-snip
> > > More information is available from MS here:
> > >
> > > http://support.microsoft.com/?kbid=290362
> > >
> > > HTH,
> > >
> > > Marc Schwartz
--snip---
> > b) It won't work anyway if printed to a non-PostScript printer.
>
> True, which is the case irrespective of Word/Windows. If you don't have
> a PS printer locally or accessible via network, you can always install a
> PS printer driver and print to a file, which can then be printed by a
> third party if required.
>
Well, as a lowly Windows and Office user, I most often right click on R
grahics, cut to clipboard, and paste into Word.   So one possiblility is for
the student to install R on her own machine (Windows or Mac?).

But I just tried Marc's suggestion, and it looks VERY VIABLE to me.  I
generated the graph from his code snippet and used "Insert picture from
file" in Word 2003 to place the graphic in a Word document.  I then tried
printing on both an HP 4100 TN laserjet and an HP 960c deskjet.  The image
printed perfectly on both printers with crisp lines and text that apprear to
be vector-based not degraded bitmapped representations.  Certainly worth the
student trying.

HTH,
Rob Baer

__
R-help@stat.math.ethz.ch 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] heatmap ordered list

2005-10-04 Thread Andrea Zangrando
Hi,
another problem on heatmaps... after generating the graph with

myBlRd <- colorRampPalette(c("blue", "red"))
heatmap(dataHeat[Top100, ], col=myBlRd(15))

i need to retrieve the row names' list ordered by the dendrogram.
I tried with   "rownames(data)[Top100]"   but the list is not ordered 
(as i can see in the generated picture). Any tips?

Tnx
AZ

-- 
Andrea Zangrando - Ph.D. Student

University of Padova
Department of Pediatrics
Laboratory of Pediatric OncoHematology
Via Giustiniani, 3
35128 Padova - Italy
Phone: +39 049 8211457
Fax: +39 049 8211456
Email:   [EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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] Problem with Matrix package

2005-10-04 Thread Martin Maechler

> "Jari" == Jari Haukka <[EMAIL PROTECTED]>
> on Tue, 04 Oct 2005 12:56:58 +0300 writes:

Jari> Hello All, While trying to install Matrix package
Jari> following error message came out:

Jari> /usr/bin/ld: cannot find -lblas-3
Jari> collect2: ld returned 1 exit status
Jari> make: *** [Matrix.so] Error 1
Jari> ERROR: compilation failed for package 'Matrix'
Jari> ** Removing '/usr/lib/R/library/Matrix'
Jari> ** Restoring previous '/usr/lib/R/library/Matrix'

Matrix has in src/Makefile

PKG_LIBS = ${LAPACK_LIBS} ${BLAS_LIBS}

and quite a few other packages have the same or a very similar
thing in their src/Makevars or src/Makefile.

Both these variables are defined by your R installation.
And it seems are definitely defined wrongly for your environment.

Try (in a shell)
grep LAPACK_LIBS `R RHOME`/etc/Makeconf
grep BLAS_LIBS `R RHOME`/etc/Makeconf
to see their values
I'm sure the '-lblas-3' above is in one of them.

Jari> It seems that someting is missing. Have anybody idea where we can 
find this 
Jari> missing piece?

there are several debian packages for BLAS/LAPACK etc.
I do wonder how you got to an R installation with LAPACK_LIBS or
BLAS_LIBS that don't match the things available on your machine.

Jari> We have Debian Linux.

Yes, and an installation of R (which one?)
that's not "correct" in the above sense.

How was it installed?

Regards,
Martin Maechler, ETH Zurich

__
R-help@stat.math.ethz.ch 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] Repeated measure Generalized Linear Mixed Model (glmm) ?

2005-10-04 Thread Jérôme Lemaître
Dear all,

I want to know the probability of dying in a trap as a function of habitat
variables for a metapopulation of voles sampled in 44 stations. 
My dataset is as follow:
Station tag number  deadhabitat1habitat2
1   1   yes 20  26
1   2   no  20  26
2   3   no  15  16
..

As far as I know, I should use a mixed-model as:
glmmPQL<-(fixed = dead~habitat1+habitat2, random = ~1|station, family =
binomial) in the MASS library.
However, some vole individuals were recaptured (but it is not a study
designed for capture-mark-recapture!!!) therefore, I have for example, the
4th vole:
Station tag number  deadhabitat1habitat2
3   4   no  10  12
3   4   yes 10  12

Someone suggested me to use glmm with repeated measures with the number of
tag as the variable to repeat. Apparently, it is possible to do this in SAS.

QUESTIONS : 
1) Is this also possible to do this in R, and if yes, could you please tell
me how?
2) Is this a valid way to analyse this data, and if not, could someone
please put me in the right way?


Thank you very very much to all in advance

Jérôme Lemaître

Étudiant au doctorat
Université Laval
Québec, QC  G1K 7P4

__
R-help@stat.math.ethz.ch 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] sampling vectors

2005-10-04 Thread Ravi Varadhan
I mean to say:  check out "rmultinom" function  
 
? rmultinom
 
For example,
 
rmultinom(10,50,prob=rep(1,5)) 
 
will give you 10 vectors (arranged as columns of a matrix), each of length 5, 
sampled from 1:50 and adding up to 50.  You can adjust the weights "prob" to 
draw according to your needs.
 
Hope this is helpful,
Ravi.
 


From: [EMAIL PROTECTED] on behalf of Ravi Varadhan
Sent: Tue 10/4/2005 7:03 AM
To: [EMAIL PROTECTED]; r-help@stat.math.ethz.ch
Subject: Re: [R] sampling vectors



Your problem is nothing but that of drawing a random sample from a multinomial 
distribution.  Check out the "Multinomial" function.

?Multinomial

Best,
Ravi.



From: [EMAIL PROTECTED] on behalf of [EMAIL PROTECTED]
Sent: Tue 10/4/2005 1:59 AM
To: r-help@stat.math.ethz.ch
Subject: Re: [R] sampling vectors



Eric Pante a écrit :

> Hello Listers,
> I am trying to sample a vector to create a new one of sample length,
> witha  sum equal to the sum of the initial vector:
> initial = 10, 30, 10 (sum=50)
> sample example = 5, 35, 10 (sum=50) or 25, 15, 10  (sum=50), etc ...
> My problem is to control the sum, so it stays constant.

f0 = function()
{
s1 = 50;
for (i in 0:s1)
{
s2 = s1 - i;
for (j in 0:s2)
{
s3 = s2 - j;
print (c(i,j,s3));
}
}
}

(If I have well understood the question) ?
hih
Vincent

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



[[alternative HTML version deleted]]




[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] sampling vectors

2005-10-04 Thread Ravi Varadhan
Your problem is nothing but that of drawing a random sample from a multinomial 
distribution.  Check out the "Multinomial" function.
 
?Multinomial
 
Best,
Ravi.



From: [EMAIL PROTECTED] on behalf of [EMAIL PROTECTED]
Sent: Tue 10/4/2005 1:59 AM
To: r-help@stat.math.ethz.ch
Subject: Re: [R] sampling vectors



Eric Pante a écrit :

> Hello Listers,
> I am trying to sample a vector to create a new one of sample length,
> witha  sum equal to the sum of the initial vector:
> initial = 10, 30, 10 (sum=50)
> sample example = 5, 35, 10 (sum=50) or 25, 15, 10  (sum=50), etc ...
> My problem is to control the sum, so it stays constant.

f0 = function()
{
s1 = 50;
for (i in 0:s1)
{
s2 = s1 - i;
for (j in 0:s2)
{
s3 = s2 - j;
print (c(i,j,s3));
}
}
}

(If I have well understood the question) ?
hih
Vincent

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



[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] boxplot statistics

2005-10-04 Thread Graham Williams
Received Tue 04 Oct 2005  7:26pm +1000 from Karin Lagesen:
> 
> I have read and reread the boxplot and the boxplot stats page, and I
> still cannot understand how and what boxplot shows. I realize that
> this might be due to me not knowing enough statistics, but anyway...
> 
> First, how does boxplot determine the size of the box? And is the line
> inside the box the mean or the median (or something completely
> different?) And how does it determine how long out the whiskers should
> go?
> 
> Also, the boxplot.stats page talks about "hinges", what are those?  
> "The two "hinges" are versions of the first and third quartile, i.e.,
> close to 'quantile(x, c(1,3)/4)'."

Wikipedia has a reasonable description

   http://en.wikipedia.org/wiki/Boxplot

Regards

__
R-help@stat.math.ethz.ch 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] newbie questions - looping through hierarchial datafille

2005-10-04 Thread jim holtman
Here a brute force way based on the format of you input data. Basically it
reads a line in and then 'splits' it apart based on blanks and then
processes based on the 'tag'. Information is stored in some global data and
the '.result' is converted into a dataframe that you can work with.
 
> xIN <- scan('/treedata.txt', what='', sep='\n') # read in entire line
Read 59 items
> xIN <- strsplit(xIN, ' ') # split out fields separated by blanks
> # initialize 'global' variables to collect the information
> Out <- list() # individual results
> .result <- list(); r.n <- 0
> # process the data into a list '.result'
> # make use of the '<<-' to assign to a 'global' value
> invisible(lapply(xIN, function(x){
+ if (x[1] == "A") Out$inv <<- x[2]
+ else if (x[1] == "X") {
+ Out$strat <<- x[2]
+ Out$total <<- x[3]
+ Out$year <<- x[4]
+ } else if (x[1] == "P"){
+ Out$plot <<- x[2]
+ Out$age <<- x[3]
+ Out$slope <<- x[4]
+ Out$species <<- x[5]
+ } else if (x[1] == "T"){
+ Out$tree <<- x[2]
+ Out$freq <<- x[3]
+ } else if (x[1] == "L"){
+ Out$leader <<- x[2]
+ Out$diam <<- x[3]
+ Out$height <<- x[4]
+ } else if (x[1] == "F") {
+ Out$start <<- x[2]
+ Out$finish <<- x[3]
+ Out$feature <<- x[4]
+ .result[[r.n <<- r.n + 1]] <<- Out # store the result
+ }
+ }))
> # convert the list to a dataframe for processing
> myData <- lapply(.result, function(x) do.call('cbind', x))
> myData <- as.data.frame(do.call('rbind', myData))
> myData[order(myData$inv, myData$strat, myData$plot, myData$tree,
myData$leader),]
inv strat total year plot age slope species tree freq leader diam height
start finish feature
1 BENALLA_1 1 10 YE=1985 1 20.25 slope=14 SPP:P.RAD 1 25 0 28.5 21.3528 0
21.3528 SFNSW_DIC:P
2 BENALLA_1 1 10 YE=1985 1 20.25 slope=14 SPP:P.RAD 1 25 0 28.5 21.3528
21.3528 100 SFNSW_DIC:P
3 BENALLA_1 1 10 YE=1985 1 20.25 slope=14 SPP:P.RAD 2 25 0 32 23.1 0
6.5SFNSW_DIC:A
4 BENALLA_1 1 10 YE=1985 1 20.25 slope=14 SPP:P.RAD 2 25 0 32 23.1 6.5
23.1SFNSW_DIC:C
5 BENALLA_1 1 10 YE=1985 1 20.25 slope=14 SPP:P.RAD 2 25 0 32 23.1 23.1 100
SFNSW_DIC:C
6 BENALLA_1 1 10 YE=1985 1 20.25 slope=14 SPP:P.RAD 3 25 0 39.5 22.2407 0
4.7 SFNSW_DIC:A
7 BENALLA_1 1 10 YE=1985 1 20.25 slope=14 SPP:P.RAD 3 25 0 39.5 22.2407 4.7
6.7 SFNSW_DIC:C
8 BENALLA_1 1 10 YE=1985 2 20.25 slope=13 SPP:P.RAD 1 25 0 38 22.1474 0 1
SFNSW_DIC:G
9 BENALLA_1 1 10 YE=1985 2 20.25 slope=13 SPP:P.RAD 1 25 0 38 22.1474
1 2.3SFNSW_DIC:A
10 BENALLA_1 1 10 YE=1985 2 20.25 slope=13 SPP:P.RAD 1001 25 0 38 22.1474 0
1 SFNSW_DIC:G
11 BENALLA_1 1 10 YE=1985 2 20.25 slope=13 SPP:P.RAD 1001 25 0 38 22.1474 1
2.3 SFNSW_DIC:A
12 BENALLA_1 1 10 YE=1985 2 20.25 slope=13 SPP:P.RAD 2 25 0 32.5 21.7386 0 2
SFNSW_DIC:A
13 BENALLA_1 1 10 YE=1985 2 20.25 slope=13 SPP:P.RAD 2 25 0 32.5 21.7386 2
3.3 SFNSW_DIC:G
14 BENALLA_1 1 10 YE=1985 2 20.25 slope=13 SPP:P.RAD 2 25 0 32.5 21.7386 3.3
10.4 SFNSW_DIC:C
15 BENALLA_1 2 10 YE=1985 1 20.25 slope=14 SPP:P.RAD 1 25 0 28.5 21.3528 0
21.3528 SFNSW_DIC:P
16 BENALLA_1 2 10 YE=1985 1 20.25 slope=14 SPP:P.RAD 1 25 0 28.5 21.3528
21.3528 100 SFNSW_DIC:P
17 BENALLA_1 2 10 YE=1985 1 20.25 slope=14 SPP:P.RAD 2 25 0 32 23.1 0
6.5SFNSW_DIC:A
18 BENALLA_1 2 10 YE=1985 1 20.25 slope=14 SPP:P.RAD 2 25 0 32 23.1
6.5 23.1SFNSW_DIC:C
19 BENALLA_1 2 10 YE=1985 1 20.25 slope=14 SPP:P.RAD 2 25 0 32 23.1 23.1 100
SFNSW_DIC:C
20 BENALLA_1 2 10 YE=1985 1 20.25 slope=14 SPP:P.RAD 3 25 0 39.5 22.2407 0
4.7 SFNSW_DIC:A
21 BENALLA_1 2 10 YE=1985 1 20.25 slope=14 SPP:P.RAD 3 25 0 39.5 22.2407 4.7
6.7 SFNSW_DIC:C
22 BENALLA_1 2 10 YE=1985 2 20.25 slope=13 SPP:P.RAD 1 25 0 38 22.1474 0 1
SFNSW_DIC:G
23 BENALLA_1 2 10 YE=1985 2 20.25 slope=13 SPP:P.RAD 1 25 0 38 22.1474
1 2.3SFNSW_DIC:A
24 BENALLA_1 2 10 YE=1985 2 20.25 slope=13 SPP:P.RAD 1001 25 0 38 22.1474 0
1 SFNSW_DIC:G
25 BENALLA_1 2 10 YE=1985 2 20.25 slope=13 SPP:P.RAD 1001 25 0 38 22.1474 1
2.3 SFNSW_DIC:A
26 BENALLA_1 2 10 YE=1985 2 20.25 slope=13 SPP:P.RAD 2 25 0 32.5 21.7386 0 2
SFNSW_DIC:A
27 BENALLA_1 2 10 YE=1985 2 20.25 slope=13 SPP:P.RAD 2 25 0 32.5 21.7386 2
3.3 SFNSW_DIC:G
28 BENALLA_1 2 10 YE=1985 2 20.25 slope=13 SPP:P.RAD 2 25 0 32.5 21.7386 3.3
10.4 SFNSW_DIC:C
>
>
>


 On 10/3/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:
>
> Dear List,
>
> Im new to R - making a transition from SAS. I have a space delimited file
> with the following structure. Each line in the datafile is identified by
> the first letter.
>
> A = Inventory (Inventory)
> X = Stratum (Stratum_no Total Ye=year established)
> P = Plot (Plot_no age slope= species)
> T = Tree (tree_no frequency)
> L = Leader (leader diameter height)
> F = Feature (start_height finish_height feature)
>
> On each of these lines there are some 'line specific' variables (in
> brackets). The data is hierarchical in nature - A feature belongs to a
> leader, a leader belongs to a tree, a tree belongs to a plot, a plot
> belongs to a stratum, a stratum belongs to inventory. There are many
> features in a tree. Many trees in a plot etc.
>
> In

Re: [R] boxplot statistics

2005-10-04 Thread Roger Bivand
On Tue, 4 Oct 2005, Karin Lagesen wrote:

> 
> I have read and reread the boxplot and the boxplot stats page, and I
> still cannot understand how and what boxplot shows. I realize that
> this might be due to me not knowing enough statistics, but anyway...
> 
> First, how does boxplot determine the size of the box? And is the line
> inside the box the mean or the median (or something completely
> different?) And how does it determine how long out the whiskers should
> go?
> 
> Also, the boxplot.stats page talks about "hinges", what are those?  
> "The two "hinges" are versions of the first and third quartile, i.e.,
> close to 'quantile(x, c(1,3)/4)'."
> 
> Thankyou very much.

The reference on the help page is:

 Chambers, J. M., Cleveland, W. S., Kleiner, B. and Tukey, P. A.
 (1983) _Graphical Methods for Data Analysis._  Wadsworth &
 Brooks/Cole.

and a search in BIBSYS suggests that a copy is in your university library:

 author = Chambers and title word = Graphical and material type = Books

The references are there to suggest where to look for the information you 
asked for.

> 
> Karin
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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] boxplot statistics

2005-10-04 Thread Petr Pikal
Hi

Try to find some textbook about statistics. You can get many 
explanations just by finding "boxplot" by e.g. Google and reading 
whot you found.

And of course you can get some information from help pages you 
mentioned.

coef: this determines how far the plot "whiskers" extend out from
  the box.  If 'coef' is positive, the whiskers extend to the

^
  most extreme data point which is no more than 'coef' times
  
  the length of the box away from the box. A value of zero
  ^^
  causes the whiskers to extend to the data extremes (and no
  outliers be returned).

HTH
Petr



On 4 Oct 2005 at 11:24, Karin Lagesen wrote:

To: [EMAIL PROTECTED]
From:   Karin Lagesen <[EMAIL PROTECTED]>
Date sent:  Tue, 04 Oct 2005 11:24:04 +0200
Subject:[R] boxplot statistics

> 
> I have read and reread the boxplot and the boxplot stats page, and I
> still cannot understand how and what boxplot shows. I realize that
> this might be due to me not knowing enough statistics, but anyway...
> 
> First, how does boxplot determine the size of the box? And is the line
> inside the box the mean or the median (or something completely
> different?) And how does it determine how long out the whiskers should
> go?
> 
> Also, the boxplot.stats page talks about "hinges", what are those? 
> "The two "hinges" are versions of the first and third quartile, i.e.,
> close to 'quantile(x, c(1,3)/4)'."
> 
> Thankyou very much.
> 
> Karin
> -- 
> Karin Lagesen, PhD student
> [EMAIL PROTECTED]
> http://www.cmbn.no/rognes/
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

Petr Pikal
[EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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] Problem with Matrix package

2005-10-04 Thread Jari Haukka
Hello All,

While trying to install Matrix package following error message came out:


/usr/bin/ld: cannot find -lblas-3
collect2: ld returned 1 exit status
make: *** [Matrix.so] Error 1
ERROR: compilation failed for package 'Matrix'
** Removing '/usr/lib/R/library/Matrix'
** Restoring previous '/usr/lib/R/library/Matrix'


It seems that someting is missing. Have anybody idea where we can find this 
missing piece?
We have Debian Linux.


Jari Haukka

__
R-help@stat.math.ethz.ch 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)

2005-10-04 Thread Jari Haukka
Hello All,

While trying to install Matrix package following error message came out:


/usr/bin/ld: cannot find -lblas-3
collect2: ld returned 1 exit status
make: *** [Matrix.so] Error 1
ERROR: compilation failed for package 'Matrix'
** Removing '/usr/lib/R/library/Matrix'
** Restoring previous '/usr/lib/R/library/Matrix'


It seems that someting is missing. Have anybody idea where we can find this 
missing piece?
We have Debian Linux.



Jari Haukka

__
R-help@stat.math.ethz.ch 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] boxplot statistics

2005-10-04 Thread Karin Lagesen

I have read and reread the boxplot and the boxplot stats page, and I
still cannot understand how and what boxplot shows. I realize that
this might be due to me not knowing enough statistics, but anyway...

First, how does boxplot determine the size of the box? And is the line
inside the box the mean or the median (or something completely
different?) And how does it determine how long out the whiskers should
go?

Also, the boxplot.stats page talks about "hinges", what are those?  
"The two "hinges" are versions of the first and third quartile, i.e.,
close to 'quantile(x, c(1,3)/4)'."

Thankyou very much.

Karin
-- 
Karin Lagesen, PhD student
[EMAIL PROTECTED]
http://www.cmbn.no/rognes/

__
R-help@stat.math.ethz.ch 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] sampling vectors

2005-10-04 Thread Daniel Nordlund
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> On Behalf Of ecatchpole
> Sent: Monday, October 03, 2005 11:57 PM
> To: Eric Pante
> Cc: r-help@stat.math.ethz.ch
> Subject: Re: [R] sampling vectors
> 
> Eric,
> 
> If you want samples of size 3 from 0:50, with sum==50, this seems to do
> the job (with apologies to those who really know how to program in R):
> 
> tot <- 50
> ii <- 0
> aa <- list()
> for(i in 0:tot){
> for(j in 0:(tot-i)){
>k <- tot-i-j
>ii <- ii+1
>aa[[ii]] <- list(i=i,j=j,k=k)
> }
> }
> 
> aa[sample(ii, 4)] # for a sample of 4.
> 
> If you want a sample of size n from x[1],...x[N], such that the sample
> sum is T, then that is much trickier!
> 
> Ted.
> 
> On 04/10/05 07:31,  Eric Pante wrote,:
> > Hello Listers,
> >
> > I am trying to sample a vector to create a new one of sample length,
> > witha  sum equal to the sum of the initial vector:
> >
> > initial = 10, 30, 10 (sum=50)
> > sample example = 5, 35, 10 (sum=50) or 25, 15, 10  (sum=50), etc ...
> >
> > My problem is to control the sum, so it stays constant.
> > Any suggestions would be very helpful !
> >
> > Thank you in advance,
> > Eric
> >

Eric,

Here is another solution, which allows vectors of different lengths and sums.

vectorSample <- function(vec) {
  tot<-sum(vec)
  Len<-length(vec)
  v < -rep(0,Len)
  for(i in Len:2) {
UL <- tot - sum(v) - i + 1
v[i]<-sample(1:UL,1)
} 
  v[1] <- tot - sum(v)
  v
  }

 vectorSample( c(10,30,10) )

Hope this helps,

Dan Nordlund
Bothell, WA

__
R-help@stat.math.ethz.ch 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] heatmap

2005-10-04 Thread Roger Bivand
On Tue, 4 Oct 2005, Jim Lemon wrote:

> Andrea Zangrando wrote:
>  > Hi,
>  > i created a graph with heatmap(sma) function:
>  >
>  > heatmap(dataHeat(x))
>  >
>  > and I wish to change the gradation of colors from blue to red, how could
>  > i do?
>  > Using "heatmap(dataHeat(x), col=c(2,4))" i will use only 2 colors
>  > without gradation.
>  >
> The color.gradient function in the plotrix package returns a sequence of 
> interpolated colors between any two starting colors or incomplete 
> sequences of primaries.
> 
> I noticed that a function named ramp (in the base package?) was 
> mentioned, but I could not find it. If there is a function equivalent to 
> color.gradient, I would like to know about it, as I try to avoid 
> duplicating functions.

see ?colorRamp and look at:

> colorRampPalette
function (colors, ...) 
{
ramp <- colorRamp(colors, ...)
function(n) {
x <- ramp(seq(0, 1, length = n))
rgb(x[, 1], x[, 2], x[, 3], max = 255)
}
}

to see where it comes from. The colorRamp/colorRampPalette combination is 
quite remarkable and lots of fun ...

Roger

> 
> Jim
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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] heatmap

2005-10-04 Thread Jim Lemon
Andrea Zangrando wrote:
 > Hi,
 > i created a graph with heatmap(sma) function:
 >
 > heatmap(dataHeat(x))
 >
 > and I wish to change the gradation of colors from blue to red, how could
 > i do?
 > Using "heatmap(dataHeat(x), col=c(2,4))" i will use only 2 colors
 > without gradation.
 >
The color.gradient function in the plotrix package returns a sequence of 
interpolated colors between any two starting colors or incomplete 
sequences of primaries.

I noticed that a function named ramp (in the base package?) was 
mentioned, but I could not find it. If there is a function equivalent to 
color.gradient, I would like to know about it, as I try to avoid 
duplicating functions.

Jim

__
R-help@stat.math.ethz.ch 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] spline.des

2005-10-04 Thread Uwe Ligges
Frede Aakmann Tøgersen wrote:
> Hey
> 
> The function spline.des is in the splines package. You need to do 
> 
> library(splines)
> 
> before you have the full functionality of the fda package.

So this is obviously a bug in fda: it should at least depend/suggest the 
"splines" package, should try to load it, and give an appropriate error 
message if splines is required but not available for the case in question.

Uwe Ligges


> 
> Best regards
> Frede Aakmann Tøgersen
>  
> 
>  
> 
> 
>>-Oprindelig meddelelse-
>>Fra: [EMAIL PROTECTED] 
>>[mailto:[EMAIL PROTECTED] På vegne af lforzani
>>Sendt: 3. oktober 2005 22:28
>>Til: Douglas Bates; Horacio Montenegro
>>Cc: r-help@stat.math.ethz.ch
>>Emne: [R] spline.des
>>
>>Hello, I am using library fda and I can not run a lot of 
>>functions because I receive the error:
>>
>>Error in bsplineS(evalarg, breaks, norder, nderiv) : 
>>couldn't find function "spline.des"
>>
>>
>>do you know how I can fix that? Thnaks. Liliana
>>
>>__
>>R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] spline.des

2005-10-04 Thread Frede Aakmann Tøgersen

Hey

The function spline.des is in the splines package. You need to do 

library(splines)

before you have the full functionality of the fda package.


Best regards
Frede Aakmann Tøgersen
 

 

> -Oprindelig meddelelse-
> Fra: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] På vegne af lforzani
> Sendt: 3. oktober 2005 22:28
> Til: Douglas Bates; Horacio Montenegro
> Cc: r-help@stat.math.ethz.ch
> Emne: [R] spline.des
> 
> Hello, I am using library fda and I can not run a lot of 
> functions because I receive the error:
> 
> Error in bsplineS(evalarg, breaks, norder, nderiv) : 
> couldn't find function "spline.des"
> 
> 
> do you know how I can fix that? Thnaks. Liliana
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Getting eps into Word documents.

2005-10-04 Thread Prof Brian Ripley
On Mon, 3 Oct 2005, Marc Schwartz (via MN) wrote:

> On Mon, 2005-10-03 at 22:00 +0100, Ted Harding wrote:
>> Rolf (& Marc)
>>
>> On 03-Oct-05 Marc Schwartz (via MN) wrote:
>>> On Mon, 2005-10-03 at 16:31 -0300, Rolf Turner wrote:
 A student in one of my courses has asked me about getting R graphics
 output (under Linux) into a Word document.  I.e. she wants to do her
 R thing under Linux, but then do her word processing using Word.

 Scanning around the r-help archives I encountered an inquiry about
 this topic --- eps into Word documents --- from Paul Johnson but
 found no replies to it.  I tried contacting him but the email address
 in the archives appeared not to be valid.  Does anyone know a
 satisfactory solution to the problem of including a graphic which
 exists in the form of a *.eps (encapsulated postscript) file into a
 Word document.  If so, would you be willing to share it with me and
 my student?

 If so, please be gentle in your explanation.  I am not myself (repeat
 ***NOT***) a user of Word!
>>>
>>> Hehe...  :-)
>>>
>>> Rolf, just use the guidance provided in ?postscript. In the details
>>> section it indicates:
>>>
>>>  The postscript produced by R is EPS (_Encapsulated PostScript_)
>>>  compatible, and can be included into other documents, e.g., into
>>>  LaTeX, using '\includegraphics{}'.  For use in this way
>>>  you will probably want to set 'horizontal = FALSE, onefile =
>>>  FALSE, paper = "special"'.
>>>
>>> So use something like the following:
>>>
>>>
>>> postscript("RPlot.eps", height = 4, width = 4,
>>>horizontal = FALSE, onefile = FALSE,
>>>paper = "special")
>>>
>>> plot(1:5)
>>>
>>> dev.off()
>>>
>>>
>>> You can then import the .eps file into Word or most other such
>>> applications that can import encapsulated postscript files.
>>>
>>> The recent versions of Word will also automatically generate a
>>> bitmapped preview of the plot upon import.  BTW, OO.org 2.0,
>>> which is in late beta testing now, also generates EPS preview
>>> images upon import.
>>>
>>> The key to doing this successfully is using the arguments to
>>> postscript() as defined above. I have never had a problem with this.
>>>
>>> More information is available from MS here:
>>>
>>> http://support.microsoft.com/?kbid=290362
>>>
>>> HTH,
>>>
>>> Marc Schwartz
>>
>> This suggestion could be problematic in that
>
> Ted,
>
>> a) According to the MS web site above, it applies to recent Word
>>(Office 2002/2003) or possibly earlier "depending on installed
>>graphics filters".
>
> The Word EPS filter has been around for some time. I recall using it
> years ago. Note that it is listed on that site in both categories of
> filters for some reason.  In the older versions of Word, there was no
> preview image generated, hence you ended up with a box/frame place
> holder of sorts, unless you added a preview image before importing.

We've been using this route for more than a decade (on both Windows and 
Classic MacOS).  You can use GSView, Photoshop, ... to add a preview if 
you desire.

> That being said, one does need to install the import filters from the
> Office CD, which may not be part of the default settings on all prior
> versions. It may require going back into the Office set up program to
> install them.
>
>> b) It won't work anyway if printed to a non-PostScript printer.
>
> True, which is the case irrespective of Word/Windows. If you don't have
> a PS printer locally or accessible via network, you can always install a
> PS printer driver and print to a file, which can then be printed by a
> third party if required.
>
> If one has ps2pdf/Ghostscript available, you can also convert the PS
> file to PDF and then print it via Acrobat or other PDF viewers.
>
>> If either of these applies to Rolf's student, she could have problems.
>>
>> [Just to add my own "disclaimer": the only version of Word I'm in
>> any position to ever touch, and then only if driven to, belongs
>> to Office 98; and I'm sure that this doesn't know a thing about
>> PostScript!]
>>
>> Another option to consider, since she's doing her R work on Linux,
>> is that recent versions of the ImageMagick program 'convert' have
>> the capability to convert EPS into WMF (Windows Metafile; use
>> file extension ".wmf" for 'convert') or EMF (Enhanced Metafile);
>> use file extension ".emf". The gubbins is built in to a file
>> "wmf.so" in the lib/ImageMagick tree.
>>
>> Likewise, the program 'pstoedit' can do it (to ".wmf" or ".emf"),
>> using library /usr/local/lib/pstoedit/libp2edrvwmf.so (on my machine).
>>
>> Most Linux distributions these days come with ImageMagick and
>> pstoedit. If not already installed in the machine she's using it
>> should be straightforward to get this dome.
>>
>> Hoping this helps,
>> Ted.
>
> Ted, the critical issue with doing the WMF/EMF conversion on Linux is
> that the libEMF stuff generates lousy quality (and visu

Re: [R] Problem reading in external data and assigning data.frames within R

2005-10-04 Thread ecatchpole
Try

xnew <- edit(data.frame())

Ted.


On 04/10/05 16:29,  Nathan Dieckmann wrote,:
>   Hey there,
> 
> I apologize if this is an irritatingly simple question ... I'm a
> new user.  I can't understand why R flips the sign of all data values
> when reading in external text files (tab delimited or csv) with the
> read.delim or read.csv functions.  The signs of data values also seem
> to be flipped after assigning a new data.frame from within R (xnew <--
> edit(data.frame()).  What am I doing wrong?
> 
>Any help would be greatly appreciated.  Thanks in advance.
> 
>  -- Nate
> 
> -
> Nathan Dieckmann
> Department of Psychology
> University of Oregon
> Eugene, OR 97403
> (541) 346-4963
> [EMAIL PROTECTED]
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


-- 
Dr E.A. Catchpole
Visiting Fellow
Univ of New South Wales at ADFA, Canberra, Australia
and University of Kent, Canterbury, England
- www.ma.adfa.edu.au/~eac
- fax: +61 2 6268 8786  
- ph:  +61 2 6268 8895

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