Re: [R] PCA and MDS

2005-06-22 Thread Prof Brian Ripley
On Wed, 22 Jun 2005, Guohui Ding wrote:

 prcomp(stats) Principal Components Analysis
 princomp(stats) Principal Components Analysis
 scale(base) Scaling and Centering of Matrix-like Objects

The first two are correct for PCA, but scale is not MDS.

MDS is available in cmdscale (stats), isoMDS (MASS), sammon (MASS) and 
elsewhere.

 I am not familar with R. I want to use PCA (principal components
 analysis) and MDS (multidimensional scaling). Can someone tell me
 which R package I should use for PCA and MDS? I appreciate your help
 in advance.

-- 
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] How to use expression in label with xYplot

2005-06-22 Thread PANTERA Laurent
Dear R-List,

 I want to use the label function (from Hmisc library) to allow for the
names of my isotopes.

library(Hmisc)
library(lattice)
library(grid)
num - c(78,137,129m)
nom - c(Ge,Cs,Te)
df - data.frame(GE78=seq(nom),CS137=seq(nom),TE129m=seq(nom))

if I use this function to create the labels :

lab - function(i)
  as.expression(bquote(italic(phantom(0)^{.(num[i])}*.(nom[i]

label(df$GE78) -  lab(1)
label(df$CS137) -  lab(2)
label(df$TE129m) -  lab(3)

all works fine when I use text and xyplot :

plot(1:10)
text(6,6,labels=label(df$CS137))
xyplot(CS137~TE129m,data=df,xlab=label(df$CS137),ylab=label(df$TE129m))

but xYplot doesn't work fine

xYplot(CS137~TE129m,data=df)

I have the message :
Error in parse(file, n, text, prompt) : parse error

 if I change the lab function

lab - function(i)
 
as.character(paste(italic(phantom(0)^{\,num[i],\}*\,nom[i],\),sep=
))

text and xyplot work fine if I use the parse function and xYplot works fine.

label(df$GE78) -  lab(1)
label(df$CS137) -  lab(2)
label(df$TE129m) -  lab(3)
plot(1:10)
text(6,6,labels=parse(text=label(df$CS137)))
xyplot(CS137~TE129m,data=df,xlab=parse(text=label(df$CS137)),ylab=parse(text
=label(df$TE129m)))
xYplot(CS137~TE129m,data=df)

What is the good way to use expression in the labels of variables with the
label function ?

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] tapply

2005-06-22 Thread Martin Maechler
 AndyL == Liaw, Andy [EMAIL PROTECTED]
 on Tue, 21 Jun 2005 13:30:54 -0400 writes:

AndyL Try:
 (x - factor(1:2, levels=1:5))
AndyL [1] 1 2
AndyL Levels: 1 2 3 4 5
 (x - x[, drop=TRUE])
AndyL [1] 1 2
AndyL Levels: 1 2

or  
(x - factor(1:2, levels=1:5))
(x2 - factor(x))

which also drops the level
Martin

AndyL Andy

 From: Weiwei Shi [mailto:[EMAIL PROTECTED] 
 
 Even before I tried, I already realize it must be true when I read
 this reply! Great job! thanks, Andy.
 
  str(z)
 `data.frame':   235 obs. of  2 variables:
 $ CLAIMNUM : Factor w/ 1907 levels 0,1001849,..: 1083 1083
 1083 1582 1582 1084 1681 1681 1391 1391 ...
 $ SIU.SAVED: int  475 3000 3000 0 0 4352 0 0 4500 3000 ...
 
 So, I have another general question: how to avoid this when I 
 do the matching?
 In my case, claimnum does not have to be a factor.  I think I can do
 as.integer on it to de-factor it. But, I want to know how to do it w/
 keeping is as factor? btw, what's your way to drop those levels?  :)
 
 weiwei 
 
 
 On 6/21/05, Liaw, Andy [EMAIL PROTECTED] wrote:
  What does str(z) say?  I suspect the second column is a 
 factor, which, after
  the subsetting, has some empty levels.  If so, just drop 
 those levels.
  
  Andy
  
   From: Weiwei Shi
  
   hi
   i tried all the methods suggested above:
   ave and rowsum with with function works for my 
 situation. I think
   the problem might not be due to tapply.
   My data z comes from
   z-y[y[[1]] %in% x[[2]], c(1,9)]
  
   while z is supposed to have no entries for those non-matched
   between x and y.
  
   however, when I run tapply, and the result also includes those
   non-matched entries. I use is.na function to remove those 
 entry from z
   first and then use tapply again, but the result is the same: those
   NA's and those non-matched results are still there. 
 That's what I mean
   by it doesn't work.
  
   Is there something I missed here so that z implicitly has some
   trace back to y dataset?
  
   thanks,
  
   On 6/20/05, Gabor Grothendieck [EMAIL PROTECTED] wrote:
On 6/20/05, Weiwei Shi [EMAIL PROTECTED] wrote:
 hi,
 i have another question on tapply:
 i have a dataset z like this:
 5540 389100307391  2600
 5541 389100307391  2600
 5542 389100307391  2600
 5543 389100307391  2600
 5544 389100307391  2600
 5546 381300302513NA
 5547 387000307470NA
 5548 387000307470NA
 5549 387000307470NA
 5550 387000307470NA
 5551 387000307470NA
 5552 387000307470NA

 I want to sum the column 3 by column 2.
 I removed NA by calling:
 tapply(z[[3]], z[[2]], sum, na.rm=T)
 but it does not work.

 then, i used
 z1-z[!is.na(z[[3]],]
 and repeat
 still doesn't work.

 please help.

   
Depending on what you want you may be able to use rowsum:
   
- display only groups that have at least one non-NA with the sum
  being the sum of the non-NAs:
   
with(na.omit(z), rowsum(V3, V2))
   
- display all groups with the sum being NA if any member is NA:
   
rowsum(z$V3, z$V2)
   
  
  
   --
   Weiwei Shi, Ph.D
  
   Did you always know?
   No, I did not. But I believed...
   ---Matrix III
  
   __
   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
  
  
  
  
  
  
  
 --
 
  Notice:  This e-mail message, together with any 
 attachments, contains information of Merck  Co., Inc. (One 
 Merck Drive, Whitehouse Station, New Jersey, USA 08889), 
 and/or its affiliates (which may be known outside the United 
 States as Merck Frosst, Merck Sharp  Dohme or MSD and in 
 Japan, as Banyu) that may be confidential, proprietary 
 copyrighted and/or legally privileged. It is intended solely 
 for the use of the individual or entity named on this 
 message.  If you are not the intended recipient, and have 
 received this message in error, please notify us immediately 
 by reply e-mail and then delete it from your system.
  
 --
 
  
 
 
 -- 
 Weiwei Shi, Ph.D
 
 Did you 

[R] predict.coxph fitted values for failure times

2005-06-22 Thread Dan Bebber
I would like to extract predicted failure times from a
coxph model in library(survival). However, none of the
prediction options (lp, risk, expected, terms)
seem to bear any relationship to failure time.

Perhaps I am asking the wrong question, but can coxph
provide predicted failure times?

Thanks,
Dan Bebber

Department of Plant Sciences
University of Oxford





___ 
How much free photo storage do you get? Store your holiday

__
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] A question on time-dependent covariates in the Cox model.

2005-06-22 Thread Marianne dk
I have a dataset with

event=death
time (from medical examination until death/censoring)
dose (given at examination time)

Two groups are considered, a non-exposed group (dose=0), an exposed group 
(dose between 5 and 60).

For some reason there is a theory of the dose increasing its effect over 
time (however it was only given (and measured) once = at the time of 
examination).

I tested a model:

coxph(Surv(time,dod)~dose + dose:time)

Previously I tested the model in SAS:

proc phreg data=test;
model time*dod(0)=dose dosetime /rl ties=efron;
dosetime=time*dose;
run;

Without the interaction terms I get the same results for the two models. By 
including the interaction terms I do not. The model in R gives a negative 
coefficient for the interaction term which is expected to be positive (and 
is so in SAS). The LRTs are also completely different.

TWO QUESTIONS:

1) Is it reasonable to bring in an interaction term when dose is only 
measured once?

2) If yes, can anyone give a hint on explaining the difference between the 
models in R and SAS?

Thanx in advance,
marianne

_
Nyhet! Hotmail direkt i Mobilen! http://mobile.msn.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] predict.coxph fitted values for failure times

2005-06-22 Thread Prof Brian Ripley
On Wed, 22 Jun 2005, Dan Bebber wrote:

 I would like to extract predicted failure times from a
 coxph model in library(survival). However, none of the
 prediction options (lp, risk, expected, terms)
 seem to bear any relationship to failure time.

 Perhaps I am asking the wrong question, but can coxph
 provide predicted failure times?

Strictly no, as a Cox proportional hazards model does not model the 
baseline hazard.  However, there is a coxph method for survfit() which
allows you to predict the survival distribution for the fitted or new 
data, presumably using Breslow's estimator of the baseline hazard.
There's an example on the help page and more in MASS (the book and its 
scripts).

Unfortunately the help page is misleading, documenting only the
km method as if it were the generic (and using \synopsis to avoid
this being flagged).

-- 
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] mu^2(1-mu)^2 variance function for GLM

2005-06-22 Thread Henric Nilsson
Dear Professor Firth,

David Firth said the following on 2005-06-16 17:22:

 I do not have a ready stock of other examples, but I do have my own 
 version of a family function for this, reproduced below.  It differs 
 from yours (apart from being a regular family function rather than using 
 a modified quasi) in the definition of deviance residuals.  These 
 necessarily involve an arbitrary constant (see McCullagh and Nelder, 
 1989, p330); in my function that arbitrariness is in the choice eps - 
 0.0005.  I don't think the deviance contributions as you specified in 
 your code below will have the right derivative (with respect to mu) for 
 observations where y=0 or y=1.

I'm sorry for the late reply.

You're right -- my definition of the deviance residuals isn't correct. 
Your code, on the other hand, seems to do the right thing.

Many thanks for this note and the provided `wedderburn' function.


Henric

__
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] sweep() and recycling

2005-06-22 Thread Prof Brian Ripley
I think that as the proponents do not agree, we need to leave this as is.

BTW, R-devel is the place to discuss patched to R, rather than R-help.

On Tue, 21 Jun 2005, Heather Turner wrote:

 Agreed my examples may be trivial and I'm sure there are more efficient ways 
 to do the same thing, but I disagree that my examples are against the spirit 
 of sweep (). In the first example a vector is swept out from the rows, with 
 one value for odd rows and one value for even rows. In the second example an 
 array of values is swept out across the third dimension. In the third example 
 an array of values is swept out from the full array.

 The first example is a natural use of recycling. E.g.

 sweep(matrix(1:100, 50, 2), 1, c(1, 1000), +, give.warning = TRUE)

 is a quicker way of writing

 sweep(matrix(1:100, 50, 2), 1, rep(c(1, 1000), 25), +, give.warning = TRUE)

 but your code would give a warning in the first case, even though the intent 
 and the result are exactly the same as in the second case.

 As you say, it is only a warning, that can be ignored. However the warning 
 should at least reflect the warning condition used, i.e. warn that the length 
 of STATS does not equal the extent of MARGIN, rather warning that STATS does 
 not recycle exactly.

 Heather

 Robin Hankin [EMAIL PROTECTED] 06/21/05 02:47pm 
 Hi

 On Jun 21, 2005, at 02:33 pm, Heather Turner wrote:

 I think the warning condition in Robin's patch is too harsh - the
 following examples seem reasonable to me, but all produce warnings

 sweep(array(1:24, dim = c(4,3,2)), 1, 1:2, give.warning = TRUE)
 sweep(array(1:24, dim = c(4,3,2)), 1, 1:12, give.warning = TRUE)
 sweep(array(1:24, dim = c(4,3,2)), 1, 1:24, give.warning = TRUE)



 The examples above do give warnings (as intended) but I think all three
 cases above
 are inimical to the spirit of sweep(): nothing is being swept out.

 So a warning is appropriate, IMO.

 In any case, one can always suppress (or ignore!) a warning if one knows
 what one is doing.  YMMV, but if I wanted to do the above operations I
 would
 replace


 sweep(array(0, dim = c(4,3,2)), c(1,3), 1:12, + , give.warning =
 FALSE)

 with

  aperm(array(1:12,c(4,2,3)),c(1,3,2))


 best wishes

 rksh







 I have written an alternative (given below) which does not give
 warnings in the above cases, but does warn in the following case

 sweep(array(1:24, dim = c(4,3,2)), 1:2, 1:3)
 , , 1

  [,1] [,2] [,3]
 [1,]036
 [2,]039
 [3,]069
 [4,]369

 , , 2

  [,1] [,2] [,3]
 [1,]   12   15   18
 [2,]   12   15   21
 [3,]   12   18   21
 [4,]   15   18   21

 Warning message:
 STATS does not recycle exactly across MARGIN

 The code could be easily modified to warn in other cases, e.g. when
 length of STATS is a divisor of the corresponding array extent (as in
 the first example above, with length(STATS) = 2).

 The code also includes Gabor's suggestion.

 Heather

 sweep - function (x, MARGIN, STATS, FUN = -, warn =
 getOption(warn), ...)
 {
 FUN - match.fun(FUN)
 dims - dim(x)
 perm - c(MARGIN, (1:length(dims))[-MARGIN])
 if (warn = 0) {
 s - length(STATS)
 cumDim - c(1, cumprod(dims[perm]))
 if (s  max(cumDim))
 warning(length of STATS greater than length of array,
 call. = FALSE)
 else {
 upper - min(ifelse(cumDim  s, cumDim, max(cumDim)))
 lower - max(ifelse(cumDim  s, cumDim, min(cumDim)))
 if (any(upper %% s != 0, s %% lower != 0))
 warning(STATS does not recycle exactly across MARGIN,
 call. = FALSE)
 }
 }
 FUN(x, aperm(array(STATS, dims[perm]), order(perm)), ...)
 }

 Gabor Grothendieck [EMAIL PROTECTED] 06/21/05 01:25pm 
 \
 Perhaps the signature should be:

sweep(...other args go here..., warn=getOption(warn))

 so that the name and value of the argument are consistent with
 the R warn option.

 On 6/21/05, Robin Hankin [EMAIL PROTECTED] wrote:

 On Jun 20, 2005, at 04:58 pm, Prof Brian Ripley wrote:

 The issue here is that the equivalent command array(1:5, c(6,6)) (to
 matrix(1:5,6,6)) gives no warning, and sweep uses array().

 I am not sure either should: fractional recycling was normally
 allowed
 in S3 (S4 tightened up a bit).

 Perhaps someone who thinks sweep() should warn could contribute a
 tested patch?



 OK,  modified R code and Rd file below (is this the best way to do
 this?)




 sweep -
   function (x, MARGIN, STATS, FUN = -, give.warning = FALSE, ...)
 {
   FUN - match.fun(FUN)
   dims - dim(x)
   if(give.warning  length(STATS)1  any(dims[MARGIN] !=
 dim(as.array(STATS{
 warning(array extents do not recycle exactly)
   }
   perm - c(MARGIN, (1:length(dims))[-MARGIN])
   FUN(x, aperm(array(STATS, dims[perm]), order(perm)), ...)
 }







 \name{sweep}
 \alias{sweep}
 \title{Sweep out Array Summaries}
 \description{
   Return an array obtained from an input array 

Re: [R] A question on time-dependent covariates in the Cox model.

2005-06-22 Thread Peter Dalgaard
Marianne dk [EMAIL PROTECTED] writes:

 I have a dataset with
 
 event=death
 time (from medical examination until death/censoring)
 dose (given at examination time)
 
 Two groups are considered, a non-exposed group (dose=0), an exposed group 
 (dose between 5 and 60).
 
 For some reason there is a theory of the dose increasing its effect over 
 time (however it was only given (and measured) once = at the time of 
 examination).
 
 I tested a model:
 
 coxph(Surv(time,dod)~dose + dose:time)
 
 Previously I tested the model in SAS:
 
 proc phreg data=test;
   model time*dod(0)=dose dosetime /rl ties=efron;
   dosetime=time*dose;
   run;
 
 Without the interaction terms I get the same results for the two models. By 
 including the interaction terms I do not. The model in R gives a negative 
 coefficient for the interaction term which is expected to be positive (and 
 is so in SAS). The LRTs are also completely different.
 
 TWO QUESTIONS:
 
 1) Is it reasonable to bring in an interaction term when dose is only 
 measured once?
 
 2) If yes, can anyone give a hint on explaining the difference between the 
 models in R and SAS?

I don't know what SAS does, maybe it second-guesses your intentions,
but R will definitely get it completely wrong. If you use time as a
covariate, the same time (of death/censoring) will be applied at all
death times. Pretty obviously, long observation times tend to be
associated with low mortalities! With interactions you get, er,
similarly incorrect effects.

To do coxph with time-dependent variables, you need to split data
into little time segments, according to the death time of every death,
inserting a new variable (ntime, say) which is the time of the
endpoint of the interval. 

-- 
   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


[R] Subsetting across a frame for plotting

2005-06-22 Thread Morten Sickel
I have a huge frame holding holding model results for a number of
locations and time series:

 str(tonedata)
`data.frame':   434 obs. of  339 variables:
 $ VALUE   : int  101 104 105 106 111 118 119 121 122 123 ...
 $ COUNT   : int  2443 184 1539 1016 132 1208 1580 654 864 560 ...
 $ AREA: num  6.11e+08 4.60e+07 3.85e+08 2.54e+08 3.30e+07 ...
 $ D1_1958 : num  470 446 452 457 407 ...
 $ D2_1958 : num  480 455 461 467 416 ...
 $ D3_1958 : num  493 469 475 480 429 ...
 $ D4_1958 : num  542 517 522 526 475 ...
 $ D5_1958 : num  585 560 565 568 517 ...

I would like to be able to take all values, except the three first
(value, count, area) and be able to plot them. I have managed to make a
subset that looks like what I want, by doing tonedata[11,4:339], but
that data set is not a vector that can be plottet, it is treated like a
set of single values. I tried to use as.vector on the set, bot to no
help. I am probably overlooking somehing quite simple, (not to mention
not really understanding R's data model..) so help would be appreciated.

-- 
Morten Sickel
Norwegian Radiation Protection Authority

__
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] legend

2005-06-22 Thread Thomas Steiner
I color some area grey with polygon() (with a red border) and then I
want to have the dashed red border in the legend as well. How do I
manage it?

And I want to mix (latex) expressions with text in my legend.

Just execute my lines below and you know want I mean. Or pass by at
http://de.wikipedia.org/wiki/Bild:GBM.png to see the picture online.

Thomas


bm - function(n=500, from=0, to=1) {
  x=seq(from=from,to=to,length=n)
  BM-c(0,cumsum(rnorm(n-1,mean=0,sd=sqrt(to/n
  cbind(x,BM)
}
gbm - function(bm,S0=1,sigma=0.1,mu=1) {
  gbm=S0
  for (t in 2:length(bm[,1])) {
gbm[t]=S0*exp((mu-sigma^2/2)*bm[t,1]+sigma*bm[t,2])
  }
  cbind(bm[,1],gbm)
}

set.seed(9826064)
cs=c(dark green, steelblue, red, yellow)

#png(filename = GBM.png, width=1600, height=1200, pointsize = 12)
par(bg=lightgrey)
x=seq(from=0,to=1,length=500)
plot(x=x, y=exp(0.7*x), type=n, xlab=Zeit, ylab=, ylim=c(1,3.5))
polygon(x=c(x,rev(x)),
y=c(exp(0.7*x)+0.4*sqrt(x),rev(exp(0.7*x)-0.4*sqrt(x))), col=grey,
border=cs[3], lty=dashed)
lines(x=x,y=exp(0.7*x), type=l, lwd=3, col=cs[1])
lines(gbm(bm(),S0=1,mu=0.7,sigma=0.4), lwd=3, col=cs[2])
lines(gbm(bm(),S0=1,mu=0.7,sigma=0.2), lwd=3, col=cs[3])
lines(gbm(bm(),S0=1,mu=0.7,sigma=0.1), lwd=3, col=cs[4])
title(main=Geometrische Brownsche Bewegung,cex.main=2.5)
legend(x=0,y=3.5,legend=c(exp(0.7x),mu=0.7, sigma=0.4,mu=0.7,
sigma=0.2,mu=0.7, sigma=0.1,Standardabweichung für 
sigma=0.2),lwd=c(4,4,4,4,12),col=c(cs,grey),bg=transparent,cex=1.15)
#dev.off()

__
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] nlme leading minor error

2005-06-22 Thread Petr Pikal
Dear all

I am struggling with nlme and error message. Even going through 
Pinheiro, Bates nlme book did not gave me a clue how to avoid 
this.

fit - nlme(ce ~ fi1 / ((1+exp(fi2-fi3*tepl))^(1/fi4)), data = 
temp1na.gr,
start = c(fi1=30, fi2=-100, fi3=-.05, fi4=40), 
fixed = fi1+fi2+fi3+fi4~1, 
random = pdDiag(fi2+fi4~1),
groups = ~spol.f)

gives

Error in chol((value + t(value))/2) : the leading minor of order 1 is 
not positive definite

Is this error due to lack of experimental points?
Here you have one typical part of my data. It is for level spol.f = 
3/11.

teplce
800 28.87
800 29.35
825 29
850 28.73
875 26.83
900 24.07

I have 1-5 points for each level (2 levels with 5 points, 1 level with 
4 points, several levels with 2 and 3 points and few with only one 
point.

Fitting this model to each level separately led to several sets of 
coeficients fi1-fi4 and the separate fits were quite OK.

Please give me a hint what can be the cause for this error message 
and how I shall organize my data to avoid this. (Lack of 
experimental points is also an answer as I can do some subsequent 
measurement.

R 2.1.0, W 2000, nlme package

Best regards



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


Re: [R] Subsetting across a frame for plotting

2005-06-22 Thread Liaw, Andy
You might save yourself some headaches by turning it into a matrix instead,
since all the columns are either integer or numeric:

tonedata - data.matrix(tonedata)

Data frames are really lists, so even when you get a one-row subset, it's
still a one-row data frame.  You can use unlist() to turn that into a
vector.

Andy

 From: Morten Sickel
 
 I have a huge frame holding holding model results for a number of
 locations and time series:
 
  str(tonedata)
 `data.frame':   434 obs. of  339 variables:
  $ VALUE   : int  101 104 105 106 111 118 119 121 122 123 ...
  $ COUNT   : int  2443 184 1539 1016 132 1208 1580 654 864 560 ...
  $ AREA: num  6.11e+08 4.60e+07 3.85e+08 2.54e+08 3.30e+07 ...
  $ D1_1958 : num  470 446 452 457 407 ...
  $ D2_1958 : num  480 455 461 467 416 ...
  $ D3_1958 : num  493 469 475 480 429 ...
  $ D4_1958 : num  542 517 522 526 475 ...
  $ D5_1958 : num  585 560 565 568 517 ...
 
 I would like to be able to take all values, except the three first
 (value, count, area) and be able to plot them. I have managed 
 to make a
 subset that looks like what I want, by doing tonedata[11,4:339], but
 that data set is not a vector that can be plottet, it is 
 treated like a
 set of single values. I tried to use as.vector on the set, bot to no
 help. I am probably overlooking somehing quite simple, (not to mention
 not really understanding R's data model..) so help would be 
 appreciated.
 
 -- 
 Morten Sickel
 Norwegian Radiation Protection Authority
 
 __
 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] the svDialogs package

2005-06-22 Thread Marco Zucchelli
Hello Philippe,

Thanks for the explanation!

  did you change the guidlgopen as well?

Now I get :

file - guiDlgOpen(title= Open case/control 
file,defaultFile=,defaultDir=,multi=FALSE, filters = c(All files 
(*.*), *.*))

gdata - read.table(file,as.is=T,header=T)

Error in file(file, r) : unable to open connection
In addition: Warning message:
cannot open file 'C:/ProgramFiles/R/Work/dcdc2.txt'


and the reason is that

 file
[1] C:/ProgramFiles/R/Work/dcdc2.txt

so the space between Program and Files has disappeared and the path is wrong

correct path would be C:/Program Files/R/Work/dcdc2.txt

Marco

- Original Message - 
From: Philippe Grosjean [EMAIL PROTECTED]
To: Marco Zucchelli [EMAIL PROTECTED]
Cc: R-help r-help@stat.math.ethz.ch
Sent: Friday, June 10, 2005 7:36 AM
Subject: Re: [R] the svDialogs package


 Hello Marco,

 For the first error, the message is clear: not implemented yet!.
 Several dialog boxes are not done yet, but the functions already exist,
 mainly as placeholders for future development.

 Regarding the second, there was a bug in the function (corrected in
 SciViews 0.8-6 that I have just uploaded to CRAN), and also a
 misunderstanding of the its first argument: list. This argument should
 be a charactger vector containing the list of items... but not a list!
 So, the correct code is:

  m_list - 1:10
  res - guiDlgList(m_list) # Need SciViews 0.8-6!
  res

 Note that guiDlgXXX() functions return results _invisibly_. So, you need
 to assign its result to a variable, or use something like:

  (guiDlgList(m_list))

 to see the result printed at the console.

 Best,

 Philippe

 ..°}))
  ) ) ) ) )
 ( ( ( ( (Prof. Philippe Grosjean
  ) ) ) ) )
 ( ( ( ( (Numerical Ecology of Aquatic Systems
  ) ) ) ) )   Mons-Hainaut University, Pentagone (3D08)
 ( ( ( ( (Academie Universitaire Wallonie-Bruxelles
  ) ) ) ) )   8, av du Champ de Mars, 7000 Mons, Belgium
 ( ( ( ( (
  ) ) ) ) )   phone: + 32.65.37.34.97, fax: + 32.65.37.30.54
 ( ( ( ( (email: [EMAIL PROTECTED]
  ) ) ) ) )
 ( ( ( ( (web:   http://www.umh.ac.be/~econum
  ) ) ) ) )  http://www.sciviews.org
 ( ( ( ( (
 ..

 Marco Zucchelli wrote:
 Hi Philippe and R community,

  I am trying to use some functions from the svDialogs package but I get 
 some werid errors I do not understand:


library(svDialogs)


m_list - as.list(1:10)



guiDlgDoubleList(m_list, m_list)

 Error in guiDlgDoubleList(m_list, m_list) :
 Not yet implemented!



guiDlgList(m_list)

 Error in guiDlgList(m_list) : couldn't find function guiSetFonts.tcltk




 Am I doing anything wrong ?? Do I need some other package?



 Marco





 [[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-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] How to use expression in label with xYplot

2005-06-22 Thread Frank E Harrell Jr
PANTERA Laurent wrote:
 Dear R-List,
 
  I want to use the label function (from Hmisc library) to allow for the
 names of my isotopes.
 
 library(Hmisc)
 library(lattice)
 library(grid)
 num - c(78,137,129m)
 nom - c(Ge,Cs,Te)
 df - data.frame(GE78=seq(nom),CS137=seq(nom),TE129m=seq(nom))
 
 if I use this function to create the labels :
 
 lab - function(i)
   as.expression(bquote(italic(phantom(0)^{.(num[i])}*.(nom[i]
 
 label(df$GE78) -  lab(1)
 label(df$CS137) -  lab(2)
 label(df$TE129m) -  lab(3)
 
 all works fine when I use text and xyplot :
 
 plot(1:10)
 text(6,6,labels=label(df$CS137))
 xyplot(CS137~TE129m,data=df,xlab=label(df$CS137),ylab=label(df$TE129m))
 
 but xYplot doesn't work fine
 
 xYplot(CS137~TE129m,data=df)
 
 I have the message :
 Error in parse(file, n, text, prompt) : parse error
 
  if I change the lab function
 
 lab - function(i)
  
 as.character(paste(italic(phantom(0)^{\,num[i],\}*\,nom[i],\),sep=
 ))
 
 text and xyplot work fine if I use the parse function and xYplot works fine.
 
 label(df$GE78) -  lab(1)
 label(df$CS137) -  lab(2)
 label(df$TE129m) -  lab(3)
 plot(1:10)
 text(6,6,labels=parse(text=label(df$CS137)))
 xyplot(CS137~TE129m,data=df,xlab=parse(text=label(df$CS137)),ylab=parse(text
 =label(df$TE129m)))
 xYplot(CS137~TE129m,data=df)
 
 What is the good way to use expression in the labels of variables with the
 label function ?
 
 thanks

In Hmisc, labels are used for many contexts in which expressions aren't 
allowed, so as of this moment labels must be ordinary character strings. 
  I typically pass expressions to xYplot using xlab or ylab directly 
without using the label.

Frank

 
 __
 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
 


-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

__
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] A polar.plot BUG in plotrix 1.3.3 ?

2005-06-22 Thread Halldor Björnsson
Hi,

I just updated to R-2.1.1 and updated packages acordingly

However, after the update, routines that use polar.plot
did not function as correctly.

In plotrix 1.3.3 the polar.plot function does scale label.pos
to radians prior to calling radial.plot

Hence, the command
polar.plot(c(5,10,5,0),c(-10,0,10,20),rp.type='P',
 labels=c(A,N,V,S),label.pos=c(0,90,180,270))

produces absurd compass lines but the correct results are obtained if 
label.pos is scaled with pi/180 :

polar.plot(c(5,10,5,0),c(-10,0,10,20),rp.type='P',
 labels=c(A,N,V,S),label.pos=c(0,90,180,270)*pi/180)

I have attatched the polar.plot function from the two different versions 
of the package.

It seems that if not missing  then label.pos is not changed at all in 
version 1.3.3

So, a feature or a bug?

Sincerely,
-- 
--
Halldor Bjornsson   ([EMAIL PROTECTED])
Vedurstofa Islands (Icelandic Met. Office)
Bustadavegur 9, IS-150, Reykjavik, Iceland
--

In version 1.3.3

polar.plot-function(lengths,polar.pos,labels,label.pos,rp.type=r,...) {
  npos-length(lengths)
  # if no positions are given, add the average distance between 
positions so that
  # the first and last line don't overlap
  if(missing(polar.pos)) radial.pos-seq(0,(2-2/(npos+1))*pi,length=npos)
  else radial.pos-pi*polar.pos/180
  if(missing(labels)) {
   labels-as.character(seq(0,340,by=20))
   label.pos-seq(0,1.9*pi,length=18)
  }
  if(missing(label.pos)) label.pos-pi*label.pos/180
  radial.plot(lengths,radial.pos,range(radial.pos),labels,label.pos,
   rp.type=rp.type,...)
}



In version 1.2

polar.plot-function(lengths,polar.pos,labels,label.pos,rp.type=r,...) {
  npos-length(lengths)
  # if no positions are given, add the average distance between 
positions so that
  # the first and last line don't overlap
  if(missing(polar.pos)) polar.pos-seq(0,360-360/(npos+1),length=npos)
  if(missing(labels)) {
   label.pos-seq(0,340,by=20)
   labels-as.character(label.pos)
   label.range-c(0,pi*340/180)
  }
  if(missing(label.pos)) label.pos-polar.pos
  polar.range-range(polar.pos)
  newrange-c(pi*polar.range[1]/180,pi*(2-(360-polar.range[2])/180))
  # rescale to radians
  radial.pos-rescale(c(polar.pos,polar.range),newrange)[1:npos]
  nlabels-length(labels)
  label.pos-rescale(c(label.pos,0,360),c(0,2*pi))[1:nlabels]

radial.plot(lengths,radial.pos,newrange,labels,label.pos,rp.type=rp.type,...)
}

__
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] the svDialogs package

2005-06-22 Thread Marco Zucchelli
Hello again,

 I am using the guidlglist

I noticed (on windows) that if you scroll the list by using the up and down 
arrows of the gui by clicking with the mouse, if you click twice fast the 
gui disappears and the value on top of the list is selected.

It is meant to be like that ?

Marco



- Original Message - 
From: Philippe Grosjean [EMAIL PROTECTED]
To: Marco Zucchelli [EMAIL PROTECTED]
Cc: R-help r-help@stat.math.ethz.ch
Sent: Friday, June 10, 2005 7:36 AM
Subject: Re: [R] the svDialogs package


 Hello Marco,

 For the first error, the message is clear: not implemented yet!.
 Several dialog boxes are not done yet, but the functions already exist,
 mainly as placeholders for future development.

 Regarding the second, there was a bug in the function (corrected in
 SciViews 0.8-6 that I have just uploaded to CRAN), and also a
 misunderstanding of the its first argument: list. This argument should
 be a charactger vector containing the list of items... but not a list!
 So, the correct code is:

  m_list - 1:10
  res - guiDlgList(m_list) # Need SciViews 0.8-6!
  res

 Note that guiDlgXXX() functions return results _invisibly_. So, you need
 to assign its result to a variable, or use something like:

  (guiDlgList(m_list))

 to see the result printed at the console.

 Best,

 Philippe

 ..°}))
  ) ) ) ) )
 ( ( ( ( (Prof. Philippe Grosjean
  ) ) ) ) )
 ( ( ( ( (Numerical Ecology of Aquatic Systems
  ) ) ) ) )   Mons-Hainaut University, Pentagone (3D08)
 ( ( ( ( (Academie Universitaire Wallonie-Bruxelles
  ) ) ) ) )   8, av du Champ de Mars, 7000 Mons, Belgium
 ( ( ( ( (
  ) ) ) ) )   phone: + 32.65.37.34.97, fax: + 32.65.37.30.54
 ( ( ( ( (email: [EMAIL PROTECTED]
  ) ) ) ) )
 ( ( ( ( (web:   http://www.umh.ac.be/~econum
  ) ) ) ) )  http://www.sciviews.org
 ( ( ( ( (
 ..

 Marco Zucchelli wrote:
 Hi Philippe and R community,

  I am trying to use some functions from the svDialogs package but I get 
 some werid errors I do not understand:


library(svDialogs)


m_list - as.list(1:10)



guiDlgDoubleList(m_list, m_list)

 Error in guiDlgDoubleList(m_list, m_list) :
 Not yet implemented!



guiDlgList(m_list)

 Error in guiDlgList(m_list) : couldn't find function guiSetFonts.tcltk




 Am I doing anything wrong ?? Do I need some other package?



 Marco





 [[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-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] Snow package -- Results

2005-06-22 Thread Naji
First, many thanks to Simon Urbanek for his help.

A simulation case (50x34x5x3  250 replications) each based on behavior of
2500 consumers takes
- 2h20mins on a laptop (2 MHz, 1Go, WinXp)
- 1h on a G5 bi-proc (2.5 Mhz, 2Go)
A loop was used for the laptop, the same loop was transposed as function for
the Mac

Best regards
Naji

__
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] A question on time-dependent covariates in the Cox model.

2005-06-22 Thread Jacob Etches
This is a question about time-varying effects rather than time-varying 
covariates, even if the SAS method tests for the former by using the 
latter.  SAS evaluates the line

 dosetime=time*dose;

for all observations at each event time as it estimates the model, such 
that you are not using future information.  It has the effect of 
testing for a linear change in the magnitude of the effect of dose over 
time.  I believe Paul Allison's survival book recommends this as a 
quick and dirty test for constancy of effect.  Had you put that line in 
a datastep prior to PHREG, rather than in PHREG, you'd get a completely 
different (and uninformative) result (probably the same as R is giving 
you), because each observation's total survival time would be used to 
create a single value for the interaction term.  You could manually 
replicate SAS's behaviour in R if you wanted, but every observation 
would have to start a new time interval whenever any other observation 
has an event, as Peter explained below.

You might also want to look at Aalen's additive survival model for 
non-linear changes in effect over time:
http://www.med.uio.no/imb/stat/addreg/

hope that helps,
Jacob Etches


On 2005/06/22, at 06:34, Peter Dalgaard wrote:

 Marianne dk [EMAIL PROTECTED] writes:

 I have a dataset with

 event=death
 time (from medical examination until death/censoring)
 dose (given at examination time)

 Two groups are considered, a non-exposed group (dose=0), an exposed 
 group
 (dose between 5 and 60).

 For some reason there is a theory of the dose increasing its effect 
 over
 time (however it was only given (and measured) once = at the time of
 examination).

 I tested a model:

 coxph(Surv(time,dod)~dose + dose:time)

 Previously I tested the model in SAS:

 proc phreg data=test;
  model time*dod(0)=dose dosetime /rl ties=efron;
  dosetime=time*dose;
  run;

 Without the interaction terms I get the same results for the two 
 models. By
 including the interaction terms I do not. The model in R gives a 
 negative
 coefficient for the interaction term which is expected to be positive 
 (and
 is so in SAS). The LRTs are also completely different.

 TWO QUESTIONS:

 1) Is it reasonable to bring in an interaction term when dose is only
 measured once?

 2) If yes, can anyone give a hint on explaining the difference 
 between the
 models in R and SAS?

 I don't know what SAS does, maybe it second-guesses your intentions,
 but R will definitely get it completely wrong. If you use time as a
 covariate, the same time (of death/censoring) will be applied at all
 death times. Pretty obviously, long observation times tend to be
 associated with low mortalities! With interactions you get, er,
 similarly incorrect effects.

 To do coxph with time-dependent variables, you need to split data
 into little time segments, according to the death time of every death,
 inserting a new variable (ntime, say) which is the time of the
 endpoint of the interval.

 -- 
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

__
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] nlme leading minor error

2005-06-22 Thread Douglas Bates
On 6/22/05, Petr Pikal [EMAIL PROTECTED] wrote:
 Dear all
 
 I am struggling with nlme and error message. Even going through
 Pinheiro, Bates nlme book did not gave me a clue how to avoid
 this.
 
 fit - nlme(ce ~ fi1 / ((1+exp(fi2-fi3*tepl))^(1/fi4)), data =
 temp1na.gr,
 start = c(fi1=30, fi2=-100, fi3=-.05, fi4=40),
 fixed = fi1+fi2+fi3+fi4~1,
 random = pdDiag(fi2+fi4~1),
 groups = ~spol.f)
 
 gives
 
 Error in chol((value + t(value))/2) : the leading minor of order 1 is
 not positive definite
 
 Is this error due to lack of experimental points?
 Here you have one typical part of my data. It is for level spol.f =
 3/11.
 
 teplce
 800 28.87
 800 29.35
 825 29
 850 28.73
 875 26.83
 900 24.07
 
 I have 1-5 points for each level (2 levels with 5 points, 1 level with
 4 points, several levels with 2 and 3 points and few with only one
 point.
 
 Fitting this model to each level separately led to several sets of
 coeficients fi1-fi4 and the separate fits were quite OK.
 
 Please give me a hint what can be the cause for this error message
 and how I shall organize my data to avoid this. (Lack of
 experimental points is also an answer as I can do some subsequent
 measurement.

The first thing to do is to plot the data for each level of spol.f and
see if it is reasonable that you would be able to estimate four
parameters from such a curve.

Then try setting verbose = TRUE, control = list(msVerbose = TRUE) in
your call to nlme to see how the parameters are being changed during
the iterations.

__
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] A polar.plot BUG in plotrix 1.3.3 ?

2005-06-22 Thread Uwe Ligges
Halldor Björnsson wrote:

 Hi,
 
 I just updated to R-2.1.1 and updated packages acordingly
 
 However, after the update, routines that use polar.plot
 did not function as correctly.
 
 In plotrix 1.3.3 the polar.plot function does scale label.pos
 to radians prior to calling radial.plot
 
 Hence, the command
 polar.plot(c(5,10,5,0),c(-10,0,10,20),rp.type='P',
  labels=c(A,N,V,S),label.pos=c(0,90,180,270))
 
 produces absurd compass lines but the correct results are obtained if 
 label.pos is scaled with pi/180 :
 
 polar.plot(c(5,10,5,0),c(-10,0,10,20),rp.type='P',
  labels=c(A,N,V,S),label.pos=c(0,90,180,270)*pi/180)
 
 I have attatched the polar.plot function from the two different versions 
 of the package.
 
 It seems that if not missing  then label.pos is not changed at all in 
 version 1.3.3
 
 So, a feature or a bug?
 
 Sincerely,

Obviously this is a question for the author and maintainer of the 
package (in CC).

Uwe Ligges

__
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] Subsetting across a frame for plotting

2005-06-22 Thread Morten Sickel
 

Fra: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] På vegne av Liaw, Andy

You might save yourself some headaches by turning it into a matrix instead, 
since all the columns are either integer or numeric:
tonedata - data.matrix(tonedata)

Data frames are really lists, so even when you get a one-row subset, it's 
still a one-row data frame.  You can use unlist() to turn 
that into a vector.

Andy

Great, Andy, thanks! unlist was what I was looking for. 

Morten

__
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] r programming help

2005-06-22 Thread Mohammad Ehsanul Karim
Dear list,

Is there anyway i can make the following formula short
by r-programming?

CYCLE.n-c(NA,
WET[1]*DRY[1],
WET[1]*DRY[2]+WET[2]*DRY[1],
WET[1]*DRY[3]+WET[2]*DRY[2]+WET[3]*DRY[1],
WET[1]*DRY[4]+WET[2]*DRY[3]+WET[3]*DRY[2]+WET[4]*DRY[1],
WET[1]*DRY[5]+WET[2]*DRY[4]+WET[3]*DRY[3]+WET[4]*DRY[2]+WET[5]*DRY[1],
WET[1]*DRY[6]+WET[2]*DRY[5]+WET[3]*DRY[4]+WET[4]*DRY[3]+WET[5]*DRY[2]+WET[6]*DRY[1],
WET[1]*DRY[7]+WET[2]*DRY[6]+WET[3]*DRY[5]+WET[4]*DRY[4]+WET[5]*DRY[3]+WET[6]*DRY[2]+WET[7]*DRY[1],
WET[1]*DRY[8]+WET[2]*DRY[7]+WET[3]*DRY[6]+WET[4]*DRY[5]+WET[5]*DRY[4]+WET[6]*DRY[3]+WET[7]*DRY[2]+WET[8]*DRY[1],
WET[1]*DRY[9]+WET[2]*DRY[8]+WET[3]*DRY[7]+WET[4]*DRY[6]+WET[5]*DRY[5]+WET[6]*DRY[4]+WET[7]*DRY[3]+WET[8]*DRY[2]+WET[9]*DRY[1],
WET[1]*DRY[10]+WET[2]*DRY[9]+WET[3]*DRY[8]+WET[4]*DRY[7]+WET[5]*DRY[6]+WET[6]*DRY[5]+WET[7]*DRY[4]+WET[8]*DRY[3]+WET[9]*DRY[2]+WET[10]*DRY[1],
WET[1]*DRY[11]+WET[2]*DRY[10]+WET[3]*DRY[9]+WET[4]*DRY[8]+WET[5]*DRY[7]+WET[6]*DRY[6]+WET[7]*DRY[5]+WET[8]*DRY[4]+WET[9]*DRY[3]+WET[10]*DRY[2]+WET[11]*DRY[1],
WET[1]*DRY[12]+WET[2]*DRY[11]+WET[3]*DRY[10]+WET[4]*DRY[9]+WET[5]*DRY[8]+WET[6]*DRY[7]+WET[7]*DRY[6]+WET[8]*DRY[5]+WET[9]*DRY[4]+WET[10]*DRY[3]+WET[11]*DRY[2]+WET[12]*DRY[1],
WET[1]*DRY[13]+WET[2]*DRY[12]+WET[3]*DRY[11]+WET[4]*DRY[10]+WET[5]*DRY[9]+WET[6]*DRY[8]+WET[7]*DRY[7]+WET[8]*DRY[6]+WET[9]*DRY[5]+WET[10]*DRY[4]+WET[11]*DRY[3]+WET[12]*DRY[2]+WET[13]*DRY[1],
WET[1]*DRY[14]+WET[2]*DRY[13]+WET[3]*DRY[12]+WET[4]*DRY[11]+WET[5]*DRY[10]+WET[6]*DRY[9]+WET[7]*DRY[8]+WET[8]*DRY[7]+WET[9]*DRY[6]+WET[10]*DRY[5]+WET[11]*DRY[4]+WET[12]*DRY[3]+WET[13]*DRY[2]+WET[14]*DRY[1],
WET[1]*DRY[15]+WET[2]*DRY[14]+WET[3]*DRY[13]+WET[4]*DRY[12]+WET[5]*DRY[11]+WET[6]*DRY[10]+WET[7]*DRY[9]+WET[8]*DRY[8]+WET[9]*DRY[7]+WET[10]*DRY[6]+WET[11]*DRY[5]+WET[12]*DRY[4]+WET[13]*DRY[3]+WET[14]*DRY[2]+WET[15]*DRY[1],
WET[1]*DRY[16]+WET[2]*DRY[15]+WET[3]*DRY[14]+WET[4]*DRY[13]+WET[5]*DRY[12]+WET[6]*DRY[11]+WET[7]*DRY[10]+WET[8]*DRY[9]+WET[9]*DRY[8]+WET[10]*DRY[7]+WET[11]*DRY[6]+WET[12]*DRY[5]+WET[13]*DRY[4]+WET[14]*DRY[3]+WET[15]*DRY[2]+WET[16]*DRY[1],
WET[1]*DRY[17]+WET[2]*DRY[16]+WET[3]*DRY[15]+WET[4]*DRY[14]+WET[5]*DRY[13]+WET[6]*DRY[12]+WET[7]*DRY[11]+WET[8]*DRY[10]+WET[9]*DRY[9]+WET[10]*DRY[8]+WET[11]*DRY[7]+WET[12]*DRY[6]+WET[13]*DRY[5]+WET[14]*DRY[4]+WET[15]*DRY[3]+WET[16]*DRY[2]+WET[17]*DRY[1],
WET[1]*DRY[18]+WET[2]*DRY[17]+WET[3]*DRY[16]+WET[4]*DRY[15]+WET[5]*DRY[14]+WET[6]*DRY[13]+WET[7]*DRY[12]+WET[8]*DRY[11]+WET[9]*DRY[10]+WET[10]*DRY[9]+WET[11]*DRY[8]+WET[12]*DRY[7]+WET[13]*DRY[6]+WET[14]*DRY[5]+WET[15]*DRY[4]+WET[16]*DRY[3]+WET[17]*DRY[2]+WET[18]*DRY[1],
WET[1]*DRY[19]+WET[2]*DRY[18]+WET[3]*DRY[17]+WET[4]*DRY[16]+WET[5]*DRY[15]+WET[6]*DRY[15]+WET[7]*DRY[13]+WET[8]*DRY[12]+WET[9]*DRY[11]+WET[10]*DRY[10]+WET[11]*DRY[9]+WET[12]*DRY[8]+WET[13]*DRY[7]+WET[14]*DRY[6]+WET[15]*DRY[5]+WET[16]*DRY[4]+WET[17]*DRY[3]+WET[18]*DRY[2]+WET[19]*DRY[1],
WET[1]*DRY[20]+WET[2]*DRY[19]+WET[3]*DRY[18]+WET[4]*DRY[17]+WET[5]*DRY[16]+WET[6]*DRY[15]+WET[7]*DRY[14]+WET[8]*DRY[13]+WET[9]*DRY[12]+WET[10]*DRY[11]+WET[11]*DRY[10]+WET[12]*DRY[9]+WET[13]*DRY[8]+WET[14]*DRY[7]+WET[15]*DRY[6]+WET[16]*DRY[5]+WET[17]*DRY[4]+WET[18]*DRY[3]+WET[19]*DRY[2]+WET[20]*DRY[1],
WET[1]*DRY[21]+WET[2]*DRY[20]+WET[3]*DRY[19]+WET[4]*DRY[18]+WET[5]*DRY[17]+WET[6]*DRY[16]+WET[7]*DRY[15]+WET[8]*DRY[14]+WET[9]*DRY[13]+WET[10]*DRY[12]+WET[11]*DRY[11]+WET[12]*DRY[10]+WET[13]*DRY[9]+WET[14]*DRY[8]+WET[15]*DRY[7]+WET[16]*DRY[6]+WET[17]*DRY[5]+WET[18]*DRY[4]+WET[19]*DRY[3]+WET[20]*DRY[2]+WET[21]*DRY[1],
WET[1]*DRY[22]+WET[2]*DRY[21]+WET[3]*DRY[20]+WET[4]*DRY[19]+WET[5]*DRY[18]+WET[6]*DRY[17]+WET[7]*DRY[16]+WET[8]*DRY[15]+WET[9]*DRY[14]+WET[10]*DRY[13]+WET[11]*DRY[12]+WET[12]*DRY[11]+WET[13]*DRY[10]+WET[14]*DRY[9]+WET[15]*DRY[8]+WET[16]*DRY[7]+WET[17]*DRY[6]+WET[18]*DRY[5]+WET[19]*DRY[4]+WET[20]*DRY[3]+WET[21]*DRY[2]+WET[22]*DRY[1],
WET[1]*DRY[23]+WET[2]*DRY[22]+WET[3]*DRY[21]+WET[4]*DRY[20]+WET[5]*DRY[19]+WET[6]*DRY[18]+WET[7]*DRY[17]+WET[8]*DRY[16]+WET[9]*DRY[15]+WET[10]*DRY[14]+WET[11]*DRY[13]+WET[12]*DRY[12]+WET[13]*DRY[11]+WET[14]*DRY[10]+WET[15]*DRY[9]+WET[16]*DRY[8]+WET[17]*DRY[7]+WET[18]*DRY[6]+WET[19]*DRY[5]+WET[20]*DRY[4]+WET[21]*DRY[3]+WET[22]*DRY[2]+WET[23]*DRY[1],
WET[1]*DRY[24]+WET[2]*DRY[23]+WET[3]*DRY[22]+WET[4]*DRY[21]+WET[5]*DRY[20]+WET[6]*DRY[19]+WET[7]*DRY[18]+WET[8]*DRY[17]+WET[9]*DRY[16]+WET[10]*DRY[15]+WET[11]*DRY[14]+WET[12]*DRY[13]+WET[13]*DRY[12]+WET[14]*DRY[11]+WET[15]*DRY[10]+WET[16]*DRY[9]+WET[17]*DRY[8]+WET[18]*DRY[7]+WET[19]*DRY[6]+WET[20]*DRY[5]+WET[21]*DRY[4]+WET[22]*DRY[3]+WET[23]*DRY[2]+WET[24]*DRY[1],
WET[1]*DRY[25]+WET[2]*DRY[24]+WET[3]*DRY[23]+WET[4]*DRY[22]+WET[5]*DRY[21]+WET[6]*DRY[20]+WET[7]*DRY[19]+WET[8]*DRY[18]+WET[9]*DRY[17]+WET[10]*DRY[16]+WET[11]*DRY[15]+WET[12]*DRY[14]+WET[13]*DRY[13]+WET[14]*DRY[12]+WET[15]*DRY[11]+WET[16]*DRY[10]+WET[17]*DRY[9]+WET[18]*DRY[8]+WET[19]*DRY[7]+WET[20]*DRY[6]+WET[21]*DRY[5]+WET[22]*DRY[4]+WET[23]*DRY[3]+WET[24]*DRY[2]+WET[25]*DRY[1],

[R] Extract Coeff, Std Error, etc from gnls output

2005-06-22 Thread Christian Mora
Dear list members;

Is there any trick to extract the coefficients along with std errors,
t-values and p-values for each beta from a gnls fit model (similar to the
results obtained using summary(lm)$coeff for linear models)?

Thanks for any hint

cm

__
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] Contour Plots

2005-06-22 Thread Bernard L. Dillard
Hello all.

I'm confused a bit about contour plots.  After reading the help at
?contour, it seems as though the contour plot is for 3D plots (x,y, and
z).  My data is in the form of grid coordinates (x,y), and I want to see a
contour plot of the data so that I can tell where most observations lie. 
My question is simple but still evasive.

Say my data is called places.  One column is X and another is Y.  Or,

  places$X  places$Y

Coordinate 1  32   50
Coordinate 2  15   33
Coordinate 3  28   20
etc

How do I get R to do the contour plot with no third z coordinate?

Thanks.

-- 
Do all you can with what you have in the time you have in the place you are!

-Nkosi Johnson, 12-year old African hero

__
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 trying to use boot and lme together

2005-06-22 Thread Michael Dewey
At 23:09 21/06/05, Prof Brian Ripley wrote:
On Tue, 21 Jun 2005, Douglas Bates wrote:

On 6/21/05, Søren Højsgaard [EMAIL PROTECTED] wrote:

Thanks everyone for your help, more comments at the foot

The problem with simulate.lme is that it only returns logL for a given 
model fitted to a simulated data set  - not the simulated data set 
itself (which one might have expected a function with that name to 
do...). It would be nice with that functionality...
Søren

You could add it.  You just need to create a matrix that will be large
enough to hold all the simulated data sets and fill a column (or row
if you prefer but column is probably better because of the way that
matrices are stored) during each iteration of the simulation and
remember to include that matrix in the returned object.

Note: you don't need to store it: you can do the analysis at that point 
and return the statistics you want, rather than just logL.

I did say `see simulate.lme', not `use simulate.lme'.  I know nlme is no 
longer being developed, but if it were I would be suggesting/contributing 
a modification that allowed the user to specify an `extraction' function 
from the fit -- quite a few pieces of bootstrap code work that way.

--
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

This has been most informative for me. Given the rather stern comments in 
Pinheiro and Bates that most things do not have the reference distribution 
you might naively think I now realise that simulate.lme is more important 
than its rather cursory treatment in the book. As suggested I have looked 
at the code but although I can see broadly what each section does I lack 
the skill to modify it myself. I will have to wait for someone more gifted.

If there is to be a successor edition to Pinheiro and Bates perhaps I could 
suggest that this topic merits a bit more discussion?


Michael Dewey
[EMAIL PROTECTED]
http://www.aghmed.fsnet.co.uk/home.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] Contour Plots

2005-06-22 Thread Liaw, Andy
I guess what you want is contours of the density over the x-y plane.  There
are a few choices that I know of:

kde2d in MASS (part of the `VR' bundle)
bkde2d in KernSmooth
sm.density in sm
locfit in locfit

Andy

 From: Bernard L. Dillard
 
 Hello all.
 
 I'm confused a bit about contour plots.  After reading the help at
 ?contour, it seems as though the contour plot is for 3D 
 plots (x,y, and
 z).  My data is in the form of grid coordinates (x,y), and I 
 want to see a
 contour plot of the data so that I can tell where most 
 observations lie. 
 My question is simple but still evasive.
 
 Say my data is called places.  One column is X and another is Y.  Or,
 
   places$X  places$Y
 
 Coordinate 1  32   50
 Coordinate 2  15   33
 Coordinate 3  28   20
 etc
 
 How do I get R to do the contour plot with no third z coordinate?
 
 Thanks.
 
 -- 
 Do all you can with what you have in the time you have in the 
 place you are!
 
 -Nkosi Johnson, 12-year old African hero
 
 __
 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] Kouros Owzar is ooo.

2005-06-22 Thread Kouros Owzar

I will be out of the office starting  06/21/2005 and will not return until
06/29/2005.

__
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] r programming help

2005-06-22 Thread Peter Dalgaard
Mohammad Ehsanul Karim [EMAIL PROTECTED] writes:

 Dear list,
 
 Is there anyway i can make the following formula short
 by r-programming?
 
 CYCLE.n-c(NA,
 WET[1]*DRY[1],
 WET[1]*DRY[2]+WET[2]*DRY[1],
 WET[1]*DRY[3]+WET[2]*DRY[2]+WET[3]*DRY[1],


As far as I can see: 

z - toeplitz(DRY)
z[upper.tri(z)] - 0
c(NA, z %*% WET)

or convolve() with suitable options, padding, and/or cutting (but
beware, there could be devils in the details). convolve(WET,DRY,
type=o) gives you about twice what you need, I believe.


-- 
   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


[R] (slightly off topic, but...) More of a stat design question...

2005-06-22 Thread David L. Van Brunt, Ph.D.
With such a wide range of backgrounds here, I thought I'd toss this out here 
to get ideas.

I've lucked into some clinical trial data where schizophrenic patients were 
randomly assigned to start on one of three drugs, then were followed 
naturalistically over a year (or more, depending on when they enrolled). 
They were assessed with a standard battery of instruments at baseline, and 
at regular intervals. Apart from the initial random assignment, treatment 
decisions were left up to patients and their doctors. Thus, one of the main 
outcomes of the trial is the all-cause time to discontinuation which is 
believed to be the patient-centric tipping point where the risks and costs 
of using the drug outweight the benefit, so the patient either switches or 
just stops. The outcome variable, therefore, is a censored time variable. I 
have the number of days, and a flag to identify if that number is actual 
discontinuation or just the end of observation.

Now, the a priori analysis is done and gone (Cox regression of which drug 
had longest time to d/c), and a more clinical question has come up: using 
these data, can we build a model to predict, for each patient, the drug 
which is likely to be best for that individual. Sounds like a bayesian 
opportunity to me, a separate model for each drug based on an analysis of 
the patients randomized to each drug, then apply each model to a holdout 
sample, and see if patients matched to therapy did better than patients who 
were not.

If I were just predicting a single continuous measure, or a dichotomous 
outcome, I'd have no problem. The question is, given that the outcome is a 
censored time variable, which approaches would get me closest to the 
posterior probability of success or expected number of days, give or take 
Y in the clinical sense, not the frequentist sense (if you repeated this 
study K times,...)?

Just interested in hearing some thoughts on this.

---
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


Re: [R] predict.coxph fitted values for failure times

2005-06-22 Thread Thomas Lumley
On Wed, 22 Jun 2005, Dan Bebber wrote:

 I would like to extract predicted failure times from a
 coxph model in library(survival). However, none of the
 prediction options (lp, risk, expected, terms)
 seem to bear any relationship to failure time.

 Perhaps I am asking the wrong question, but can coxph
 provide predicted failure times?


It's tricky, because it depends what you mean by predicted. It's 
typically impossible to estimate the mean survival time for given 
covariates when there is censoring.  You can use survfit() on your Cox 
model to get predicted survival curves.

-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] Is it possible to get the first letter of a word?

2005-06-22 Thread Navarre Sabine
Hi,
I would to get the first letter of a word like:

 title_cat
   TitleCat
1 Training
 
I would like T from Training!

Thnaks a lot for your help
 
Sabine


-

 Téléchargez le ici !  
[[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] Is it possible to get the first letter of a word?

2005-06-22 Thread Uwe Ligges
Navarre Sabine wrote:

 Hi,
 I would to get the first letter of a word like:
 
 
title_cat
 
TitleCat
 1 Training
  
 I would like T from Training!
 
 Thnaks a lot for your help



substr(title_cat,1,1)

Uwe Ligges

 Sabine
 
   
 -
 
  Téléchargez le ici !  
   [[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-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] Is it possible to get the first letter of a word?

2005-06-22 Thread Liaw, Andy
Use substring() or substr().

Andy

 From: Navarre Sabine
 
 Hi,
 I would to get the first letter of a word like:
 
  title_cat
TitleCat
 1 Training
  
 I would like T from Training!
 
 Thnaks a lot for your help
  
 Sabine
 
   
 -
 
  Téléchargez le ici !  
   [[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] Is it possible to get the first letter of a word?

2005-06-22 Thread Chuck Cleland
?substring

Navarre Sabine wrote:
 Hi,
 I would to get the first letter of a word like:
 
 
title_cat
 
TitleCat
 1 Training
  
 I would like T from Training!
 
 Thnaks a lot for your help
  
 Sabine
 
   
 -
 
  Téléchargez le ici !  
   [[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

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894

__
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] Is it possible to get the first letter of a word?

2005-06-22 Thread Ken Knoblauch
or What about;

 strsplit(Training, split=)[[1]][1]
[1] T


Ken Knoblauch
Inserm U371, Cerveau et Vision
Department of Cognitive Neurosciences
18 avenue du Doyen Lepine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: 06 84 10 64 10
http://www.lyon.inserm.fr/371/

__
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] Is it possible to get the first letter of a word?

2005-06-22 Thread Marc Schwartz
On Wed, 2005-06-22 at 16:42 +0200, Navarre Sabine wrote:
 Hi,
 I would to get the first letter of a word like:
 
  title_cat
TitleCat
 1 Training
  
 I would like T from Training!
 
 Thnaks a lot for your help
  
 Sabine


There are multiple approaches, but you need to be careful, since it
appears that your object is a factor. Thus you may need to convert to a
character vector first:

 title_cat - factor(Training)

 substr(as.character(title_cat), 1, 1)
[1] T


Otherwise:

 title_cat - Training

 substr(title_cat, 1, 1)
[1] T

See ?substr for more information.

HTH,

Marc Schwartz

__
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] Contour Plots

2005-06-22 Thread Uwe Ligges
Bernard L. Dillard wrote:

 Hello all.
 
 I'm confused a bit about contour plots.  After reading the help at
 ?contour, it seems as though the contour plot is for 3D plots (x,y, and
 z).  My data is in the form of grid coordinates (x,y), and I want to see a
 contour plot of the data so that I can tell where most observations lie. 
 My question is simple but still evasive.
 
 Say my data is called places.  One column is X and another is Y.  Or,
 
   places$X  places$Y
 
 Coordinate 1  32   50
 Coordinate 2  15   33
 Coordinate 3  28   20
 etc
 
 How do I get R to do the contour plot with no third z coordinate?

For just 2 columns, a contour plot does not make much sense, I guess.
I think an image() makes much more sense in this case.

Your z matrix consists of the entries of the data.frame/matrix given 
above, the x and y vectors are the column and row numbers.


Uwe Ligges



 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


[R] Howto crosstable-ing......

2005-06-22 Thread v . demartino2
I receive the following meteo dataset regularly, containing the average
daily temperatures (tMedia) of a certain month for 24 selected meteo-stations
(COD_WMO) whose human-readable names are in (NOME).

str(tabella)
`data.frame':   1038 obs. of  4 variables:
 $ COD_WMO: int  16045 16045 16045 16045 16045 16045 16045 16045 16045 16045
...
 $ NOME   : Factor w/ 24 levels ALGHERO,BARI/PALESE MACCHIE,..: 22 22
22 22 22 22 22 22 22 22 ...
 $ DATE   :'POSIXct', format: chr  2005-05-01 2005-05-02 2005-05-03
2005-05-04 ...
 $ tMedia : num  11.7 18.6 16.9 19.7 15.0 ...


Here you are a short list of it:
COD_WMO  NOME   DATE   tMedia
505   16191 FALCONARA 2005-06-01  20.95
506   16191 FALCONARA 2005-06-02  20.15
507   16191 FALCONARA 2005-06-03  18.60
506   16191 FALCONARA 2005-06-02  20.15
507   16191 FALCONARA 2005-06-03  18.60
508   16191 FALCONARA 2005-06-04  22.30
509   16191 FALCONARA 2005-06-05 NA
510   16191 FALCONARA 2005-06-06 NA
511   16191 FALCONARA 2005-06-07  18.20
549   16206 GROSSETO 2005-06-01  20.65
550   16206 GROSSETO 2005-06-02  21.95
551   16206 GROSSETO 2005-06-03  22.25
552   16206 GROSSETO 2005-06-04  20.15
553   16206 GROSSETO 2005-06-05 NA
554   16206 GROSSETO 2005-06-06 NA
555   16206 GROSSETO 2005-06-07  22.35
.
.


I need to rearrange tMedia into a new dataframe whose column names are COD_WMO
 (or   NOME) and the row is DATE.

ex.
DATEALGHERO   BARI/PALESE   FALCONARA  GROSSETO ..
2005-06-01   16.3 12.8   17.3  
 14.0   ...
2005-06-02   18.2   8.918.0
  17.9   ..
...


I read some pieces of R-docs in the internet and run the MASS chapter 2
examples but without finding anything suitable to my purpose.

Could you please help me?

Ciao

Vittorio

__
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] legend

2005-06-22 Thread Uwe Ligges
Thomas Steiner wrote:

 I color some area grey with polygon() (with a red border) and then I
 want to have the dashed red border in the legend as well. How do I
 manage it?
 
 And I want to mix (latex) expressions with text in my legend.


Both points are not that easy to solve, hence I'd like to suggest to 
write your own little function that generates the legend.

Starting at the upper left, calculating the stringheight, painting the 
(party very special) symbols, and adding the text line by line seems to 
be the most easiest solution here (which is not that nice, though.

Uwe Ligges


 Just execute my lines below and you know want I mean. Or pass by at
 http://de.wikipedia.org/wiki/Bild:GBM.png to see the picture online.
 
 Thomas
 
 
 bm - function(n=500, from=0, to=1) {
   x=seq(from=from,to=to,length=n)
   BM-c(0,cumsum(rnorm(n-1,mean=0,sd=sqrt(to/n
   cbind(x,BM)
 }
 gbm - function(bm,S0=1,sigma=0.1,mu=1) {
   gbm=S0
   for (t in 2:length(bm[,1])) {
 gbm[t]=S0*exp((mu-sigma^2/2)*bm[t,1]+sigma*bm[t,2])
   }
   cbind(bm[,1],gbm)
 }
 
 set.seed(9826064)
 cs=c(dark green, steelblue, red, yellow)
 
 #png(filename = GBM.png, width=1600, height=1200, pointsize = 12)
 par(bg=lightgrey)
 x=seq(from=0,to=1,length=500)
 plot(x=x, y=exp(0.7*x), type=n, xlab=Zeit, ylab=, ylim=c(1,3.5))
 polygon(x=c(x,rev(x)),
 y=c(exp(0.7*x)+0.4*sqrt(x),rev(exp(0.7*x)-0.4*sqrt(x))), col=grey,
 border=cs[3], lty=dashed)
 lines(x=x,y=exp(0.7*x), type=l, lwd=3, col=cs[1])
 lines(gbm(bm(),S0=1,mu=0.7,sigma=0.4), lwd=3, col=cs[2])
 lines(gbm(bm(),S0=1,mu=0.7,sigma=0.2), lwd=3, col=cs[3])
 lines(gbm(bm(),S0=1,mu=0.7,sigma=0.1), lwd=3, col=cs[4])
 title(main=Geometrische Brownsche Bewegung,cex.main=2.5)
 legend(x=0,y=3.5,legend=c(exp(0.7x),mu=0.7, sigma=0.4,mu=0.7,
 sigma=0.2,mu=0.7, sigma=0.1,Standardabweichung für 
 sigma=0.2),lwd=c(4,4,4,4,12),col=c(cs,grey),bg=transparent,cex=1.15)
 #dev.off()
 
 __
 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] Howto crosstable-ing......

2005-06-22 Thread Uwe Ligges
See ?reshape

Uwe Ligges

[EMAIL PROTECTED] wrote:

 I receive the following meteo dataset regularly, containing the average
 daily temperatures (tMedia) of a certain month for 24 selected meteo-stations
 (COD_WMO) whose human-readable names are in (NOME).
 
 str(tabella)
 `data.frame': 1038 obs. of  4 variables:
  $ COD_WMO: int  16045 16045 16045 16045 16045 16045 16045 16045 16045 16045
 ...
  $ NOME   : Factor w/ 24 levels ALGHERO,BARI/PALESE MACCHIE,..: 22 22
 22 22 22 22 22 22 22 22 ...
  $ DATE   :'POSIXct', format: chr  2005-05-01 2005-05-02 2005-05-03
 2005-05-04 ...
  $ tMedia : num  11.7 18.6 16.9 19.7 15.0 ...
 
 
 Here you are a short list of it:
 COD_WMO  NOME   DATE   tMedia
 505   16191 FALCONARA 2005-06-01  20.95
 506   16191 FALCONARA 2005-06-02  20.15
 507   16191 FALCONARA 2005-06-03  18.60
 506   16191 FALCONARA 2005-06-02  20.15
 507   16191 FALCONARA 2005-06-03  18.60
 508   16191 FALCONARA 2005-06-04  22.30
 509   16191 FALCONARA 2005-06-05 NA
 510   16191 FALCONARA 2005-06-06 NA
 511   16191 FALCONARA 2005-06-07  18.20
 549   16206 GROSSETO 2005-06-01  20.65
 550   16206 GROSSETO 2005-06-02  21.95
 551   16206 GROSSETO 2005-06-03  22.25
 552   16206 GROSSETO 2005-06-04  20.15
 553   16206 GROSSETO 2005-06-05 NA
 554   16206 GROSSETO 2005-06-06 NA
 555   16206 GROSSETO 2005-06-07  22.35
 .
 .
 
 
 I need to rearrange tMedia into a new dataframe whose column names are COD_WMO
  (or   NOME) and the row is DATE.
 
 ex.
 DATEALGHERO   BARI/PALESE   FALCONARA  GROSSETO ..
 2005-06-01   16.3 12.8   17.3  
  14.0   ...
 2005-06-02   18.2   8.918.0
   17.9   ..
 ...
 
 
 I read some pieces of R-docs in the internet and run the MASS chapter 2
 examples but without finding anything suitable to my purpose.
 
 Could you please help me?
 
 Ciao
 
 Vittorio
 
 __
 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] chisq test and fisher exact test

2005-06-22 Thread Weiwei Shi
Hi,
I have a text mining project and currently I am working on feature
generation/selection part.
My plan is selecting a set of words or word combinations which have
better discriminant capability than other words in telling the group
id's (2 classes in this case) for a dataset which has 2,000,000
documents.

One approach is using contrast-set association rule mining while the
other is using chisqr or fisher exact test.

An example which has 3 contingency tables for 3 words as followed
(word coded by number):
 tab[,,1:3]
, , 1

  [,1][,2]
[1,] 11266 2151526
[2,]   125   31734

, , 2

  [,1][,2]
[1,] 43571 2119221
[2,]52   31807

, , 3

 [,1][,2]
[1,]  427 2162365
[2,]5   31854


I have some questions on this:
1. What's the thumb of rule to use chisq test instead of Fisher exact
test. I have a  vague memory which said for each cell, the count needs
to be over 50 if chisq instead of fisher exact test is going to be
used. In the case of word 3,  I think I should use fisher test.
However, running chisq like below is fine:
 tab[,,3]
 [,1][,2]
[1,]  427 2162365
[2,]5   31854
 chisq.test(tab[,,3])

Pearson's Chi-squared test with Yates' continuity correction

data:  tab[, , 3]
X-squared = 0.0963, df = 1, p-value = 0.7564

but running on the whole set of words (including 14240 words) has the
following warnings:
 p.chisq-as.double(lapply(1:N, function(i) chisq.test(tab[,,i])$p.value))
There were 50 or more warnings (use warnings() to see the first 50)
 warnings()
Warning messages:
1: Chi-squared approximation may be incorrect in: chisq.test(tab[, , i])
2: Chi-squared approximation may be incorrect in: chisq.test(tab[, , i])
3: Chi-squared approximation may be incorrect in: chisq.test(tab[, , i])
4: Chi-squared approximation may be incorrect in: chisq.test(tab[, , i])


2. So, my second question is, is this warning b/c I am against the
assumption of using chisq. But why Word 3 is fine? How to trace the
warning to see which word caused this warning?

3. My result looks like this (after some mapping treating from number
id to word and some words are stemmed here, like ACCID is accident):
  of[1:50,]
  map...2.  p.fisher
21   ACCID  0.00e+00
30  CD  0.00e+00
67ROCK  0.00e+00
104  CRACK  0.00e+00
111   CHIP  0.00e+00
179  GLASS  0.00e+00
84BACK 4.199878e-291
395   DRIVEABL 5.335989e-287
60 CAP 9.405235e-285
262 WINDSHIELD 2.691641e-254
13  IV 3.905186e-245
110 HZ 2.819713e-210
11CAMP 9.086768e-207
2  SHATTER 5.273994e-202
297ALP 1.678521e-177
162BED 1.822031e-173
249BCD 1.398391e-160
493   RACK 4.178617e-156
59CAUS 7.539031e-147

3.1 question: Should I use two-sided test instead of one-sided for
fisher test? I read some material which suggests using two-sided.

3.2 A big question: Even though the result looks very promising since
this is case of classiying fraud cases and the words selected by this
approach make sense. However, I think p-values here just indicate the
strength to reject null hypothesis, not the strength of association
between word and class of document. So, what kind of statistics I
should use here to evaluate the strength of association? odds ratio?

Any suggestions are welcome!

Thanks!
-- 
Weiwei Shi, Ph.D

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

__
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] Howto crosstable-ing......

2005-06-22 Thread Liaw, Andy
Looks to me like you want something like reshape()...

Andy

 From: [EMAIL PROTECTED]
 
 I receive the following meteo dataset regularly, containing 
 the average
 daily temperatures (tMedia) of a certain month for 24 
 selected meteo-stations
 (COD_WMO) whose human-readable names are in (NOME).
 
 str(tabella)
 `data.frame': 1038 obs. of  4 variables:
  $ COD_WMO: int  16045 16045 16045 16045 16045 16045 16045 
 16045 16045 16045
 ...
  $ NOME   : Factor w/ 24 levels ALGHERO,BARI/PALESE 
 MACCHIE,..: 22 22
 22 22 22 22 22 22 22 22 ...
  $ DATE   :'POSIXct', format: chr  2005-05-01 2005-05-02 
 2005-05-03
 2005-05-04 ...
  $ tMedia : num  11.7 18.6 16.9 19.7 15.0 ...
 
 
 Here you are a short list of it:
 COD_WMO  NOME   DATE   tMedia
 505   16191 FALCONARA 2005-06-01  20.95
 506   16191 FALCONARA 2005-06-02  20.15
 507   16191 FALCONARA 2005-06-03  18.60
 506   16191 FALCONARA 2005-06-02  20.15
 507   16191 FALCONARA 2005-06-03  18.60
 508   16191 FALCONARA 2005-06-04  22.30
 509   16191 FALCONARA 2005-06-05 NA
 510   16191 FALCONARA 2005-06-06 NA
 511   16191 FALCONARA 2005-06-07  18.20
 549   16206 GROSSETO 2005-06-01  20.65
 550   16206 GROSSETO 2005-06-02  21.95
 551   16206 GROSSETO 2005-06-03  22.25
 552   16206 GROSSETO 2005-06-04  20.15
 553   16206 GROSSETO 2005-06-05 NA
 554   16206 GROSSETO 2005-06-06 NA
 555   16206 GROSSETO 2005-06-07  22.35
 .
 .
 
 
 I need to rearrange tMedia into a new dataframe whose column 
 names are COD_WMO
  (or   NOME) and the row is DATE.
 
 ex.
 DATEALGHERO   BARI/PALESE   FALCONARA  
 GROSSETO ..
 2005-06-01   16.3 12.8   17.3 
  
  14.0   ...
 2005-06-02   18.2   8.9
 18.0
   17.9   ..
 ..
 .
 
 
 I read some pieces of R-docs in the internet and run the MASS 
 chapter 2
 examples but without finding anything suitable to my purpose.
 
 Could you please help me?
 
 Ciao
 
 Vittorio
 
 __
 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] r programming help

2005-06-22 Thread Peter Wolf
Try:

  DRY-c(2,5,3,7,11)
  WET-(1:5)*10
  print(filter(c(rep(0,length(WET)),DRY),WET))

Time Series:
Start = 1
End = 10
Frequency = 1
[1]  NA  NA   0  20  90 190 360 640  NA  NA

  CYCLE.n-c(NA,
  WET[1]*DRY[1],
  WET[1]*DRY[2]+WET[2]*DRY[1],
  WET[1]*DRY[3]+WET[2]*DRY[2]+WET[3]*DRY[1],
  WET[1]*DRY[4]+WET[2]*DRY[3]+WET[3]*DRY[2]+WET[4]*DRY[1],
  WET[1]*DRY[5]+WET[2]*DRY[4]+WET[3]*DRY[3]+WET[4]*DRY[2]+WET[5]*DRY[1])
  print(CYCLE.n)
[1]  NA  20  90 190 360 640

Peter Wolf

Mohammad Ehsanul Karim wrote:

Dear list,

Is there anyway i can make the following formula short
by r-programming?

CYCLE.n-c(NA,
WET[1]*DRY[1],
WET[1]*DRY[2]+WET[2]*DRY[1],
WET[1]*DRY[3]+WET[2]*DRY[2]+WET[3]*DRY[1],
WET[1]*DRY[4]+WET[2]*DRY[3]+WET[3]*DRY[2]+WET[4]*DRY[1],
WET[1]*DRY[5]+WET[2]*DRY[4]+WET[3]*DRY[3]+WET[4]*DRY[2]+WET[5]*DRY[1],
WET[1]*DRY[6]+WET[2]*DRY[5]+WET[3]*DRY[4]+WET[4]*DRY[3]+WET[5]*DRY[2]+WET[6]*DRY[1],
WET[1]*DRY[7]+WET[2]*DRY[6]+WET[3]*DRY[5]+WET[4]*DRY[4]+WET[5]*DRY[3]+WET[6]*DRY[2]+WET[7]*DRY[1],
WET[1]*DRY[8]+WET[2]*DRY[7]+WET[3]*DRY[6]+WET[4]*DRY[5]+WET[5]*DRY[4]+WET[6]*DRY[3]+WET[7]*DRY[2]+WET[8]*DRY[1],
WET[1]*DRY[9]+WET[2]*DRY[8]+WET[3]*DRY[7]+WET[4]*DRY[6]+WET[5]*DRY[5]+WET[6]*DRY[4]+WET[7]*DRY[3]+WET[8]*DRY[2]+WET[9]*DRY[1],
WET[1]*DRY[10]+WET[2]*DRY[9]+WET[3]*DRY[8]+WET[4]*DRY[7]+WET[5]*DRY[6]+WET[6]*DRY[5]+WET[7]*DRY[4]+WET[8]*DRY[3]+WET[9]*DRY[2]+WET[10]*DRY[1],
WET[1]*DRY[11]+WET[2]*DRY[10]+WET[3]*DRY[9]+WET[4]*DRY[8]+WET[5]*DRY[7]+WET[6]*DRY[6]+WET[7]*DRY[5]+WET[8]*DRY[4]+WET[9]*DRY[3]+WET[10]*DRY[2]+WET[11]*DRY[1],
WET[1]*DRY[12]+WET[2]*DRY[11]+WET[3]*DRY[10]+WET[4]*DRY[9]+WET[5]*DRY[8]+WET[6]*DRY[7]+WET[7]*DRY[6]+WET[8]*DRY[5]+WET[9]*DRY[4]+WET[10]*DRY[3]+WET[11]*DRY[2]+WET[12]*DRY[1],
WET[1]*DRY[13]+WET[2]*DRY[12]+WET[3]*DRY[11]+WET[4]*DRY[10]+WET[5]*DRY[9]+WET[6]*DRY[8]+WET[7]*DRY[7]+WET[8]*DRY[6]+WET[9]*DRY[5]+WET[10]*DRY[4]+WET[11]*DRY[3]+WET[12]*DRY[2]+WET[13]*DRY[1],
WET[1]*DRY[14]+WET[2]*DRY[13]+WET[3]*DRY[12]+WET[4]*DRY[11]+WET[5]*DRY[10]+WET[6]*DRY[9]+WET[7]*DRY[8]+WET[8]*DRY[7]+WET[9]*DRY[6]+WET[10]*DRY[5]+WET[11]*DRY[4]+WET[12]*DRY[3]+WET[13]*DRY[2]+WET[14]*DRY[1],
WET[1]*DRY[15]+WET[2]*DRY[14]+WET[3]*DRY[13]+WET[4]*DRY[12]+WET[5]*DRY[11]+WET[6]*DRY[10]+WET[7]*DRY[9]+WET[8]*DRY[8]+WET[9]*DRY[7]+WET[10]*DRY[6]+WET[11]*DRY[5]+WET[12]*DRY[4]+WET[13]*DRY[3]+WET[14]*DRY[2]+WET[15]*DRY[1],
WET[1]*DRY[16]+WET[2]*DRY[15]+WET[3]*DRY[14]+WET[4]*DRY[13]+WET[5]*DRY[12]+WET[6]*DRY[11]+WET[7]*DRY[10]+WET[8]*DRY[9]+WET[9]*DRY[8]+WET[10]*DRY[7]+WET[11]*DRY[6]+WET[12]*DRY[5]+WET[13]*DRY[4]+WET[14]*DRY[3]+WET[15]*DRY[2]+WET[16]*DRY[1],
WET[1]*DRY[17]+WET[2]*DRY[16]+WET[3]*DRY[15]+WET[4]*DRY[14]+WET[5]*DRY[13]+WET[6]*DRY[12]+WET[7]*DRY[11]+WET[8]*DRY[10]+WET[9]*DRY[9]+WET[10]*DRY[8]+WET[11]*DRY[7]+WET[12]*DRY[6]+WET[13]*DRY[5]+WET[14]*DRY[4]+WET[15]*DRY[3]+WET[16]*DRY[2]+WET[17]*DRY[1],
WET[1]*DRY[18]+WET[2]*DRY[17]+WET[3]*DRY[16]+WET[4]*DRY[15]+WET[5]*DRY[14]+WET[6]*DRY[13]+WET[7]*DRY[12]+WET[8]*DRY[11]+WET[9]*DRY[10]+WET[10]*DRY[9]+WET[11]*DRY[8]+WET[12]*DRY[7]+WET[13]*DRY[6]+WET[14]*DRY[5]+WET[15]*DRY[4]+WET[16]*DRY[3]+WET[17]*DRY[2]+WET[18]*DRY[1],
WET[1]*DRY[19]+WET[2]*DRY[18]+WET[3]*DRY[17]+WET[4]*DRY[16]+WET[5]*DRY[15]+WET[6]*DRY[15]+WET[7]*DRY[13]+WET[8]*DRY[12]+WET[9]*DRY[11]+WET[10]*DRY[10]+WET[11]*DRY[9]+WET[12]*DRY[8]+WET[13]*DRY[7]+WET[14]*DRY[6]+WET[15]*DRY[5]+WET[16]*DRY[4]+WET[17]*DRY[3]+WET[18]*DRY[2]+WET[19]*DRY[1],
WET[1]*DRY[20]+WET[2]*DRY[19]+WET[3]*DRY[18]+WET[4]*DRY[17]+WET[5]*DRY[16]+WET[6]*DRY[15]+WET[7]*DRY[14]+WET[8]*DRY[13]+WET[9]*DRY[12]+WET[10]*DRY[11]+WET[11]*DRY[10]+WET[12]*DRY[9]+WET[13]*DRY[8]+WET[14]*DRY[7]+WET[15]*DRY[6]+WET[16]*DRY[5]+WET[17]*DRY[4]+WET[18]*DRY[3]+WET[19]*DRY[2]+WET[20]*DRY[1],
WET[1]*DRY[21]+WET[2]*DRY[20]+WET[3]*DRY[19]+WET[4]*DRY[18]+WET[5]*DRY[17]+WET[6]*DRY[16]+WET[7]*DRY[15]+WET[8]*DRY[14]+WET[9]*DRY[13]+WET[10]*DRY[12]+WET[11]*DRY[11]+WET[12]*DRY[10]+WET[13]*DRY[9]+WET[14]*DRY[8]+WET[15]*DRY[7]+WET[16]*DRY[6]+WET[17]*DRY[5]+WET[18]*DRY[4]+WET[19]*DRY[3]+WET[20]*DRY[2]+WET[21]*DRY[1],
WET[1]*DRY[22]+WET[2]*DRY[21]+WET[3]*DRY[20]+WET[4]*DRY[19]+WET[5]*DRY[18]+WET[6]*DRY[17]+WET[7]*DRY[16]+WET[8]*DRY[15]+WET[9]*DRY[14]+WET[10]*DRY[13]+WET[11]*DRY[12]+WET[12]*DRY[11]+WET[13]*DRY[10]+WET[14]*DRY[9]+WET[15]*DRY[8]+WET[16]*DRY[7]+WET[17]*DRY[6]+WET[18]*DRY[5]+WET[19]*DRY[4]+WET[20]*DRY[3]+WET[21]*DRY[2]+WET[22]*DRY[1],
WET[1]*DRY[23]+WET[2]*DRY[22]+WET[3]*DRY[21]+WET[4]*DRY[20]+WET[5]*DRY[19]+WET[6]*DRY[18]+WET[7]*DRY[17]+WET[8]*DRY[16]+WET[9]*DRY[15]+WET[10]*DRY[14]+WET[11]*DRY[13]+WET[12]*DRY[12]+WET[13]*DRY[11]+WET[14]*DRY[10]+WET[15]*DRY[9]+WET[16]*DRY[8]+WET[17]*DRY[7]+WET[18]*DRY[6]+WET[19]*DRY[5]+WET[20]*DRY[4]+WET[21]*DRY[3]+WET[22]*DRY[2]+WET[23]*DRY[1],

Re: [R] Howto crosstable-ing......

2005-06-22 Thread Marc Schwartz
On Wed, 2005-06-22 at 17:12 +0200, [EMAIL PROTECTED] wrote:
 I receive the following meteo dataset regularly, containing the average
 daily temperatures (tMedia) of a certain month for 24 selected meteo-stations
 (COD_WMO) whose human-readable names are in (NOME).
 
 str(tabella)
 `data.frame': 1038 obs. of  4 variables:
  $ COD_WMO: int  16045 16045 16045 16045 16045 16045 16045 16045 16045 16045
 ...
  $ NOME   : Factor w/ 24 levels ALGHERO,BARI/PALESE MACCHIE,..: 22 22
 22 22 22 22 22 22 22 22 ...
  $ DATE   :'POSIXct', format: chr  2005-05-01 2005-05-02 2005-05-03
 2005-05-04 ...
  $ tMedia : num  11.7 18.6 16.9 19.7 15.0 ...
 
 
 Here you are a short list of it:
 COD_WMO  NOME   DATE   tMedia
 505   16191 FALCONARA 2005-06-01  20.95
 506   16191 FALCONARA 2005-06-02  20.15
 507   16191 FALCONARA 2005-06-03  18.60
 506   16191 FALCONARA 2005-06-02  20.15
 507   16191 FALCONARA 2005-06-03  18.60
 508   16191 FALCONARA 2005-06-04  22.30
 509   16191 FALCONARA 2005-06-05 NA
 510   16191 FALCONARA 2005-06-06 NA
 511   16191 FALCONARA 2005-06-07  18.20
 549   16206 GROSSETO 2005-06-01  20.65
 550   16206 GROSSETO 2005-06-02  21.95
 551   16206 GROSSETO 2005-06-03  22.25
 552   16206 GROSSETO 2005-06-04  20.15
 553   16206 GROSSETO 2005-06-05 NA
 554   16206 GROSSETO 2005-06-06 NA
 555   16206 GROSSETO 2005-06-07  22.35
 .
 .
 
 
 I need to rearrange tMedia into a new dataframe whose column names are COD_WMO
  (or   NOME) and the row is DATE.
 
 ex.
 DATEALGHERO   BARI/PALESE   FALCONARA  GROSSETO ..
 2005-06-01   16.3 12.8   17.3  
  14.0   ...
 2005-06-02   18.2   8.918.0
   17.9   ..
 ...
 
 
 I read some pieces of R-docs in the internet and run the MASS chapter 2
 examples but without finding anything suitable to my purpose.
 
 Could you please help me?
 
 Ciao
 
 Vittorio

I believe that the following will get you there, based upon your example
output above:

 reshape(tabella[, -1], idvar = DATE, timevar = NOME, 
  v.names = tMedia, direction = wide)
DATE tMedia.FALCONARA tMedia.GROSSETO
1 2005-06-0120.95   20.65
2 2005-06-0220.15   21.95
3 2005-06-0318.60   22.25
6 2005-06-0422.30   20.15
7 2005-06-05   NA  NA
8 2005-06-06   NA  NA
9 2005-06-0718.20   22.35

See ?reshape for more information.

HTH,

Marc Schwartz

__
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] r programming help

2005-06-22 Thread Don MacQueen
In addition to Peter's suggestion of converting 
to a matrix operation, here is a simple solution 
using naive R programming.

Using the 7th element of CYCLE.n as an example:
 replace this:
WET[1]*DRY[6]+WET[2]*DRY[5]+WET[3]*DRY[4]+WET[4]*DRY[3]+WET[5]*DRY[2]+WET[6]*DRY[1]
with this:
sum(WET[1:6]*DRY[6:1])

which then suggests a loop.

nin - length(WET)
CYCLE.n - rep(NA,nin+1)
for (i in 1:nin) CYCLE.n[i+1] - sum(WET[1:i]*DRY[i:1])


-Don

At 4:03 PM +0200 6/22/05, Peter Dalgaard wrote:
Mohammad Ehsanul Karim [EMAIL PROTECTED] writes:

  Dear list,

  Is there anyway i can make the following formula short
  by r-programming?

  CYCLE.n-c(NA,
  WET[1]*DRY[1],
  WET[1]*DRY[2]+WET[2]*DRY[1],
  WET[1]*DRY[3]+WET[2]*DRY[2]+WET[3]*DRY[1],


As far as I can see:

z - toeplitz(DRY)
z[upper.tri(z)] - 0
c(NA, z %*% WET)

or convolve() with suitable options, padding, and/or cutting (but
beware, there could be devils in the details). convolve(WET,DRY,
type=o) gives you about twice what you need, I believe.


--
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


-- 
--
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] Extract Coeff, Std Error, etc from gnls output

2005-06-22 Thread Douglas Bates
On 6/22/05, Christian Mora [EMAIL PROTECTED] wrote:
 Dear list members;
 
 Is there any trick to extract the coefficients along with std errors,
 t-values and p-values for each beta from a gnls fit model (similar to the
 results obtained using summary(lm)$coeff for linear models)?

The best way to get the coefficients is with the extractor function
coef.  There is no extractor for the t-values and the p-values so you
need to look at the result of str(summary(gnlsfit)) to find the name
of the component.

__
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] monitoring objects sizes

2005-06-22 Thread Omar Lakkis
I have an R script that loops over market contracts. The script runs
well for markets with relatively small number of contracts but seg
faults when the number of contracts (loop iterations) is large.
Is there a way for me to monitor my objects and their sizes from
within the R script?
How can I get all of the objects and their sizes?

__
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] chisq test and fisher exact test

2005-06-22 Thread Kjetil Brinchmann Halvorsen
Weiwei Shi wrote:

Hi,
I have a text mining project and currently I am working on feature
generation/selection part.
My plan is selecting a set of words or word combinations which have
better discriminant capability than other words in telling the group
id's (2 classes in this case) for a dataset which has 2,000,000
documents.

One approach is using contrast-set association rule mining while the
other is using chisqr or fisher exact test.

An example which has 3 contingency tables for 3 words as followed
(word coded by number):
  

tab[,,1:3]


, , 1

  [,1][,2]
[1,] 11266 2151526
[2,]   125   31734

, , 2

  [,1][,2]
[1,] 43571 2119221
[2,]52   31807

, , 3

 [,1][,2]
[1,]  427 2162365
[2,]5   31854


I have some questions on this:
1. What's the thumb of rule to use chisq test instead of Fisher exact
test. I have a  vague memory which said for each cell, the count needs
to be over 50 if chisq instead of fisher exact test is going to be
used. In the case of word 3,  I think I should use fisher test.
However, running chisq like below is fine:
  

tab[,,3]


 [,1][,2]
[1,]  427 2162365
[2,]5   31854
  

chisq.test(tab[,,3])



Pearson's Chi-squared test with Yates' continuity correction

data:  tab[, , 3]
X-squared = 0.0963, df = 1, p-value = 0.7564

but running on the whole set of words (including 14240 words) has the
following warnings:
  

p.chisq-as.double(lapply(1:N, function(i) chisq.test(tab[,,i])$p.value))


There were 50 or more warnings (use warnings() to see the first 50)
  

warnings()


Warning messages:
1: Chi-squared approximation may be incorrect in: chisq.test(tab[, , i])
2: Chi-squared approximation may be incorrect in: chisq.test(tab[, , i])
3: Chi-squared approximation may be incorrect in: chisq.test(tab[, , i])
4: Chi-squared approximation may be incorrect in: chisq.test(tab[, , i])


2. So, my second question is, is this warning b/c I am against the
assumption of using chisq. But why Word 3 is fine? How to trace the
warning to see which word caused this warning?

3. My result looks like this (after some mapping treating from number
id to word and some words are stemmed here, like ACCID is accident):
  of[1:50,]
  map...2.  p.fisher
21   ACCID  0.00e+00
30  CD  0.00e+00
67ROCK  0.00e+00
104  CRACK  0.00e+00
111   CHIP  0.00e+00
179  GLASS  0.00e+00
84BACK 4.199878e-291
395   DRIVEABL 5.335989e-287
60 CAP 9.405235e-285
262 WINDSHIELD 2.691641e-254
13  IV 3.905186e-245
110 HZ 2.819713e-210
11CAMP 9.086768e-207
2  SHATTER 5.273994e-202
297ALP 1.678521e-177
162BED 1.822031e-173
249BCD 1.398391e-160
493   RACK 4.178617e-156
59CAUS 7.539031e-147

3.1 question: Should I use two-sided test instead of one-sided for
fisher test? I read some material which suggests using two-sided.

3.2 A big question: Even though the result looks very promising since
this is case of classiying fraud cases and the words selected by this
approach make sense. However, I think p-values here just indicate the
strength to reject null hypothesis, not the strength of association
between word and class of document. So, what kind of statistics I
should use here to evaluate the strength of association? odds ratio?

Any suggestions are welcome!

Thanks!
  

You can use chisq.test with sim=TRUE, or call it as usual first, see if 
there is a warning, and then recall
with sim=TRUE.

Kjetil

-- 

Kjetil Halvorsen.

Peace is the most effective weapon of mass construction.
   --  Mahdi Elmandjra




-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.

__
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] monitoring objects sizes

2005-06-22 Thread Liaw, Andy
Do RSiteSearch(ls.obj) and click on the first hit.

Andy

 From: Omar Lakkis
 
 I have an R script that loops over market contracts. The script runs
 well for markets with relatively small number of contracts but seg
 faults when the number of contracts (loop iterations) is large.
 Is there a way for me to monitor my objects and their sizes from
 within the R script?
 How can I get all of the objects and their sizes?
 
 __
 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] monitoring objects sizes

2005-06-22 Thread Spencer Graves
  hel.search(object size) found a function object.size that should 
do what you want.

  spencer graves

Omar Lakkis wrote:

 I have an R script that loops over market contracts. The script runs
 well for markets with relatively small number of contracts but seg
 faults when the number of contracts (loop iterations) is large.
 Is there a way for me to monitor my objects and their sizes from
 within the R script?
 How can I get all of the objects and their sizes?
 
 __
 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

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

[EMAIL PROTECTED]
www.pdf.com http://www.pdf.com
Tel:  408-938-4420
Fax: 408-280-7915

__
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] classes with chron slots

2005-06-22 Thread Sebastian Luque
I'd like to define a class with a chron slot, but:

R require(chron)
R setClass(myclass, representation(datetime = chron))
[1] myclass
Warning message:
undefined slot classes in definition of myclass: datetime(class chron)
in: .completeClassSlots(ClassDef, where)

How should such a class be defined?

Sebastian
-- 
Sebastian P. Luque

__
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] analyzing suvival data using splines (a.k.a., piecewise log-hazard-ratio models)

2005-06-22 Thread Wittner, Ben
I'm looking for software that makes plots such as fig 4 (a)-(e), fig 5 anf fig 7
of
Gray, Robert, Flexible Methods for Analyzing Survival Data Using Splines, with
Applications to Breast Cancer Prognosis, 1992, J Am Stat Assoc, pp 942-51.

In other words, I'm looking for software that takes survival data and a
continuous
covariate as input and computes a curve giving log hazard ratio (or rate of
failure for
a specific time) as a function of the continuous covariate, as well as curves
giving
+-SE for that curve.

A plot of this nature can also be found as figure 4 in Paik, et al., A
Multigene Assay to
Predict Recurrence of Tamoxifen-Treated, Node-Negative Breast Cancer, 2004, New
England
Journal of Medicine, pp 2817-26.

Any help would be greatly appreciated.

Thanks.

-Ben

Ben Wittner
Research fellow, MGH  Harvard Medical School
[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] analyzing suvival data using splines (a.k.a., piecewise log-hazard-ratio models)

2005-06-22 Thread Frank E Harrell Jr
Wittner, Ben wrote:
 I'm looking for software that makes plots such as fig 4 (a)-(e), fig 5 anf 
 fig 7
 of
 Gray, Robert, Flexible Methods for Analyzing Survival Data Using Splines, 
 with
 Applications to Breast Cancer Prognosis, 1992, J Am Stat Assoc, pp 942-51.
 
 In other words, I'm looking for software that takes survival data and a
 continuous
 covariate as input and computes a curve giving log hazard ratio (or rate of
 failure for
 a specific time) as a function of the continuous covariate, as well as curves
 giving
 +-SE for that curve.

library(Design)
d - datadist(mydata); options(datadist='d')
f - cph(Surv(dtime,death) ~ age + sex + rcs(blood.pressure,5))
plot(f, blood.pressure=NA)

Frank

 
 A plot of this nature can also be found as figure 4 in Paik, et al., A
 Multigene Assay to
 Predict Recurrence of Tamoxifen-Treated, Node-Negative Breast Cancer, 2004, 
 New
 England
 Journal of Medicine, pp 2817-26.
 
 Any help would be greatly appreciated.
 
 Thanks.
 
 -Ben
 
 Ben Wittner
 Research fellow, MGH  Harvard Medical School
 [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
 


-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

__
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] Rsquare from glmmPQL or another GLMM?

2005-06-22 Thread Ronaldo Reis-Jr.
Hi,

I know that Rsquare in glm or in non-linear models is wrong, but some people 
like this.

How I make to estimate the Rsquare from a model ajusted with glmmPQL or 
another GLMM?

Thanks for all
Ronaldo
-- 
A simplicidade é o último degrau da sabedoria.
-- Victor Hugo
--
|   // | \\   [***]
|   ( õ   õ )  [Ronaldo Reis Júnior]
|  V  [UFV/DBA-Entomologia]
|/ \   [36570-000 Viçosa - MG  ]
|  /(.''`.)\  [Fone: 31-3899-4007 ]
|  /(: :'  :)\ [EMAIL PROTECTED]]
|/ (`. `'` ) \[ICQ#: 5692561 | LinuxUser#: 205366 ]
|( `-  )   [***]
|  _/   \_Powered by GNU/Debian Woody/Sarge

__
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] load history does not work on OS X

2005-06-22 Thread Steven T. Stoddard
I am running R 2.1 on OSX 10.4 using the precompiled binaries/ 
Raqua.app.  loadhistory() nor load history (from the history  
'drawer') do NOT work.  I can save history files and even see them in  
a text editor just fine, but cannot load any information (even after  
loading library(utils)).

Google and list-searches have been to no avail.

Thanks in advance for any insight ...

Steve

--
Steven T. Stoddard
Program in Ecology and Evolutionary Biology
University of Illinois at Urbana-Champaign

www.life.uiuc.edu/~sstoddar
[EMAIL PROTECTED]
(217) 333 - 2235



[[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] substitute in a named expression

2005-06-22 Thread Søren Højsgaard
I have a 'named expression' like
  expr - expression(rep(1,d))
and would like to replace the argument d with say 5 without actually evaluating 
the expression. So I try  substitute(expr, list(d=5)) in which case R simply 
returns expr which when I 'evaluate' it gives
 eval(expr)
 Error in rep.default(1, d) : invalid number of copies in rep()

I've looked at ?substitute and ?expression (and other places) for ideas, but - 
well I guess there are some details which I haven't quite understood. Can 
anyone point me in the right direction?
Thanks
Søren

__
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] How to sort a dataset by one column?

2005-06-22 Thread Ling Jin
I understand how to sort a vector, but I could not find how to sort a 
data frame or matrix by one variable (column). Could you give me some 
examples? Thanks!

Ling

__
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] string/character to number

2005-06-22 Thread Jake Michaelson
I did a very quick search of the archive and couldn't find a readily 
available answer to this one:

I'd like to convert, for example:

c(a, b, a, b)

to

c(1, -1, 1, -1)

In the case of the first vector, it may be any length, but will always 
only have two unique values.  It must always be replaced by 
corresponding values of 1 and -1.

Any thoughts?

Thanks in advance,

Jake

__
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] string/character to number

2005-06-22 Thread Jake Michaelson
Duh!

sub()

--Jake

On Jun 22, 2005, at 3:35 PM, Jake Michaelson wrote:

 I did a very quick search of the archive and couldn't find a readily
 available answer to this one:

 I'd like to convert, for example:

 c(a, b, a, b)

 to

 c(1, -1, 1, -1)

 In the case of the first vector, it may be any length, but will always
 only have two unique values.  It must always be replaced by
 corresponding values of 1 and -1.

 Any thoughts?

 Thanks in advance,

 Jake

 __
 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] How to sort a dataset by one column?

2005-06-22 Thread Marc Schwartz
On Wed, 2005-06-22 at 14:34 -0700, Ling Jin wrote:
 I understand how to sort a vector, but I could not find how to sort a 
 data frame or matrix by one variable (column). Could you give me some 
 examples? Thanks!
 
 Ling

See the examples in ?order

HTH,

Marc Schwartz

__
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] string/character to number

2005-06-22 Thread Søren Højsgaard
This works
x-c(a, b, a, b)
x[x==a]-1
x[x==b]- -1
as.numeric(x)
[1]  1 -1  1 -1




Fra: [EMAIL PROTECTED] på vegne af Jake Michaelson
Sendt: on 22-06-2005 23:35
Til: R-help@stat.math.ethz.ch
Emne: [R] string/character to number



I did a very quick search of the archive and couldn't find a readily
available answer to this one:

I'd like to convert, for example:

c(a, b, a, b)

to

c(1, -1, 1, -1)

In the case of the first vector, it may be any length, but will always
only have two unique values.  It must always be replaced by
corresponding values of 1 and -1.

Any thoughts?

Thanks in advance,

Jake

__
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] How to sort a dataset by one column?

2005-06-22 Thread Liaw, Andy
See RSiteSearch(sort.data.frame), or more generally, ?order.

Andy

 From: Ling Jin
 
 I understand how to sort a vector, but I could not find how to sort a 
 data frame or matrix by one variable (column). Could you give me some 
 examples? Thanks!
 
 Ling
 
 __
 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] string/character to number

2005-06-22 Thread Berton Gunter
Note: sub() returns a character vector not a numeric vector. as.numeric()
will convert it.

Slightly slicker and faster is: 2*(z=='a')-1   where z is your vector,
c('a','b','a','b')

Cheers,
Bert

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jake Michaelson
Sent: Wednesday, June 22, 2005 2:46 PM
To: Jake Michaelson
Cc: R-help@stat.math.ethz.ch
Subject: Re: [R] string/character to number

Duh!

sub()

--Jake

On Jun 22, 2005, at 3:35 PM, Jake Michaelson wrote:

 I did a very quick search of the archive and couldn't find a readily
 available answer to this one:

 I'd like to convert, for example:

 c(a, b, a, b)

 to

 c(1, -1, 1, -1)

 In the case of the first vector, it may be any length, but will always
 only have two unique values.  It must always be replaced by
 corresponding values of 1 and -1.

 Any thoughts?

 Thanks in advance,

 Jake

 __
 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] string/character to number

2005-06-22 Thread Marc Schwartz
To do this in one step, it would be easier to use ifelse():

 Chars
[1] a b a b

 ifelse(Chars == a, 1, -1)
[1]  1 -1  1 -1

HTH,

Marc Schwartz


On Wed, 2005-06-22 at 15:46 -0600, Jake Michaelson wrote:
 Duh!
 
 sub()
 
 --Jake
 
 On Jun 22, 2005, at 3:35 PM, Jake Michaelson wrote:
 
  I did a very quick search of the archive and couldn't find a readily
  available answer to this one:
 
  I'd like to convert, for example:
 
  c(a, b, a, b)
 
  to
 
  c(1, -1, 1, -1)
 
  In the case of the first vector, it may be any length, but will always
  only have two unique values.  It must always be replaced by
  corresponding values of 1 and -1.
 
  Any thoughts?
 
  Thanks in advance,
 
  Jake
 

__
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] string/character to number

2005-06-22 Thread Liaw, Andy
You can do indexing by name:

 x - c(a, b, a, b)
 v - c(a=1, b=-1)
 v[x]
 a  b  a  b 
 1 -1  1 -1 

Andy 

 From: Jake Michaelson
 
 Duh!
 
 sub()
 
 --Jake
 
 On Jun 22, 2005, at 3:35 PM, Jake Michaelson wrote:
 
  I did a very quick search of the archive and couldn't find a readily
  available answer to this one:
 
  I'd like to convert, for example:
 
  c(a, b, a, b)
 
  to
 
  c(1, -1, 1, -1)
 
  In the case of the first vector, it may be any length, but 
 will always
  only have two unique values.  It must always be replaced by
  corresponding values of 1 and -1.
 
  Any thoughts?
 
  Thanks in advance,
 
  Jake
 
  __
  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] substitute in a named expression

2005-06-22 Thread Gabor Grothendieck
On 6/22/05, Søren Højsgaard [EMAIL PROTECTED] wrote:
 I have a 'named expression' like
  expr - expression(rep(1,d))
 and would like to replace the argument d with say 5 without actually 
 evaluating the expression. So I try  substitute(expr, list(d=5)) in which 
 case R simply returns expr which when I 'evaluate' it gives
  eval(expr)
  Error in rep.default(1, d) : invalid number of copies in rep()
 
 I've looked at ?substitute and ?expression (and other places) for ideas, but 
 - well I guess there are some details which I haven't quite understood. Can 
 anyone point me in the right direction?

Try this:

eval(substitute(substitute(qq, list(d=5)), list(qq = expr[[1]])))

This aspect of R drove me crazy some time ago but Tony Plate finally figured 
it out and discussed it some time back:
   http://tolstoy.newcastle.edu.au/R/help/04/03/1247.html
There is also a handy utility routine, esub, defined there.

The key points are:

- substitute won't go inside expressions but it will go inside call objects.
  In this case your expr is an expression but expr[[1]] is a call object with
  the desired contents.  Note that quote will return a call
  object so you can avoid the [[1]] if you define expr as cl - quote(rep(1,d))
  i.e.  
   cl - quote(rep(1,d))
   eval(substitute(substitute(cl, list(d=5)), list(cl = cl)))

- substitute autoquotes anything inside it so one must substitute in 
  the first argument to the inner substitute using a second outer substitute.  
  That is, the outer substitute substitutes expr[[1]] (which is evaluated) into 
  the first argument of the inner substitute.

- the outer substitute wraps the result of the inner one in a call so we must 
  perform an eval to get what is within the call.  This part is explained in
  ?substitute

Sorry if this is complicated but that seems to be how it works.  Using
the esub function defined in the link above you can simplify it substantially
like this:

esub(cl, list(d=5))

# or

esub(expr[[1]], list(d=5))

__
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] chisq test and fisher exact test

2005-06-22 Thread Weiwei Shi
Is it b/c my question is too long so no one answers it? I should have
splitted it. :(

On 6/22/05, Kjetil Brinchmann Halvorsen [EMAIL PROTECTED] wrote:
 Weiwei Shi wrote:
 
 Hi,
 I have a text mining project and currently I am working on feature
 generation/selection part.
 My plan is selecting a set of words or word combinations which have
 better discriminant capability than other words in telling the group
 id's (2 classes in this case) for a dataset which has 2,000,000
 documents.
 
 One approach is using contrast-set association rule mining while the
 other is using chisqr or fisher exact test.
 
 An example which has 3 contingency tables for 3 words as followed
 (word coded by number):
 
 
 tab[,,1:3]
 
 
 , , 1
 
   [,1][,2]
 [1,] 11266 2151526
 [2,]   125   31734
 
 , , 2
 
   [,1][,2]
 [1,] 43571 2119221
 [2,]52   31807
 
 , , 3
 
  [,1][,2]
 [1,]  427 2162365
 [2,]5   31854
 
 
 I have some questions on this:
 1. What's the thumb of rule to use chisq test instead of Fisher exact
 test. I have a  vague memory which said for each cell, the count needs
 to be over 50 if chisq instead of fisher exact test is going to be
 used. In the case of word 3,  I think I should use fisher test.
 However, running chisq like below is fine:
 
 
 tab[,,3]
 
 
  [,1][,2]
 [1,]  427 2162365
 [2,]5   31854
 
 
 chisq.test(tab[,,3])
 
 
 
 Pearson's Chi-squared test with Yates' continuity correction
 
 data:  tab[, , 3]
 X-squared = 0.0963, df = 1, p-value = 0.7564
 
 but running on the whole set of words (including 14240 words) has the
 following warnings:
 
 
 p.chisq-as.double(lapply(1:N, function(i) chisq.test(tab[,,i])$p.value))
 
 
 There were 50 or more warnings (use warnings() to see the first 50)
 
 
 warnings()
 
 
 Warning messages:
 1: Chi-squared approximation may be incorrect in: chisq.test(tab[, , i])
 2: Chi-squared approximation may be incorrect in: chisq.test(tab[, , i])
 3: Chi-squared approximation may be incorrect in: chisq.test(tab[, , i])
 4: Chi-squared approximation may be incorrect in: chisq.test(tab[, , i])
 
 
 2. So, my second question is, is this warning b/c I am against the
 assumption of using chisq. But why Word 3 is fine? How to trace the
 warning to see which word caused this warning?
 
 3. My result looks like this (after some mapping treating from number
 id to word and some words are stemmed here, like ACCID is accident):
   of[1:50,]
   map...2.  p.fisher
 21   ACCID  0.00e+00
 30  CD  0.00e+00
 67ROCK  0.00e+00
 104  CRACK  0.00e+00
 111   CHIP  0.00e+00
 179  GLASS  0.00e+00
 84BACK 4.199878e-291
 395   DRIVEABL 5.335989e-287
 60 CAP 9.405235e-285
 262 WINDSHIELD 2.691641e-254
 13  IV 3.905186e-245
 110 HZ 2.819713e-210
 11CAMP 9.086768e-207
 2  SHATTER 5.273994e-202
 297ALP 1.678521e-177
 162BED 1.822031e-173
 249BCD 1.398391e-160
 493   RACK 4.178617e-156
 59CAUS 7.539031e-147
 
 3.1 question: Should I use two-sided test instead of one-sided for
 fisher test? I read some material which suggests using two-sided.
 
 3.2 A big question: Even though the result looks very promising since
 this is case of classiying fraud cases and the words selected by this
 approach make sense. However, I think p-values here just indicate the
 strength to reject null hypothesis, not the strength of association
 between word and class of document. So, what kind of statistics I
 should use here to evaluate the strength of association? odds ratio?
 
 Any suggestions are welcome!
 
 Thanks!
 
 
 You can use chisq.test with sim=TRUE, or call it as usual first, see if
 there is a warning, and then recall
 with sim=TRUE.
 
 Kjetil
 
 --
 
 Kjetil Halvorsen.
 
 Peace is the most effective weapon of mass construction.
--  Mahdi Elmandjra
 
 
 
 
 --
 No virus found in this outgoing message.
 Checked by AVG Anti-Virus.
 Version: 7.0.323 / Virus Database: 267.7.7/20 - Release Date: 16/06/2005
 
 


-- 
Weiwei Shi, Ph.D

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

__
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] substitute in a named expression

2005-06-22 Thread Peter Dalgaard
Gabor Grothendieck [EMAIL PROTECTED] writes:

 On 6/22/05, Søren Højsgaard [EMAIL PROTECTED] wrote:
  I have a 'named expression' like
   expr - expression(rep(1,d))
  and would like to replace the argument d with say 5 without actually 
  evaluating the expression. So I try  substitute(expr, list(d=5)) in which 
  case R simply returns expr which when I 'evaluate' it gives
   eval(expr)
   Error in rep.default(1, d) : invalid number of copies in rep()
  
  I've looked at ?substitute and ?expression (and other places) for ideas, 
  but - well I guess there are some details which I haven't quite understood. 
  Can anyone point me in the right direction?
 
 Try this:
 
 eval(substitute(substitute(qq, list(d=5)), list(qq = expr[[1]])))
 
 This aspect of R drove me crazy some time ago but Tony Plate finally figured 
 it out and discussed it some time back:
http://tolstoy.newcastle.edu.au/R/help/04/03/1247.html
 There is also a handy utility routine, esub, defined there.
 
 The key points are:
 
 - substitute won't go inside expressions but it will go inside call objects.
   In this case your expr is an expression but expr[[1]] is a call object with
   the desired contents.  Note that quote will return a call
   object so you can avoid the [[1]] if you define expr as cl - 
 quote(rep(1,d))
   i.e.  
cl - quote(rep(1,d))
eval(substitute(substitute(cl, list(d=5)), list(cl = cl)))
 
 - substitute autoquotes anything inside it so one must substitute in 
   the first argument to the inner substitute using a second outer substitute. 
  
   That is, the outer substitute substitutes expr[[1]] (which is evaluated) 
 into 
   the first argument of the inner substitute.
 
 - the outer substitute wraps the result of the inner one in a call so we must 
   perform an eval to get what is within the call.  This part is explained in
   ?substitute
 
 Sorry if this is complicated but that seems to be how it works.  Using
 the esub function defined in the link above you can simplify it substantially
 like this:
 
 esub(cl, list(d=5))
 
 # or
 
 esub(expr[[1]], list(d=5))

Yes, substitute() is a bass-ackward design and the automatic quoting
of the first arg is a pain. It would have been much cleaner if
standard semantics were used and you'd just quote() the argument when
needed.

Your explanation of 

 eval(substitute(substitute(qq, list(d=5)), list(qq = expr[[1]])))
 
is a tad long-winded though.

What happens is that the inner unevaluated 

substitute(qq, list(d=5))

gets the qq replaced by the value of expr[[1]]. In casu it becomes

substitute(rep(1,d),list(d=5))

this then needs to be evaluated, yielding

rep(1,5)

-- 
   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


[R] How to read an excel data into R?

2005-06-22 Thread Ling Jin
Hi all,

Does anybody know the easiest way to import excel data into R? I copied 
and pasted the excel data into a txt file, and tried read.table, but R 
reported that

Error in read.table(data_support.txt, sep =  , header = T) :
 more columns than column names

Thanks!

Ling

__
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] How to read an excel data into R?

2005-06-22 Thread Spencer Graves
  Your error message tells me that you have different numbers of fields 
in different lines.  You say you, copied and pasted the excel data into 
a txt file.  I usually copy what I want into a clean sheet then File - 
Save, then File - Save As - Save as type = CSV (Comma delimited) 
(*.csv) or Text (Tab delimited) (*.txt).  Excel will ask if I'm sure 
a couple of times, and I say yes.  If that's what you've done and still 
have a problem, then I have other tools:

  First, I'll assign the file name to something like File.  Then, 
'readLines(File, n=9)' tells me if the file starts as I think it does. 
If I've got extra headers, it will tell me that.

  Then, I do something like the following:

  n.flds - count.fields(File, sep=\t)
  plot(n.flds)
  sd(n.flds)

  Then I play with the arguments to count.fields until 'sd(n.flds)' 
is 0.  Then I use read.table with arguments as I used to get 
everything right in 'count.fields'.  If I can't get sd(n.flds) to 0, you 
can try read.table with 'fill=TRUE'.  However, when you do that, you 
need to check to make sure all the columns line up correctly with the 
shorter lines.

  Also, this issue has been discussed many times.  'RSiteSearch(read 
excel)' just produced 1196 hits for me.  If the above doesn't work, you 
might try skimming a few from that list.

  hope this helps.
  spencer graves

Ling Jin wrote:

 Hi all,
 
 Does anybody know the easiest way to import excel data into R? I copied 
 and pasted the excel data into a txt file, and tried read.table, but R 
 reported that
 
 Error in read.table(data_support.txt, sep =  , header = T) :
  more columns than column names
 
 Thanks!
 
 Ling
 
 __
 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

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

[EMAIL PROTECTED]
www.pdf.com http://www.pdf.com
Tel:  408-938-4420
Fax: 408-280-7915

__
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] legend

2005-06-22 Thread Paul Murrell
Hi


Uwe Ligges wrote:
 Thomas Steiner wrote:
 
 
I color some area grey with polygon() (with a red border) and then I
want to have the dashed red border in the legend as well. How do I
manage it?

And I want to mix (latex) expressions with text in my legend.
 
 
 
 Both points are not that easy to solve, hence I'd like to suggest to 
 write your own little function that generates the legend.
 
 Starting at the upper left, calculating the stringheight, painting the 
 (party very special) symbols, and adding the text line by line seems to 
 be the most easiest solution here (which is not that nice, though.


I don't think it's too bad.  For example, try replacing the original ...

legend(x=0,y=3.5,legend=c(exp(0.7x),mu=0.7, sigma=0.4,mu=0.7,
sigma=0.2,mu=0.7, sigma=0.1,Standardabweichung für 
sigma=0.2),lwd=c(4,4,4,4,12),col=c(cs,grey),bg=transparent,cex=1.15)

... with ...

# Use grid and gridBase so you've got some sensible
# coordinate systems to work within
library(grid)
library(gridBase)
# Align a grid viewport with the plotting region
vps - baseViewports()
pushViewport(vps$inner, vps$figure, vps$plot)
# Define labels and colours
# Labels are mathematical expressions
labels - expression(exp(0.7x),
 list(mu == 0.7,sigma == 0.4),
 list(mu == 0.7,sigma == 0.2),
 list(mu == 0.7, sigma == 0.1),
 paste(Standardabweichung für ,sigma == 0.2))
cols - cs
# Draw each legend item on its own line
# Top line 1cm in from top-left corner
for (i in 1:5) {
   x - unit(1, cm)
   y - unit(1, npc) - unit(1, cm) - unit(i, lines)
   if (i  5) {
 grid.lines(unit.c(x, unit(2, cm)), y + unit(0.5, lines),
gp=gpar(col=cols[i], lwd=3))
   } else {
 grid.rect(x, y, width=unit(1, cm),
   height=unit(1, lines),
   gp=gpar(fill=grey, col=cs[3], lty=dashed),
   just=c(left, bottom))
   }
   grid.text(labels[i], x + unit(1.5, cm), y,
 just=c(left, bottom))
}
# clean up
popViewport(3)

... that's a bit of typing, but if you need to do more than one, it 
would go inside a function with labels and cols as arguments (and '5' 
replaced by 'length(labels)') without too much trouble.

(In this case, you could also pretty easily just do the main plot using 
grid and avoid having to use gridBase.)

Paul


Just execute my lines below and you know want I mean. Or pass by at
http://de.wikipedia.org/wiki/Bild:GBM.png to see the picture online.

Thomas


bm - function(n=500, from=0, to=1) {
  x=seq(from=from,to=to,length=n)
  BM-c(0,cumsum(rnorm(n-1,mean=0,sd=sqrt(to/n
  cbind(x,BM)
}
gbm - function(bm,S0=1,sigma=0.1,mu=1) {
  gbm=S0
  for (t in 2:length(bm[,1])) {
gbm[t]=S0*exp((mu-sigma^2/2)*bm[t,1]+sigma*bm[t,2])
  }
  cbind(bm[,1],gbm)
}

set.seed(9826064)
cs=c(dark green, steelblue, red, yellow)

#png(filename = GBM.png, width=1600, height=1200, pointsize = 12)
par(bg=lightgrey)
x=seq(from=0,to=1,length=500)
plot(x=x, y=exp(0.7*x), type=n, xlab=Zeit, ylab=, ylim=c(1,3.5))
polygon(x=c(x,rev(x)),
y=c(exp(0.7*x)+0.4*sqrt(x),rev(exp(0.7*x)-0.4*sqrt(x))), col=grey,
border=cs[3], lty=dashed)
lines(x=x,y=exp(0.7*x), type=l, lwd=3, col=cs[1])
lines(gbm(bm(),S0=1,mu=0.7,sigma=0.4), lwd=3, col=cs[2])
lines(gbm(bm(),S0=1,mu=0.7,sigma=0.2), lwd=3, col=cs[3])
lines(gbm(bm(),S0=1,mu=0.7,sigma=0.1), lwd=3, col=cs[4])
title(main=Geometrische Brownsche Bewegung,cex.main=2.5)
legend(x=0,y=3.5,legend=c(exp(0.7x),mu=0.7, sigma=0.4,mu=0.7,
sigma=0.2,mu=0.7, sigma=0.1,Standardabweichung für 
sigma=0.2),lwd=c(4,4,4,4,12),col=c(cs,grey),bg=transparent,cex=1.15)
#dev.off()

__
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 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


Re: [R] How to read an excel data into R?

2005-06-22 Thread Wensui Liu
Ling,

You might take a look at the function read.xls() in gdata library.

HTH.


On 6/22/05, Ling Jin [EMAIL PROTECTED] wrote:
 Hi all,
 
 Does anybody know the easiest way to import excel data into R? I copied
 and pasted the excel data into a txt file, and tried read.table, but R
 reported that
 
 Error in read.table(data_support.txt, sep =  , header = T) :
  more columns than column names
 
 Thanks!
 
 Ling
 
 __
 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
 


-- 
WenSui Liu, MS MA
Senior Decision Support Analyst
Division of Health Policy and Clinical Effectiveness
Cincinnati Children Hospital Medical Center

__
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] Large number of covariates in survival regressions

2005-06-22 Thread Thomas Davidoff
I am trying to run a survival time regression (no time dependence so  
exponential distribution) with a fairly large but not huge number of  
right hand side variables (about 60).
r seems to not be able to estimate coefficients or standard errors  
for many of the covariates but can for some of the covariates, so I  
don't think this is a missing values problem.
Stata does not have the same problem (although it is slow).
Any thoughts?

Thomas Davidoff
Assistant Professor
Haas School of Business
UC Berkeley
Berkeley, CA 94720
phone: (510) 643-1425
fax:(510) 643-7357
[EMAIL PROTECTED]
http://faculty.haas.berkeley.edu/davidoff


[[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] mac osx, g95 package port problem

2005-06-22 Thread Joel Bremson
Hi all,

I have a working package for linux, including fortran 95 code compiled with 
g95,
that I need to port to OS X. The package works on Linux and seems to load on 
the Mac,
but when I try to run a function that calls C or Fortran I'm told that the 
symbol is not loaded.

I'm developing via a shell account on an OS X system, I don't have access to 
a desktop.
The set up is:

R 2.1.0 Patched (2005-05-12).
Darwin Kernel Version 8.1.0
G95 (GCC 4.0.0 20050124 (experimental) (g95!) 06/20/05)

Here is the Makefile:

F90_FILES=\
dbest_dbase_class.f90 \
...
r_estimate.f90 \

FORTRAN_FILES=\
dgletc.f \
...
mecdf.f

C_FILES=init.c

CFLAGS=-g -fPIC

%.o: %.f90
g95 -c -g $

%.o: %.f
g95 -c -g $

%.o: %.c
gcc -c -g $

bpkg.so: $(F90_FILES:%.f90=%.o) $(C_FILES:%.c=%.o) $(FORTRAN_FILES:%.f=%.o)
g95 -L/Library/Frameworks -o $@ $^ -L/Library/Frameworks/R.framewo\
rk/Resources

-end makefile

Here is the relevant output of R CMD CHECK:

* checking for working latex ...sh: line 1: latex: command not found
NO
* using log directory '/Users/jbremson/dev/bpkg.Rcheck'
* using R version 2.1.0, 2005-05-12
* checking for file 'bpkg/DESCRIPTION' ... OK
* this is package 'bpkg' version '1.0-1'
* checking if this is a source package ... OK

* Installing *source* package 'bpkg' ...
** libs
g95 -c -g dbest_dbase_class.f90
g95 -c -g cm_class.f90
...
gcc -c -g init.c
init.c: In function 'R_g95_init':
init.c:22: warning: incompatible implicit declaration of built-in function 
'strdup'
g95 -c -g dgletc.f
g95 -c -g dglfgb.f
g95 -c -g dglfg.f

g95 -c -g dglfgb.f
g95 -c -g dglfg.f
g95 -c -g dmdc.f
g95 -c -g mecdf.f
g95 -shared -L/Library/Frameworks -o bpkg.so dbest_dbase_class.o cm_class.o 
bgw_cla\
ss.o cm_mle_class.o pcm_dglg_o1.o cm_main.o r_estimate.o init.o dgletc.o 
dglfgb.o dg\
lfg.o dmdc.o mecdf.o -L/Library/Frameworks/R.framework/Resources
g95: unrecognized option '-shared'
** R
** data
** help
 Building/Updating help pages for package 'bpkg'
Formats: text html latex example
estimate.model text html latex example
** building package indices ...
* DONE (bpkg)

* checking package directory ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking DESCRIPTION meta-information ... OK
* checking package dependencies ... OK
* checking index information ... WARNING
Empty file 'INDEX'.
See the information on INDEX files and package subdirectories in section
'Creating R packages' of the 'Writing R Extensions' manual.
* checking package subdirectories ... OK
* checking R files for syntax errors ... OK
* checking R files for library.dynam ... OK
* checking S3 generic/method consistency ... WARNING
Error: package/namespace load failed for 'bpkg'
Call sequence:
2: stop(gettextf(package/namespace load failed for '%s', 
libraryPkgName(package)),\

call. = FALSE, domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose = 
FALSE)
Execution halted
See section 'Generic functions and methods' of the 'Writing R Extensions'
manual.
See section 'Generic functions and methods' of the 'Writing R Extensions'
manual.
* checking replacement functions ... WARNING
Error: package/namespace load failed for 'bpkg'
Call sequence:
2: stop(gettextf(package/namespace load failed for '%s', 
libraryPkgName(package)),\

call. = FALSE, domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose = 
FALSE)
Execution halted
In R, the argument of a replacement function which corresponds to the right
hand side must be named 'value'.
* checking foreign function calls ... WARNING
Error: package/namespace load failed for 'bpkg'
Call sequence:
2: stop(gettextf(package/namespace load failed for '%s', 
libraryPkgName(package)),\

call. = FALSE, domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose = 
FALSE)
Execution halted
See section 'System and foreign language interfaces' of the 'Writing R
Extensions' manual.
* checking Rd files ... OK
* checking for missing documentation entries ... ERROR
Error: package/namespace load failed for 'bpkg'

-EOF

Obviously, there is a package/namespace load filed. I looked at the 
mentioned R documentation and didn't find anything I thought relevant. Here 
is the NAMESPACE file for good measure. The package is called bpkg.

---
useDynLib(bpkg)
export(dummy,estimate.model,em2)
-EOF---

I have checked the bpkg.so file with nm and the symbols for all functions 
are present.

How can I get R to see the symbols for the package?

Regards,

Joel Bremson
Graduate Student
UC Davis

[[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] How to read an excel data into R?

2005-06-22 Thread William Revelle
Ling,

   If  any column has text with spaces between words, this will lead 
to the more columns ... problem.
Delete the spaces and try again.

e.g., if the Excel file is
Var1Var2Var3
text1   2
more text   3   4
yet more5   6
and more7   8
blahblah9   10

On a Mac, this will lead to the error message
Error in scan(file = file, what = what, sep = sep, quote = quote, 
dec = dec,  :
line 1 did not have 4 elements
(which I believe is the equivalent message to what you are getting on a PC)

But, if your remove the blanks in column 1, this reads as

  x - read.table(test.txt,header=T)
  x
   Var1 Var2 Var3
1 text12
2 moretext34
3  yetmore56
4  andmore78
5 blahblah9   10

with no error message.

Alternatively,  for small files, if using a PC try copying the Excel 
spreadsheet to your clipboard and

x  - read.table(file(clipboard), header = TRUE) or, if using a Mac

x  - read.table(pipe(pbpaste), header = TRUE)

Bill


At 8:38 PM -0400 6/22/05, Wensui Liu wrote:
Ling,

You might take a look at the function read.xls() in gdata library.

HTH.


On 6/22/05, Ling Jin [EMAIL PROTECTED] wrote:
  Hi all,

  Does anybody know the easiest way to import excel data into R? I copied
  and pasted the excel data into a txt file, and tried read.table, but R
  reported that

  Error in read.table(data_support.txt, sep =  , header = T) :
   more columns than column names

  Thanks!

   Ling



-- 
William Revelle http://pmc.psych.northwestern.edu/revelle.html   
Professor   http://personality-project.org/personality.html
Department of Psychology   http://www.wcas.northwestern.edu/psych/
Northwestern University http://www.northwestern.edu/

__
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] How to save changed options in Rcmdr

2005-06-22 Thread Shige Song
Dear All,

I want to change the default options of Rcmdr; it seemed to work when
I made changes and click the Exit and Restart R Commander. However,
next time I open Rcmdr, it automatically restored to the default
options. Is there a way to change Rcmdr's options permanently? Thanks!

Shige

__
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