[R] Low level algorithm conrol in Fisher's exact test

2005-11-10 Thread Kihwang Lee
Hi folks,

Forgive me if this question is a trivial issue.

I was doing a series of Fishers' exact test using the fisher.test
function in stats package.
Since the counts I have were quite large (c(64, 3070, 2868, 4961135)), R
suggested me to use
*other algorithms* for the test which can be specified through the
'control' argument of the
fisher.test function as I understood. But where can I find other
algorithms that I can use?
I hoped I could find relevant information in the manual but could not.

Can anybody help me out there?

Many thanks in advance.

Kihwang

__
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] Command line and R

2005-11-10 Thread paul sorenson
Angelo Secchi wrote:
 
 On Wed, 09 Nov 2005 12:25:37 - (GMT)
 (Ted Harding) [EMAIL PROTECTED] wrote:
 
 
On 09-Nov-05 Roger Bivand wrote:

On Wed, 9 Nov 2005, Angelo Secchi wrote:

Hi,
I wrote a small R script (delta.R) using commandArgs(). The script
works from the shell in usual way

R --no-save arg1  delta2.R

Suppose arg1 is the output of another shell command (e.g. gawk,
sed ...). Is there a way to tell R to read arg1 from the
output of the previous command? Any other workaround?

Use shell variables, possibly also Sys.getenv() within R as well as or 
instead of commandArgs().

If it's a fairly simple shell comand (and even if it isn't, though
it could get tricky for complicated ones) you can use the backquote
trick (called, in well-spoken circles, command substitution):

  R --no-save `shellcmd`  delta2.R

As in all shell command lines, wherever you have a command (including
arguments etc.) between backquotes, as exemplified by `shellcmd` above,
the output of the command (as sent to stdout) replaces `shellcmd` in
the command-line. This could be a lot of stuff (depending on what
shellcmd is), or just one value, or whatever.

... and this behaviour is OS (or at least command shell specific) for 
anyone trying this on Windows and wondering why it doesn't work.

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


Re: [R] help with legacy R code

2005-11-10 Thread Uwe Ligges
David Zhao wrote:

 Hi there,
 
 
 Could somebody help me disect this legacy R script I inherited at work, I
 have two questions:
 1. I've tried to upgrade our R version from 1.6.2 (yeah, I know), to R 2.0,
 but some of the lines in this script are not compatible with R 2.0, could
 someone help me figure out where the problem is?
 2. the jpeg generated (attached) seems to be off on some of the data, is
 there a better way of doing this.

1a. R 2.0 must be a software I am not familar with, since for the R I 
know such a version has never been released.
1b. We are unable to reproduce the stuff given below. Not even an error 
message is given.
1c. Do you expect anybody has the time to make your own homework, in 
particular on an unreproducible example? There are very convenient 
debugging tools made available for you in R.
2. We do not see where your jpeg produced with your data is off.


Uwe Ligges

PS: Let me quote
  PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html



 Thanks very much in advance!
 
 David
 
 
  library(MASS)
  jpeg(filename = diswrong.jpg, width = 800, height = 600, pointsize = 12,
 quality = 75, bg = white)
 
  myfunc - function(x, mean, sd, nfalse, ntotal, shape, rate) {
  (nfalse*dgamma(x,shape,rate)+(ntotal-nfalse)*dnorm(x,mean,sd))/ntotal
  }
 
  wrong - scan(wrongrawdata.txt, list(x=0))
  wrongfit - fitdistr(wrong$x, gamma)
  wrongmean - mean(wrong$x)
  wrongshape - wrongfit[[1]][1]
  wrongrate - wrongfit[[1]][2]
 
  good - scan(rawdata.txt, list(x=0))
  xmin = 0
  newx = good$x
  xmean = mean(newx)
 
 
  xmax = max(newx)+0.15
  goodhist - hist(newx, br=seq(from=0,to=xmax,by=0.15), probability=T,
 col=lightyellow)
 
  initmean - (min(newx)+max(newx))/2
  totalx - length(newx)
 
  wrongmeanshift - wrongmean + 0.2
  wrongper - pgamma(wrongmeanshift, wrongshape, wrongrate)
  nfalseundermean -
 which(abs(newx-wrongmeanshift)==min(abs(newx-wrongmeanshift)))
  initnfalse - nfalseundermean / wrongper
 
  fitmean - -1
  fitsd - 0
  fitnfalse - initnfalse
  fitshape - wrongshape
  fitrate - wrongrate
 
  curve((fitnfalse*dgamma(x,fitshape,fitrate))/totalx, add=T, col=red,
 lwd=2)
 
  breaksllength - length(goodhist$breaks)
  endi = breaksllength - 1
  binprob = c(1)
  for (i in 1:endi) {
  expnegative - fitnfalse * (pgamma(goodhist$breaks[i+1],wrongshape,
 wrongrate)-pgamma(goodhist$breaks[i],wrongshape, wrongrate))
  if (goodhist$counts[i] == 0)
  binprob[i] = 0
  else
  binprob[i] = (goodhist$counts[i] - expnegative) / goodhist$counts[i]
  }
 
  result = data.frame(newx)
  prob = c(1)
  for (i in 1:totalx) {
  bini = which ((goodhist$breaks  newx[i])  (goodhist$breaks  newx[i]-0.15
 ))
  if ((binprob[bini]  0.8) | (newx[i]  wrongmean))
  prob[i] = -1
  else
  prob[i] = binprob[bini]*100
  }
 
  result = data.frame(result, prob)
  write.table(result, file=probwrong.txt, sep= , row.name=F, col.name=F)
  fitpars = c(fitmean, fitsd, fitnfalse, fitshape, fitrate, totalx)
  result = data.frame(fitpars)
  write.table(result,file=parwrong.txt, sep= , row.name=F, col.name=F)
  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] Low level algorithm conrol in Fisher's exact test

2005-11-10 Thread Uwe Ligges
Kihwang Lee wrote:

 Hi folks,
 
 Forgive me if this question is a trivial issue.
 
 I was doing a series of Fishers' exact test using the fisher.test
 function in stats package.
 Since the counts I have were quite large (c(64, 3070, 2868, 4961135)), R
 suggested me to use
 *other algorithms* for the test which can be specified through the
 'control' argument of the
 fisher.test function as I understood. But where can I find other
 algorithms that I can use?
 I hoped I could find relevant information in the manual but could not.
 
 Can anybody help me out there?

What about a chisq.test? And honestly, I know the answer before 
calculating anything 

Uwe Ligges


 Many thanks in advance.
 
 Kihwang
 
 __
 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] About: Error in FUN(X[[1]], ...) : symbol print-name too long

2005-11-10 Thread Uwe Ligges
gsmatos1 wrote:

 Hi, 
 
 I´m trying to use the Win2BUGS package from R and I have a similar problem 

R2WinBUGS???


 that reurns with the message: 
 
 Error in FUN(X[[1]], ...) : symbol print-name too long 
 
 But, there is no stray ` character in the file ( Sugestions given by: Duncan 
 Temple Lang duncan 
 Date: Mon, 26 Sep 2005 07:31:08 -0700 ) 
 
 The progam in R is: 
 
 library(R2WinBUGS) 
 library(rbugs) 

Hmm, mixing these two packages might not be a good idea...


 dat - 
 list(x=c(49,48,50,44,54,56,48,48,51,51,50,53,51,50,51,54,50,53,50,49,51,47,53,50,49,55,53,48,54,46),
  
 y=c(50,49,57,52,47,52,58,45,55,54,51,54,56,53,52,47,51,54,50,47,46,44,54,55,52,57,52,48,48,51))
  
 
 dat  - format4Bugs(dat, digits = 0) 

What happens if you omit the line above?

Anyway, I can take closer look, but not within the next 24 hours ...

Uwe Ligges


 parm - c(lbda) 
 
 bugs(dat, inits=list(NULL), parm, d2.bug, 
 n.chains = 1, n.iter = 5000, n.burnin = floor(n.iter/2), 
 n.thin = max(1, floor(n.chains * (n.iter - n.burnin)/1000)), 
 bin = (n.iter - n.burnin) / n.thin, 
 debug = TRUE, DIC = TRUE, digits = 5, codaPkg = FALSE, 
 bugs.directory = C:/WinBUGS14/, 
 working.directory = NULL, clearWD = FALSE) 
 
   The objective of the program is to compare means of two independent 
 samples 
 that results 
   in Beherens-Fisher posterior and in the model.file of WinBUGS d2.bug 
 there is the following codes: 
 
   model 
 { 
for( i in 1 : 30 ) { 
   x[i] ~ dnorm(mu1,sig1) 
} 
for( i in 1 : 30 ) { 
   y[i] ~ dnorm(mu2,sig2) 
} 
mu1 ~ dnorm(50,1.0E-6) 
sig1 ~ dgamma(0.001,0.001) 
mu2 ~ dnorm(50,1.0E-6) 
sig2 ~ dgamma(0.001,0.001) 
lbda - mu1 - mu2 
 } 
 
   I´m a new user of WinBUGS and if someone detect error in the model codes 
 too, I´m grateful. 
 
   Thanks for help! 
   Gilberto Matos. 
 
 
 
 
 model
 {
for( i in 1 : 30 ) {
   x[i] ~ dnorm(mu1,sig1)
}
for( i in 1 : 30 ) {
   y[i] ~ dnorm(mu2,sig2)
}
mu1 ~ dnorm(50,1.0E-6)
sig1 ~ dgamma(0.001,0.001)
mu2 ~ dnorm(50,1.0E-6)
sig2 ~ dgamma(0.001,0.001)
lbda - mu1 - mu2
 }
 
 
 
 
 __
 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] Problems with Shapiro Wilk's test of normality.

2005-11-10 Thread Fredrik Karlsson
Never mind,

I solved it myself. It was an NA problem.

/Fredrik

On 11/9/05, Fredrik Karlsson [EMAIL PROTECTED] wrote:
 Hi,

 I am trying to create a table with information from Shapiro Wilk's
 test of normality.
 However, it fails due to lack of sample size, it says, but the way I
 see it, this is not a problem.
 (See the table of sample sizes (almost) at the bottom).

 Applying a different function using a similar ftable call is not a
 problem (See the bottom table).

 This is R 2.1.0 on Linux (Gentoo).

 /Fredrik

  shapiro.p.value - function(x){
 +   if(length(! is.na(x))  3  length(! is.na(x))  5000 ){
 + p - shapiro.test(x)$p.value
 + return(p)
 +}else{
 +  return(NA)
 +  }
 + }
 
  distribution.table.fun - function(x,na.rm=T,digits=1){
 +
 +   if(length(! is.na(x))  3  length(! is.na(x))  5000){
 +# shapTest - shapiro.test(x)
 +# W - shapTest$statistic
 + W - W
 +   }
 +
 +
 +
 +   shap - shapiro.p.value(x)
 +   stars - ''
 +   premark - ''
 +   postmark - ''
 +   if(length(x)  10){
 +   premark - '\\textit{'
 +   postmark - '}'
 +   }
 +
 +   #skapa stjärnor
 +   if(! is.na(shap)){
 + if( shap = 0.001 ){
 +   stars - '***'
 + }else{
 +   if( shap = 0.01 ){
 + stars - '**'
 +   }else{
 + if( shap = 0.05 ){
 +   stars - '*'
 + }
 +
 +   }
 +
 + }
 +
 + outstr - paste(premark,'W=',W,',p=',shap,postmark,stars,sep=)
 +   }
 +   else{
 + outstr -  
 +   }
 +
 +
 +   return(outstr)
 +
 + }
 
  ftable(tapply(aspvotwork$ampratio,list(Place=aspvotwork$Place,Age=aspvotwork$agemF,voicetype=aspvotwork$Type),FUN=length
   ))
voicetype Voiced Voiceless unaspirated Voiceless aspirated
 Place  Age
 Velar  18 - 24   4441  34
24 - 30   7081  71
30 - 36   5966  64
36 - 42   2527  22
42 - 48   2223  23
48 - 54   12 9   7
 Dental 18 - 24   4861  54
24 - 30   82   101  89
30 - 36   5782  72
36 - 42   1931  34
42 - 48   2533  31
48 - 54   1012  14
 Labial 18 - 24   74   141  84
24 - 30  142   264 162
30 - 36  124   213 148
36 - 42   5091  50
42 - 48   4982  64
48 - 54   1726  16
  ftable(tapply(aspvotwork$ampratio,list(Place=aspvotwork$Place,Age=aspvotwork$agemF,voicetype=aspvotwork$Type),FUN=distribution.table.fun,digits=4))
 Error in shapiro.test(x) : sample size must be between 3 and 5000
 

 ftable(tapply(aspvotwork$ampratio,list(Place=aspvotwork$Place,Age=aspvotwork$agemF,voicetype=aspvotwork$Type),FUN=mean,digits=4,na.rm=TRUE
 ))
voicetypeVoiced Voiceless unaspirated Voiceless aspirated
 Place  Age
 Velar  18 - 24   0.4816810 0.4461307   0.4513994
24 - 30   0.5289028 0.4778686   0.4888445
30 - 36   0.5452949 0.5208633   0.4756369
36 - 42   0.5631310 0.4697789   0.4709779
42 - 48   0.4968318 0.4174068   0.4088855
48 - 54   0.3057712 0.4483639   0.4561953
 Dental 18 - 24   0.4058078 0.4596251   0.4091731
24 - 30   0.4609731 0.4502778   0.4483340
30 - 36   0.5095430 0.4726149   0.4315419
36 - 42   0.4935719 0.4687774   0.4528758
42 - 48   0.4344465 0.4220429   0.4362018
48 - 54   0.3697664 0.4338549   0.4897856
 Labial 18 - 24   0.4327926 0.4879985   0.4503917
24 - 30   0.5309634 0.4839031   0.5927699
30 - 36   0.4094516 0.757   0.3964693
36 - 42   0.5010130 0.480   0.4540598
42 - 48   0.4949510 0.4329442   0.3935921
48 - 54   0.5217893 0.5124186   0.5011346
 



--
My Gentoo + PVR-350 + IVTV + MythTV 

Re: [R] Command line and R

2005-11-10 Thread Prof Brian Ripley
On Thu, 10 Nov 2005, paul sorenson wrote:

 Angelo Secchi wrote:

 On Wed, 09 Nov 2005 12:25:37 - (GMT)
 (Ted Harding) [EMAIL PROTECTED] wrote:


 On 09-Nov-05 Roger Bivand wrote:

 On Wed, 9 Nov 2005, Angelo Secchi wrote:

 Hi,
 I wrote a small R script (delta.R) using commandArgs(). The script
 works from the shell in usual way

 R --no-save arg1  delta2.R

 Suppose arg1 is the output of another shell command (e.g. gawk,
 sed ...). Is there a way to tell R to read arg1 from the
 output of the previous command? Any other workaround?

 Use shell variables, possibly also Sys.getenv() within R as well as or
 instead of commandArgs().

 If it's a fairly simple shell comand (and even if it isn't, though
 it could get tricky for complicated ones) you can use the backquote
 trick (called, in well-spoken circles, command substitution):

  R --no-save `shellcmd`  delta2.R

 As in all shell command lines, wherever you have a command (including
 arguments etc.) between backquotes, as exemplified by `shellcmd` above,
 the output of the command (as sent to stdout) replaces `shellcmd` in
 the command-line. This could be a lot of stuff (depending on what
 shellcmd is), or just one value, or whatever.

 ... and this behaviour is OS (or at least command shell specific) for
 anyone trying this on Windows and wondering why it doesn't work.

But it does work on Windows if you have a reasonable shell.  Cmd.exe is 
and (especially) command.com are not shells in the usually accepted sense.
Better to use Rterm than incur the additional overhead of R, though.

-- 
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] Low level algorithm conrol in Fisher's exact test

2005-11-10 Thread Prof Brian Ripley
On Thu, 10 Nov 2005, Kihwang Lee wrote:

 Hi folks,

 Forgive me if this question is a trivial issue.

 I was doing a series of Fishers' exact test using the fisher.test
 function in stats package.
 Since the counts I have were quite large (c(64, 3070, 2868, 4961135)), R
 suggested me to use
 *other algorithms* for the test which can be specified through the
 'control' argument of the
 fisher.test function as I understood.

Not that I can reproduce.  You cannot change the algorithm that way.

 But where can I find other algorithms that I can use? I hoped I could 
 find relevant information in the manual but could not.

 Can anybody help me out there?

What *exactly* did you see?  I get

 fisher.test(matrix(c(64, 3070, 2868, 4961135), 2))
 FEXACT error 40.
Out of workspace.

 fisher.test(matrix(c(64, 3070, 2868, 4961135), 2), workspace=20e6)
 FEXACT error 501.
The hash table key cannot be computed because the largest key
is larger than the largest representable int.
The algorithm cannot proceed.
Reduce the workspace size or use another algorithm.

Where does it say anything about using control= ?


AFAIK R does not have a means of doing Fisher's test on such a table, and 
it really does not make much statistical sense to do so.  With such 
numbers, the null hypothesis is almost always rejected (try the chisq 
test), even for negligible dependence.

-- 
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] Choosing the data type to improve accuracy in SVM, PPR and randomForest

2005-11-10 Thread jmoreira
Dear all,

This question is not a pure R question but I believe it is quite related.

I am trying to find some literature (without success) about the most appropriate
type for the data I am using. For example: day of the week is it better
represented as a factor or as a number? I am trying to answer this for SVM, PPR
and randomForest.

Thanks for any help

Joao Moreira

__
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] Low level algorithm conrol in Fisher's exact test

2005-11-10 Thread Peter Dalgaard
Uwe Ligges [EMAIL PROTECTED] writes:

 Kihwang Lee wrote:
 
  Hi folks,
  
  Forgive me if this question is a trivial issue.
  
  I was doing a series of Fishers' exact test using the fisher.test
  function in stats package.
  Since the counts I have were quite large (c(64, 3070, 2868, 4961135)), R
  suggested me to use
  *other algorithms* for the test which can be specified through the
  'control' argument of the
  fisher.test function as I understood. But where can I find other
  algorithms that I can use?
  I hoped I could find relevant information in the manual but could not.
  
  Can anybody help me out there?
 
 What about a chisq.test? And honestly, I know the answer before 
 calculating anything 

Actually, chisq.test complains that the expected values are too low...
I.e. you expected less than 5 and got 64! So the chisquare
approximation might not be perfect, but p  2e-16 should be close
enough for jazz.

There's a buglet in the internal FEXACT code that causes it to
allocate a workspace that is way too big for cases like this. If you
really want to know what the p value is, phyper() is less sensitive:

 phyper(63,2932,4964205,3134,lower=FALSE)
[1] 4.512776e-74

(and in cases where one group is much larger than the other, you're
not far off by assuming that the probability in that group is known,
leading to a binomial test:

 binom.test(64,3134,p=2868/4961135)$p.value
[1] 2.368985e-74
)

The control= argument is not too well documented, but according to my
reading of the code, it is only used to set the mult argument to
.C(fexact, ...) and has no effect on the current issue.

Actually, the fexact C code is only used if or=1 (the default), so
another way out is

 fisher.test(M,or=1+1e-15)$p.value
[1] 4.512776e-74
 fisher.test(M,or=1-1e-15)$p.value
[1] 4.512776e-74

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

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


Re: [R] Low level algorithm conrol in Fisher's exact test

2005-11-10 Thread Peter Dalgaard
Prof Brian Ripley [EMAIL PROTECTED] writes:

 
 AFAIK R does not have a means of doing Fisher's test on such a table, and 
 it really does not make much statistical sense to do so.  With such 
 numbers, the null hypothesis is almost always rejected (try the chisq 
 test), even for negligible dependence.

I have to disagree a little here. If the count in the smaller group
had been smaller we would have been well inside the scope of exact
testing, e.g.


 fisher.test(matrix(c(4, 3070, 2868, 4961135), 2),or=1+1e-15)

Fisher's Exact Test for Count Data

data:  matrix(c(4, 3070, 2868, 4961135), 2)
p-value = 0.105
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
 0.6132965 5.7830438
sample estimates:
odds ratio
  2.253824

(And the workspace issue still applies, hence the or= fiddle)

A professional statistician would know enough to switch to the
binomial (or Poisson) approximation, but others might need help.

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

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


Re: [R] Low level algorithm conrol in Fisher's exact test

2005-11-10 Thread Jim Lemon
Prof Brian Ripley wrote:
 
  Where does it say anything about using control= ?

fisher.test(x, y = NULL, workspace = 20, hybrid = FALSE,
 control = list(), or = 1, alternative = two.sided,
 conf.int = TRUE, conf.level = 0.95)
...
control  a list with named components for low level algorithm control.

I could not make any sense out of this, but it seems to indicate that 
this argument either selects or modifies the algorithm used to compute 
the output.

Jim

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


Re: [R] How to find statistics like that.

2005-11-10 Thread Duncan Murdoch
On 11/9/2005 10:01 PM, Adaikalavan Ramasamy wrote:
 I think an alternative is to use a p-value from F distribution. Even
 tough it is not a statistics, it is much easier to explain and popular
 than 1/F. Better yet to report the confidence intervals.

Just curious about your usage:  why do you say a p-value is not a statistic?

Duncan Murdoch

 
 Regards, Adai
 
 
 
 On Wed, 2005-11-09 at 17:09 -0600, Mike Miller wrote:
 
On Wed, 9 Nov 2005, Gao Fay wrote:


Hi there,

Suppose mu is constant, and error is normally distributed with mean 0 and 
fixed variance s. I need to find a statistics that:
Y_i = mu + beta1* I1_i beta2*I2_i + beta3*I1_i*I2_i + +error, where I_i is 1 
Y_i is from group A, and 0 if Y_i is from group B.

It is large when  beta1=beta2=0
It is small when beta1 and/or beta2 is not equal to 0

How can I find it by R? Thank you very much for your time.


That's a funny question.  Usually we want a statistic that is small when 
beta1=beta2=0 and large otherwise.

Why not compute the usual F statistic for the null beta1=beta2=0 and then 
use 1/F as your statistic?

Mike

__
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] Help to multinomial analyses

2005-11-10 Thread Luciana Correia Alves
Dear Sirs,
Could you please be so kind as to send us some information on residuals in 
multinomial logistic models? Is it possible to use R software?
We thank you in advance.

Sincerely yours

Luciana Alves,MSc
Beatriz Leimann, MD




--
Luciana Correia Alves
Doutoranda em Saúde Pública
ENSP - Fiocruz

__
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] silly question on covariable declaration

2005-11-10 Thread Bernat Claramunt
Hi all,
sory f it is too simple
I am new on using R and have not been able to find the answer of my problem in 
the help archives. I am performing a relatively simple aov

aov( var ~ block + block/plot/treatment + season:bloc) it's a bit longer 
but this is how it looks like.

my var is lipid content, starch content,...in wood samples. Now I want to 
add the size of the tree from where the sample was taken as a covariable, 
because I think it could have something to do.
How can I declare it ?

Thanks in advance

Bernat 

[[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] match and %in%

2005-11-10 Thread Luis Ridao Cruz
R-help,

I have two data frames with a commom column (but with different size)
What I want is to get a column (say df1$mycolumn ) according to the
matches of common columns in both data frames.

I have tried this but it is not working:

transform(fb, breidd = ifelse (match (as.character(df1$puntar),
as.character(df2$puntar) )
, df2$breidd, no ) ) )

transform(fb, breidd = ifelse(as.character(df1$puntar) %in%
as.character(df2$puntar)
, df2$breidd, no ) ) )


Thank you in advance

__
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] match and %in%

2005-11-10 Thread Sean Davis
On 11/10/05 6:33 AM, Luis Ridao Cruz [EMAIL PROTECTED] wrote:

 R-help,
 
 I have two data frames with a commom column (but with different size)
 What I want is to get a column (say df1$mycolumn ) according to the
 matches of common columns in both data frames.
 
 I have tried this but it is not working:
 
 transform(fb, breidd = ifelse (match (as.character(df1$puntar),
 as.character(df2$puntar) )
 , df2$breidd, no ) ) )
 
 transform(fb, breidd = ifelse(as.character(df1$puntar) %in%
 as.character(df2$puntar)
 , df2$breidd, no ) ) )


Try looking at ?merge or ?union to see if either will do what you like.

Sean

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


Re: [R] help with legacy R code

2005-11-10 Thread Prof Brian Ripley
1) There is no 'R 2.0'.  What version did you mean?

2) We cannot reproduce your script (no data files), and JPEGs are not 
allowed on R-help: see http://www.r-project.org/mail.html.  (PNGs are, 
though).

3) You have given us no indication of what the problems are nor in which 
lines.

Please give us more usable information.


On Wed, 9 Nov 2005, David Zhao wrote:

 Could somebody help me disect this legacy R script I inherited at work, I
 have two questions:
 1. I've tried to upgrade our R version from 1.6.2 (yeah, I know), to R 2.0,
 but some of the lines in this script are not compatible with R 2.0, could
 someone help me figure out where the problem is?
 2. the jpeg generated (attached) seems to be off on some of the data, is
 there a better way of doing this.


 library(MASS)
 jpeg(filename = diswrong.jpg, width = 800, height = 600, pointsize = 12,
 quality = 75, bg = white)

 myfunc - function(x, mean, sd, nfalse, ntotal, shape, rate) {
 (nfalse*dgamma(x,shape,rate)+(ntotal-nfalse)*dnorm(x,mean,sd))/ntotal
 }

 wrong - scan(wrongrawdata.txt, list(x=0))

...


-- 
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] How to find statistics like that.

2005-11-10 Thread Adaikalavan Ramasamy
If my usage is wrong please correct me. Thank you.

Here are my reason :

1. p-value is a (cumulative) probability and always ranges from 0 to 1.
A test statistic depending on its definition can wider range of possible
values.

2. A test statistics is one that is calculated from the data without the
need of assuming a null distribution. Whereas to calculate p-values, you
need to assume a null distribution or estimate it empirically using
permutation techniques.

3. The directionality of a test statistics may be ignored. For example a
t-statistics of -5 and 5 are equally interesting in a two-sided testing.
But the smaller the p-value, more evidence against the null hypothesis.

Regards, Adai



On Thu, 2005-11-10 at 06:05 -0500, Duncan Murdoch wrote:
 On 11/9/2005 10:01 PM, Adaikalavan Ramasamy wrote:
  I think an alternative is to use a p-value from F distribution. Even
  tough it is not a statistics, it is much easier to explain and popular
  than 1/F. Better yet to report the confidence intervals.
 
 Just curious about your usage:  why do you say a p-value is not a statistic?
 
 Duncan Murdoch
 
  
  Regards, Adai
  
  
  
  On Wed, 2005-11-09 at 17:09 -0600, Mike Miller wrote:
  
 On Wed, 9 Nov 2005, Gao Fay wrote:
 
 
 Hi there,
 
 Suppose mu is constant, and error is normally distributed with mean 0 and 
 fixed variance s. I need to find a statistics that:
 Y_i = mu + beta1* I1_i beta2*I2_i + beta3*I1_i*I2_i + +error, where I_i is 
 1 
 Y_i is from group A, and 0 if Y_i is from group B.
 
 It is large when  beta1=beta2=0
 It is small when beta1 and/or beta2 is not equal to 0
 
 How can I find it by R? Thank you very much for your time.
 
 
 That's a funny question.  Usually we want a statistic that is small when 
 beta1=beta2=0 and large otherwise.
 
 Why not compute the usual F statistic for the null beta1=beta2=0 and then 
 use 1/F as your statistic?
 
 Mike
 
 __
 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 find statistics like that.

2005-11-10 Thread Liaw, Andy
The definition of a statistic that I learned in grad school is that it's a
function of a random sample from a population.  Any p-value would fit that
definition.

Andy

 From: Adaikalavan Ramasamy
 
 If my usage is wrong please correct me. Thank you.
 
 Here are my reason :
 
 1. p-value is a (cumulative) probability and always ranges 
 from 0 to 1.
 A test statistic depending on its definition can wider range 
 of possible
 values.
 
 2. A test statistics is one that is calculated from the data 
 without the
 need of assuming a null distribution. Whereas to calculate 
 p-values, you
 need to assume a null distribution or estimate it empirically using
 permutation techniques.
 
 3. The directionality of a test statistics may be ignored. 
 For example a
 t-statistics of -5 and 5 are equally interesting in a 
 two-sided testing.
 But the smaller the p-value, more evidence against the null 
 hypothesis.
 
 Regards, Adai
 
 
 
 On Thu, 2005-11-10 at 06:05 -0500, Duncan Murdoch wrote:
  On 11/9/2005 10:01 PM, Adaikalavan Ramasamy wrote:
   I think an alternative is to use a p-value from F 
 distribution. Even
   tough it is not a statistics, it is much easier to 
 explain and popular
   than 1/F. Better yet to report the confidence intervals.
  
  Just curious about your usage:  why do you say a p-value is 
 not a statistic?
  
  Duncan Murdoch
  
   
   Regards, Adai
   
   
   
   On Wed, 2005-11-09 at 17:09 -0600, Mike Miller wrote:
   
  On Wed, 9 Nov 2005, Gao Fay wrote:
  
  
  Hi there,
  
  Suppose mu is constant, and error is normally 
 distributed with mean 0 and 
  fixed variance s. I need to find a statistics that:
  Y_i = mu + beta1* I1_i beta2*I2_i + beta3*I1_i*I2_i + 
 +error, where I_i is 1 
  Y_i is from group A, and 0 if Y_i is from group B.
  
  It is large when  beta1=beta2=0
  It is small when beta1 and/or beta2 is not equal to 0
  
  How can I find it by R? Thank you very much for your time.
  
  
  That's a funny question.  Usually we want a statistic 
 that is small when 
  beta1=beta2=0 and large otherwise.
  
  Why not compute the usual F statistic for the null 
 beta1=beta2=0 and then 
  use 1/F as your statistic?
  
  Mike
  
  __
  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-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Help to multinomial analyses

2005-11-10 Thread bady

hi, hi all,

 Dear Sirs,
 Could you please be so kind as to send us some information on residuals in
 multinomial logistic models?

here are some references to multinomial models:

Agresti A.(1996) An Introduction to Categorical Data Analysis

Agresti A. (2002) Categorical Data Analysis, 2nd Edition

McCullagh P. and Nelder J. (1989). Generalized Linear Models. Chapman and Hall,
London.

http://data.princeton.edu/wws509/notes/c6.pdf

http://www.statslab.cam.ac.uk/~pat/Splusdiscrete2.pdf
(see chapter 11 for Multinomial response)

etc ...

 Is it possible to use R software?

You can consult these links :
http://www.stat.ufl.edu/~aa/cda/software.html
http://www.statslab.cam.ac.uk/~pat/Splusdiscrete2.pdf
(see chapter 11 for Multinomial response)


cheers,

P.BADY

__
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 find statistics like that.

2005-11-10 Thread Ruben Roa
 -Original Message-
 From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED] On Behalf Of Adaikalavan 
 Ramasamy
 Sent: Thursday, November 10, 2005 10:31 AM
 To:   Duncan Murdoch
 Cc:   r-help@stat.math.ethz.ch
 Subject:  Re: [R] How to find statistics like that.
 
 If my usage is wrong please correct me. Thank you.
 
 Here are my reason :
 
 1. p-value is a (cumulative) probability and always ranges from 0 to 1.
 A test statistic depending on its definition can wider range of possible
 values.
 
 2. A test statistics is one that is calculated from the data without the
 need of assuming a null distribution. Whereas to calculate p-values, you
 need to assume a null distribution or estimate it empirically using
 permutation techniques.
 
 3. The directionality of a test statistics may be ignored. For example a
 t-statistics of -5 and 5 are equally interesting in a two-sided testing.
 But the smaller the p-value, more evidence against the null hypothesis.
 
 Regards, Adai
 

Hi:
A statistic is any real-valued or vector-valued function whose
domain includes the sample space of a random sample. The
p-value is a real-valued function and its domain includes the 
sample space of a random sample. The p-value has a sampling
distribution. The code below, found with Google (sampling distribution
of the p-value R command) shows the sampling
distribution of the p-value for a t-test of a mean when the null hypothesis
is true.
Ruben

n-18
mu-40
pop.var-100
n.draw-200
alpha-0.05
draws-matrix(rnorm(n.draw * n, mu, sqrt(pop.var)), n)
get.p.value-function(x) t.test(x, mu = mu)$p.value
pvalues-apply(draws, 2, get.p.value)
hist(pvalues)
sum(pvalues = alpha)
[1] 6

__
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] paste argument of a function as a file name

2005-11-10 Thread Luis Ridao Cruz
R-help,

I have a function which is exporting the output to a file via
write.table(df, file =  file name.xls )

What I want is to paste the file name (above) by taking the argument to
the function as a file name 

something like this:

MY.function- function(df)
{
...
...
write.table(df,argument.xls)
}
MY.function(argument)


Thank you

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


Re: [R] Help to multinomial analyses

2005-11-10 Thread Peter Flom
Luciana Alves asked

 Dear Sirs,
 Could you please be so kind as to send us some information on
residuals in
 multinomial logistic models?



Peter L. Flom, PhD
Assistant Director, Statistics and Data Analysis Core
Center for Drug Use and HIV Research
National Development and Research Institutes
71 W. 23rd St
http://cduhr.ndri.org
www.peterflom.com
New York, NY 10010
(212) 845-4485 (voice)
(917) 438-0894 (fax)



 [EMAIL PROTECTED] 11/10/2005 8:03:56 AM  gave some very good
references

here are some references to multinomial models:

Agresti A.(1996) An Introduction to Categorical Data Analysis

Agresti A. (2002) Categorical Data Analysis, 2nd Edition

McCullagh P. and Nelder J. (1989). Generalized Linear Models. Chapman
and Hall,
London.

http://data.princeton.edu/wws509/notes/c6.pdf 

http://www.statslab.cam.ac.uk/~pat/Splusdiscrete2.pdf 
(see chapter 11 for Multinomial response)

etc ...

 Is it possible to use R software?

You can consult these links :
http://www.stat.ufl.edu/~aa/cda/software.html 
http://www.statslab.cam.ac.uk/~pat/Splusdiscrete2.pdf 
(see chapter 11 for Multinomial response)


I would suggest, in addition,

Hosmer  Lemeshow Applied Logistic Regression esp. p 280-288, and
references therein.
In particular, they cite 

Lesaffre  Albert, Multiple-group regression diagnostics, Applied
Statistics, 38, 425-440

but note that the techniques recommended there are not implemented in
'available software'.  I would be interested to know if these techniques
have been implemented since H and L.

Regards

Peter

cheers,

P.BADY

__
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] Remove levels

2005-11-10 Thread Marc Bernard
Daer All,
 
I have a factor  variable, X with 5 levels. When I type tables(X) it gives me:
 
table(X)
1 2   34   5 
10   50   0   0
 
How to drop the levels with zeros such that when I will type:
table(X) it will give me:
 
table(X)
1 2   
10   5
 
 
Thank a lot,
 
Bernard
 



-


[[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] paste argument of a function as a file name

2005-11-10 Thread Sean Davis
On 11/10/05 8:28 AM, Luis Ridao Cruz [EMAIL PROTECTED] wrote:

 R-help,
 
 I have a function which is exporting the output to a file via
 write.table(df, file =  file name.xls )
 
 What I want is to paste the file name (above) by taking the argument to
 the function as a file name

help('paste')

Sean

__
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] write.table read.table with Dates

2005-11-10 Thread JeeBee
I've found several similar issues with write.table/read.table
with Dates on this list, but trying to follow this advice I still
get an error.

First, I read in data from several files, constructing several date/time
columns using ISOdatetime

 str(Tall$Begin)
'POSIXct', format: chr [1:40114] 2005-10-02 00:00:00 2005-10-02
00:00:00 ...
 length(Tall$Begin)
[1] 40114
 class(Tall$Begin)
[1] POSIXt  POSIXct

This looks good (time is not always 00:00:00 ...)
This data came from several files, now I want to store the result I have
in data.frame Tall and be able to retrieve this quickly some other time.

This is what I do:
write.table(Tall, file=somefile.csv, sep=,, qmethod=double,
row.names=FALSE)

Later, I do this to read the file again:
fieldnames=c(Begin,test-a,test-b,Eind)
T=read.table(file = somefile.csv, col.names = fieldnames,
  header = TRUE, sep = ,, quote=\, fill=FALSE)

I understand T$Begin now is a factor. I tried to simply convert it
again using (as I read on this mailinglist ...):
Q = strptime(as.character(T$Begin),format=%Y-%m-%d %H:%M:%S)

Q is looking good, though its length I don't understand .. is it a list or
something? It seems there are 40114 values in there somewhere...

 class(Q)
[1] POSIXt  POSIXlt
 length(Q)
[1] 9
 str(Q)
'POSIXlt', format: chr [1:40114] 2005-10-02 00:00:00 2005-10-02 00:00:00 ...

T$Begin = Q ### yields this error
Error in $-.data.frame(`*tmp*`, Begin, value = list(sec = c(0, 0,  :
replacement has 9 rows, data has 40114

Could somebody explain me how to convert the date column?
Or perhaps there is an easier way?

Thanks in advance for your time.

__
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] paste argument of a function as a file name

2005-11-10 Thread Romain Francois
Le 10.11.2005 14:28, Luis Ridao Cruz a écrit :

R-help,

I have a function which is exporting the output to a file via
write.table(df, file =  file name.xls )

What I want is to paste the file name (above) by taking the argument to
the function as a file name 

something like this:

MY.function- function(df)
{
...
...
write.table(df,argument.xls)
}
MY.function(argument)


Thank you
  

Hi,

Maybe sprintf or paste.

MY.function- function(df, arg=argument)
{
...
...
write.table(df,paste(arg,.xls,sep=))
# or : 
# write.table(df,sprintf(%s.xls,arg))
}
MY.function(argument)



-- 
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
+---+
| Romain FRANCOIS - http://francoisromain.free.fr   |
| Doctorant INRIA Futurs / EDF  |
+---+

__
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] paste argument of a function as a file name

2005-11-10 Thread Barry Rowlingson
Luis Ridao Cruz wrote:
 R-help,
 
 I have a function which is exporting the output to a file via
 write.table(df, file =  file name.xls )
 
 What I want is to paste the file name (above) by taking the argument to
 the function as a file name 
 
 something like this:

  More like this:

foo = function(df){
  fn=paste(deparse(substitute(df)),'.xls',sep='')
  write.table(df,file=fn)
}

Then:

  x=1:10
  foo(x)

produces a file: x.xls

  deparse(substitute(df)) is used in plot() to label the Y-axis with the 
name of the object passed to plot(), which is similar to what you want 
to do here.

Baz

__
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] paste argument of a function as a file name

2005-11-10 Thread Adaikalavan Ramasamy
my.write - function( obj, name ){

  filename - file=paste( name, .txt, sep=)
  write.table( obj, file=filename, sep=\t, quote=F)

}

my.write( df, output )

Regards, Adai


On Thu, 2005-11-10 at 13:28 +, Luis Ridao Cruz wrote:
 R-help,
 
 I have a function which is exporting the output to a file via
 write.table(df, file =  file name.xls )
 
 What I want is to paste the file name (above) by taking the argument to
 the function as a file name 
 
 something like this:
 
 MY.function- function(df)
 {
 ...
 ...
 write.table(df,argument.xls)
 }
 MY.function(argument)
 
 
 Thank you
 
 __
 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] paste argument of a function as a file name

2005-11-10 Thread Frede Aakmann Tøgersen
Why not use something like


MY.function - function(x){
  filn - deparse(substitute(x))
  filename - paste(filn,xls,sep=.)
  ...
  ...
  write.table(x,file=filename)
}


Med venlig hilsen
Frede Aakmann Tøgersen
 

 

 -Oprindelig meddelelse-
 Fra: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] På vegne af Luis Ridao Cruz
 Sendt: 10. november 2005 14:28
 Til: r-help@stat.math.ethz.ch
 Emne: [R] paste argument of a function as a file name
 
 R-help,
 
 I have a function which is exporting the output to a file via 
 write.table(df, file =  file name.xls )
 
 What I want is to paste the file name (above) by taking the 
 argument to the function as a file name 
 
 something like this:
 
 MY.function- function(df)
 {
 ...
 ...
 write.table(df,argument.xls)
 }
 MY.function(argument)
 
 
 Thank you
 
 __
 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] Remove levels

2005-11-10 Thread Uwe Ligges
Marc Bernard wrote:

 Daer All,
  
 I have a factor  variable, X with 5 levels. When I type tables(X) it gives me:
  
 table(X)
 1 2   34   5 
 10   50   0   0
  
 How to drop the levels with zeros such that when I will type:
 table(X) it will give me:
  
 table(X)
 1 2   
 10   5


table(X[,drop=TRUE])

Uwe Ligges


  
 Thank a lot,
  
 Bernard
  
 
 
   
 -
 
 
   [[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] How to find statistics like that.

2005-11-10 Thread Duncan Murdoch
On 11/10/2005 7:31 AM, Adaikalavan Ramasamy wrote:
 If my usage is wrong please correct me. Thank you.
 
 Here are my reason :
 
 1. p-value is a (cumulative) probability and always ranges from 0 to 1.
 A test statistic depending on its definition can wider range of possible
 values.
 
 2. A test statistics is one that is calculated from the data without the
 need of assuming a null distribution. Whereas to calculate p-values, you
 need to assume a null distribution or estimate it empirically using
 permutation techniques.
 
 3. The directionality of a test statistics may be ignored. For example a
 t-statistics of -5 and 5 are equally interesting in a two-sided testing.
 But the smaller the p-value, more evidence against the null hypothesis.
 
 Regards, Adai

Thanks for your explanation.  I think your interpretation is one that is 
sometimes taught, but I think it's more useful to think of a p-value as 
just another statistic, whose null distribution (in the ideal case, but 
not always in practice) is a uniform distribution on (0,1), and whose 
distribution when the alternative is true (again, ideally) tends to be 
more concentrated near 0.  This takes a lot of the mysticism out of them.

Duncan Murdoch
 
 
 On Thu, 2005-11-10 at 06:05 -0500, Duncan Murdoch wrote:
 
On 11/9/2005 10:01 PM, Adaikalavan Ramasamy wrote:

I think an alternative is to use a p-value from F distribution. Even
tough it is not a statistics, it is much easier to explain and popular
than 1/F. Better yet to report the confidence intervals.

Just curious about your usage:  why do you say a p-value is not a statistic?

Duncan Murdoch


Regards, Adai



On Wed, 2005-11-09 at 17:09 -0600, Mike Miller wrote:


On Wed, 9 Nov 2005, Gao Fay wrote:



Hi there,

Suppose mu is constant, and error is normally distributed with mean 0 and 
fixed variance s. I need to find a statistics that:
Y_i = mu + beta1* I1_i beta2*I2_i + beta3*I1_i*I2_i + +error, where I_i is 
1 
Y_i is from group A, and 0 if Y_i is from group B.

It is large when  beta1=beta2=0
It is small when beta1 and/or beta2 is not equal to 0

How can I find it by R? Thank you very much for your time.


That's a funny question.  Usually we want a statistic that is small when 
beta1=beta2=0 and large otherwise.

Why not compute the usual F statistic for the null beta1=beta2=0 and then 
use 1/F as your statistic?

Mike

__
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] paste argument of a function as a file name

2005-11-10 Thread Uwe Ligges
Luis Ridao Cruz wrote:

 R-help,
 
 I have a function which is exporting the output to a file via
 write.table(df, file =  file name.xls )
 
 What I want is to paste the file name (above) by taking the argument to
 the function as a file name 
 
 something like this:
 
 MY.function- function(df)
 {
 ...
 ...
 write.table(df,argument.xls)
 }
 MY.function(argument)

Has been asked hundreds of times on this list. Please check the archives 
as the posting guide asks to do  ...

Hint: paste()

Uwe Ligges


 
 Thank you
 
 __
 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] Remove levels

2005-11-10 Thread Peter Dalgaard
Marc Bernard [EMAIL PROTECTED] writes:

 Daer All,
  
 I have a factor  variable, X with 5 levels. When I type tables(X) it gives me:
  
 table(X)
 1 2   34   5 
 10   50   0   0
  
 How to drop the levels with zeros such that when I will type:
 table(X) it will give me:
  
 table(X)
 1 2   
 10   5

table(factor(X)) or table(X[drop=TRUE]) should do it. The latter runs
the former, but the intention might be clearer.

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

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


Re: [R] How to find statistics like that.

2005-11-10 Thread Mike Miller
On Thu, 10 Nov 2005, Ruben Roa wrote:

 A statistic is any real-valued or vector-valued function whose
 domain includes the sample space of a random sample. The
 p-value is a real-valued function and its domain includes the
 sample space of a random sample. The p-value has a sampling
 distribution. The code below, found with Google (sampling distribution
 of the p-value R command) shows the sampling
 distribution of the p-value for a t-test of a mean when the null hypothesis
 is true.
 Ruben

 n-18
 mu-40
 pop.var-100
 n.draw-200
 alpha-0.05
 draws-matrix(rnorm(n.draw * n, mu, sqrt(pop.var)), n)
 get.p.value-function(x) t.test(x, mu = mu)$p.value
 pvalues-apply(draws, 2, get.p.value)
 hist(pvalues)
 sum(pvalues = alpha)
 [1] 6


The sampling distribution of a p-value when the null hypothesis is true 
can be given more simply by this R code:

runif()

That holds for any valid test, not just a t test, that produces p-values 
distributed continuously on [0,1].  Discrete distributions can't quite do 
that without special tweaking.

Mike

__
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] write.table read.table with Dates

2005-11-10 Thread Gabor Grothendieck
On 11/10/05, JeeBee [EMAIL PROTECTED] wrote:
 I've found several similar issues with write.table/read.table
 with Dates on this list, but trying to follow this advice I still
 get an error.

 First, I read in data from several files, constructing several date/time
 columns using ISOdatetime

  str(Tall$Begin)
 'POSIXct', format: chr [1:40114] 2005-10-02 00:00:00 2005-10-02
 00:00:00 ...
  length(Tall$Begin)
 [1] 40114
  class(Tall$Begin)
 [1] POSIXt  POSIXct

 This looks good (time is not always 00:00:00 ...)
 This data came from several files, now I want to store the result I have
 in data.frame Tall and be able to retrieve this quickly some other time.

 This is what I do:
 write.table(Tall, file=somefile.csv, sep=,, qmethod=double,
 row.names=FALSE)

 Later, I do this to read the file again:
 fieldnames=c(Begin,test-a,test-b,Eind)
 T=read.table(file = somefile.csv, col.names = fieldnames,
  header = TRUE, sep = ,, quote=\, fill=FALSE)

 I understand T$Begin now is a factor. I tried to simply convert it
 again using (as I read on this mailinglist ...):
 Q = strptime(as.character(T$Begin),format=%Y-%m-%d %H:%M:%S)

 Q is looking good, though its length I don't understand .. is it a list or
 something? It seems there are 40114 values in there somewhere...

  class(Q)
 [1] POSIXt  POSIXlt
  length(Q)
 [1] 9
  str(Q)
 'POSIXlt', format: chr [1:40114] 2005-10-02 00:00:00 2005-10-02 00:00:00 
 ...

 T$Begin = Q ### yields this error
 Error in $-.data.frame(`*tmp*`, Begin, value = list(sec = c(0, 0,  :
replacement has 9 rows, data has 40114

 Could somebody explain me how to convert the date column?
 Or perhaps there is an easier way?


You are converting it to POSIXlt (which represents date/times as a 9
element structure) but its likely you really wanted to convert it to
POSIXct.

as.POSIXct(T$Begin)

Also, you might need to use the tz= argument depending on what result
you want.

See the Help Desk article in RNews 4/1 for more info.

__
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 find statistics like that.

2005-11-10 Thread Ruben Roa
 -Original Message-
 From: Mike Miller [SMTP:[EMAIL PROTECTED]
 Sent: Thursday, November 10, 2005 12:32 PM
 To:   Ruben Roa
 Cc:   [EMAIL PROTECTED]; Duncan Murdoch; r-help@stat.math.ethz.ch
 Subject:  Re: [R] How to find statistics like that.
 
 On Thu, 10 Nov 2005, Ruben Roa wrote:
 
  A statistic is any real-valued or vector-valued function whose
  domain includes the sample space of a random sample. The
  p-value is a real-valued function and its domain includes the
  sample space of a random sample. The p-value has a sampling
  distribution. The code below, found with Google (sampling distribution
  of the p-value R command) shows the sampling
  distribution of the p-value for a t-test of a mean when the null hypothesis
  is true.
  Ruben
 
  n-18
  mu-40
  pop.var-100
  n.draw-200
  alpha-0.05
  draws-matrix(rnorm(n.draw * n, mu, sqrt(pop.var)), n)
  get.p.value-function(x) t.test(x, mu = mu)$p.value
  pvalues-apply(draws, 2, get.p.value)
  hist(pvalues)
  sum(pvalues = alpha)
  [1] 6
 
 
 The sampling distribution of a p-value when the null hypothesis is true 
 can be given more simply by this R code:
 
 runif()
 
 That holds for any valid test, not just a t test, that produces p-values 
 distributed continuously on [0,1].  Discrete distributions can't quite do 
 that without special tweaking.
 
 Mike
 

Theorem 2.1.4 in Casella and Berger (1990, p. 52).
Ruben

__
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] Interpretation of output from glm

2005-11-10 Thread John Fox
Dear Pedro,

The basic point, which relates to the principle of marginality in
formulating linear models, applies whether the predictors are factors,
covariates, or both. I think that this is a common topic in books on linear
models; I certainly discuss it in my Applied Regression, Linear Models, and
Related Methods.

Regards,
 John


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Pedro de Barros
 Sent: Wednesday, November 09, 2005 10:45 AM
 To: r-help@stat.math.ethz.ch
 Subject: Re: [R] Interpretation of output from glm
 Importance: High
 
 Dear John,
 
 Thanks for the quick reply. I did indeed have these ideas, 
 but somehow floating, and all I could find about this 
 mentioned categorical predictors. Can you suggest a good book 
 where I could try to learn more about this?
 
 Thanks again,
 
 Pedro
 At 01:49 09/11/2005, you wrote:
 Dear Pedro,
 
 
   -Original Message-
   From: [EMAIL PROTECTED] 
   [mailto:[EMAIL PROTECTED] On Behalf Of Pedro de 
   Barros
   Sent: Tuesday, November 08, 2005 9:47 AM
   To: r-help@stat.math.ethz.ch
   Subject: [R] Interpretation of output from glm
   Importance: High
  
   I am fitting a logistic model to binary data. The 
 response variable 
   is a factor (0 or 1) and all predictors are continuous variables. 
   The main predictor is LT (I expect a logistic relation between LT 
   and the probability of being
   mature) and the other are variables I expect to modify 
 this relation.
  
   I want to test if all predictors contribute significantly for the 
   fit or not I fit the full model, and get these results
  
 summary(HMMaturation.glmfit.Full)
  
   Call:
   glm(formula = Mature ~ LT + CondF + Biom + LT:CondF + LT:Biom,
family = binomial(link = logit), data = HMIndSamples)
  
   Deviance Residuals:
Min   1Q   Median   3Q  Max
   -3.0983  -0.7620   0.2540   0.7202   2.0292
  
   Coefficients:
  Estimate Std. Error z value Pr(|z|)
   (Intercept) -8.789e-01  3.694e-01  -2.379  0.01735 *
   LT   5.372e-02  1.798e-02   2.987  0.00281 **
   CondF   -6.763e-02  9.296e-03  -7.275 3.46e-13 ***
   Biom-1.375e-02  2.005e-03  -6.856 7.07e-12 ***
   LT:CondF 2.434e-03  3.813e-04   6.383 1.74e-10 ***
   LT:Biom  7.833e-04  9.614e-05   8.148 3.71e-16 ***
   ---
   Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
   (Dispersion parameter for binomial family taken to be 1)
  
Null deviance: 10272.4  on 8224  degrees of freedom Residual 
   deviance:  7185.8  on 8219  degrees of freedom
   AIC: 7197.8
  
   Number of Fisher Scoring iterations: 8
  
   However, when I run anova on the fit, I get   
   anova(HMMaturation.glmfit.Full, test='Chisq') Analysis of 
 Deviance 
   Table
  
   Model: binomial, link: logit
  
   Response: Mature
  
   Terms added sequentially (first to last)
  
  
   Df Deviance Resid. Df Resid. Dev P(|Chi|)
   NULL822410272.4
   LT  1   2873.8  8223 7398.7   0.0
   CondF   1  0.1  8222 7398.5   0.7
   Biom1  0.2  8221 7398.3   0.7
   LT:CondF1142.1  8220 7256.3 9.413e-33
   LT:Biom 1 70.4  8219 7185.8 4.763e-17
   Warning message:
   fitted probabilities numerically 0 or 1 occurred in: 
 method(x = x[, 
   varseq = i, drop = FALSE], y = object$y, weights = 
   object$prior.weights,
  
  
   I am having a little difficulty interpreting these results.
   The result from the fit tells me that all predictors are 
   significant, while the anova indicates that besides LT (the main 
   variable), only the interaction of the other terms is 
 significant, 
   but the main effects are not.
   I believe that in the first output (on the glm object), the 
   significance of all terms is calculated considering each of them 
   alone in the model (i.e.
   removing all other terms), while the anova output is (as it says) 
   considering the sequential addition of the terms.
  
   So, there are 2 questions:
   a) Can I tell that the interactions are significant, but not the 
   main effects?
 
 In a model with this structure, the main effects represent slopes 
 over the origin (i.e., where the other variables in the 
 product terms 
 are 0), and aren't meaningfully interpreted as main effects. 
 (Is there 
 even any data near the origin?)
 
   b) Is it legitimate to consider a model where the 
 interactions are 
   considered, but not the main effects CondF and Biom?
 
 Generally, no: That is, such a model is interpretable, but it places 
 strange constraints on the regression surface -- that the CondF and 
 Biom slopes are 0 over the origin.
 
 None of this is specific to logistic 

[R] Fonts, Plus

2005-11-10 Thread ivo welch

Dear R Wizards:

sorry, I need more help.  hopefully, it will help others in the future. 
I am using R 2.2.0 Patched (2005-11-07 r36217).


[a]

# copy from the postscriptFont documentation
CMitalic - postscriptFont(ComputerModern,
   c(CM_regular_10.afm, CM_boldx_10.afm,
 cmti10.afm, cmbxti10.afm,
 CM_symbol_10.afm))
postscriptFonts(CMitalic=CMitalic)

# trying this one out.  I copied the syntax that worked for lucida
pdf(file=test.pdf, fonts=CMitalic, version=1.4);
par(family=CMitalic);
plot( c(0,1),c(0,1) );
myeq - bquote((w[I]==.(1/7)));
text( 0.5, 0.3, myeq );
text( 0.5, 0.7, this is computer modern);
dev.off();

Now, pdffonts test.pdf (from the xpdf distribution) gives me

$ pdffonts test.pdf
name type emb sub uni object ID
  --- --- --- -
Error (4149): Dictionary key must be a name object
Error (4152): Dictionary key must be a name object
ZapfDingbats Type 1   no  no  no   5  0
HelveticaType 1   no  no  no  10  0
Helvetica-Bold   Type 1   no  no  no  11  0
Helvetica-ObliqueType 1   no  no  no  12  0
Helvetica-BoldObliqueType 1   no  no  no  13  0
Symbol   Type 1   no  no  no  14  0
CMR10Type 1   no  no  no  15  0
CMBX10   Type 1   no  no  no  16  0
CMTI10   Type 1   no  no  no  17  0
CMBXTI10 Type 1   no  no  no  18  0
Error (4149): Dictionary key must be a name object
Error (4152): Dictionary key must be a name object
CMSY10   Type 1   no  no  no  19  0

so, something is still wrong.

[b]

I am looking at the docs for postscriptFonts.  ?postscriptFonts.  May I
suggest that we add two or three more lines to show usage?  something
like plot(c(0,1),c(0,1)); text(0.2, 0.5, hello, font=2); dev.off(). 
More generally, a documented sample example file that shows usage of
many/multiple postscript fonts and families within one graph would be a
great help.

This is of course all just my own ignorance.  In general, I am not yet
sure about the whole font syntax.  I wonder what a font=something
statement in the plot statement itself does.  I believe the
par(family=) changes the font used for the figure [e.g., axis labels],
although I am wondering why I am giving a string [CMItalic] rather
than a variable [CMItalic].  the ?text documentation does not have an
example of font selection, especially if I want to mix multiple fonts
and from different font families.


[c]

how do I tell a CMD BATCH not to execute the site file?  R
--no-init-file works only interactively.  ( Would it not make sense to
allow this options also for CMD BATCH?)  I probably have an incorrect
installation, because the suggestion from R --help fails for me

$ R CMD command --help
/usr/local/lib64/R/bin/Rcmd: line 45: exec: command: not found

However, R CMD BATCH my.R works just fine.

Further suggestion: let's have an abbreviation for --no-init-file, too;
e.g., -I.


[d] regarding my earlier suggestion of a variable that contains the
currently executing file, I know I can put an argv0 - filename into
each file, but it would be nice if this happened automatically and was
available everywhere.  just a suggestion...


please don't see the above as a complaint.  R is great, and the effort
you guys put in is terrific.  It's just that I am struggling with the
syntax here, and this one is not easy to figure out.

Regards,

/ivo

__
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] write.table read.table with Dates

2005-11-10 Thread JeeBee

I see that strptime returns a list of
year, mon, mday, hour, min, sec, etc.

The following works for me (for each column that is a date/time field
in my imported file)

cat(Converting date/time fields...\n)
Q = strptime(as.character(data$myfield), format=%Y-%m-%d%H:%M:%S)
data$myfield = ISOdatetime(year = Q$year + 1900,
   month = Q$mon + 1, day = Q$mday,
   hour =Q$hour, min = Q$min, sec = Q$sec, tz = )

ISOdatetime does return a vector, which is, I guess, what I want.
It is quite slow like this though, and I don't think it's the best way.

__
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] write.table read.table with Dates

2005-11-10 Thread Prof Brian Ripley
On Thu, 10 Nov 2005, JeeBee wrote:

 I've found several similar issues with write.table/read.table
 with Dates on this list, but trying to follow this advice I still
 get an error.

 First, I read in data from several files, constructing several date/time
 columns using ISOdatetime

 str(Tall$Begin)
 'POSIXct', format: chr [1:40114] 2005-10-02 00:00:00 2005-10-02
 00:00:00 ...
 length(Tall$Begin)
 [1] 40114
 class(Tall$Begin)
 [1] POSIXt  POSIXct

 This looks good (time is not always 00:00:00 ...)
 This data came from several files, now I want to store the result I have
 in data.frame Tall and be able to retrieve this quickly some other time.

 This is what I do:
 write.table(Tall, file=somefile.csv, sep=,, qmethod=double,
 row.names=FALSE)

 Later, I do this to read the file again:
 fieldnames=c(Begin,test-a,test-b,Eind)
 T=read.table(file = somefile.csv, col.names = fieldnames,
  header = TRUE, sep = ,, quote=\, fill=FALSE)

You can avoid all this trouble by using colClasses as documented on the 
help page.

 I understand T$Begin now is a factor. I tried to simply convert it
 again using (as I read on this mailinglist ...):
 Q = strptime(as.character(T$Begin),format=%Y-%m-%d %H:%M:%S)

Or just as.POSIXct(as.character(T$Begin))

 Q is looking good, though its length I don't understand .. is it a list or
 something? It seems there are 40114 values in there somewhere...

It is a list of length 9.  Try names(Q)

 class(Q)
 [1] POSIXt  POSIXlt
 length(Q)
 [1] 9
 str(Q)
 'POSIXlt', format: chr [1:40114] 2005-10-02 00:00:00 2005-10-02 00:00:00 
 ...

 T$Begin = Q ### yields this error
 Error in $-.data.frame(`*tmp*`, Begin, value = list(sec = c(0, 0,  :
replacement has 9 rows, data has 40114

 Could somebody explain me how to convert the date column?
 Or perhaps there is an easier way?

You started with POSIXct, and you need to convert back to POSIXct
with as.POSIXct(Q).

Reading ?DateTimeClasses should explain to you what you are missing.

-- 
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] R-help: conversion of long decimal numbers into hexadecimal

2005-11-10 Thread Antje Döring
Hi there,

 

could somebody help me to convert a decimal number into a hexadecimal number? I 
know that there is the function sprintf, but the numbers I want to convert 
consist of  20 or more numbers. Spintf is not able to convert these big 
numbers.

 

Thanks for any help.

 

Antje

 

 


[[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] question about the dataset fgl

2005-11-10 Thread Huh, Seungho
Dear sir or ma'am,

 

I have a question about the dataset fgl. The dataset seems to be in
the VR package, so I tried to download it from CRAN. However, after
downloading, when I tried to load the package, it was not in my package
list. I am wondering what is wrong.

 

Any advice on how to access the fgl dataset would be appreciated.
Thanks. 

 

Seungho Huh

 

 


[[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] estimating significance P-value between 2 matricesv

2005-11-10 Thread balaji
Hi all,

Being a new user of R I am having some troubles, I hope to get some
solutions.., I have tried looking everywhere but so far not been so
successful.

i have two matrices mat1=[1:26], mat2[1:47]
there are some missing values in mat1[5:6,15:26]

I want to calculate Pearson correlation r between mat1 * mat2
and also estimate the significance P-value between mat1 * mat2

By using
 cor(mat1[2:26],mat2[2:47], use=pairwise.complete.obs)
I was able to calcualte the Pearson correlation r between mat1 * mat2

I am not able to estimate the significance P-value using cor.test
My Qs are?
How to estimate significance P-value between variables of 2 matrices?
OR
is there any other approach to do this..

any idea or suggestions ??

thank you for your time,
balaji

[[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] different functions on different vector subsets

2005-11-10 Thread Ron Ophir
Hi,
I am trying to apply two different functions on on a vector as follow:
a-c(NA,1,2,3,-3,-4,-6)
if a0 I would like to raise it by the power of 2: 2^a and if the a0 I
would like to have the inverse value, i.e., -1/2^a.
so I thought of doing it two steps:
a[a0]-2^[a0]
a[a0]-(-1)/2^a[a0]
I got the following error
Error: NAs are not allowed in subscripted assignments
any other manupulation that I did with is.na() but did not succeed.
What is funny that the two sides of the assignment work and return the
same vector size:
 2^a[a0]
[1] NA  2  4  8
 a[a0]
[1] NA  1  2  3

I found a solution in term of:
sapply(a,function(x) if (is(s.na)) NA else if (x0) (-1)/2^x else 2^x)
but still I would like to understand why the solution above did not
work. I think is more ellegant.
my R version is:
 sessionInfo()
R version 2.2.0, 2005-10-06, i386-pc-mingw32 
 
attached base packages:
[1] methods   stats graphics  grDevices utils
datasets 
[7] base 
Thanks,
Ron
 

[[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] error in rowSums:'x' must be numeric

2005-11-10 Thread Illyes Eszter
Dear All, 

It's Eszter again from Hungary. I could not solve my problem form 
yesterday, so I still have to ask your help.

I have a binary dataset of vegetation samples and species as a comma 
separated file. I would like to calculate the Jaccard distance of the 
dataset. I have the following error message: 

Error in rowSums(x, prod(dn), p, na.rm) : 'x' must be numeric
In addition: Warning message:
results may be meaningless because input data have negative entries
 in: vegdist(t2, method = jaccard, binary = FALSE, diag = FALSE,  

Do you have any idea what can be the problem? I have only 0 and 1 in 
the dataset. 

Thank you very much! All the best:


Eszter


___
KGFB 2006 - Garantáltan a legjobb ár! Nyerje meg az új Swiftet + 
garantált 10,000,-  Ft értékű ajándék. WWW.NETRISK.HU

__
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 find statistics like that.

2005-11-10 Thread Duncan Murdoch
On 11/10/2005 9:32 AM, Mike Miller wrote:
 On Thu, 10 Nov 2005, Ruben Roa wrote:
 
 
A statistic is any real-valued or vector-valued function whose
domain includes the sample space of a random sample. The
p-value is a real-valued function and its domain includes the
sample space of a random sample. The p-value has a sampling
distribution. The code below, found with Google (sampling distribution
of the p-value R command) shows the sampling
distribution of the p-value for a t-test of a mean when the null hypothesis
is true.
Ruben

n-18
mu-40
pop.var-100
n.draw-200
alpha-0.05
draws-matrix(rnorm(n.draw * n, mu, sqrt(pop.var)), n)
get.p.value-function(x) t.test(x, mu = mu)$p.value
pvalues-apply(draws, 2, get.p.value)
hist(pvalues)
sum(pvalues = alpha)
[1] 6
 
 
 
 The sampling distribution of a p-value when the null hypothesis is true 
 can be given more simply by this R code:
 
 runif()
 
 That holds for any valid test, not just a t test, that produces p-values 
 distributed continuously on [0,1].  Discrete distributions can't quite do 
 that without special tweaking.

Nor can most composite null hypotheses, e.g.

H0: mu = 0 versus H1: mu  0

A t-test may be an appropriate test, but its p-value is not uniformly 
distributed when mu is -1, even though the null is true.

Duncan Murdoch

__
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] ltext - adding text to each panel from a matrix

2005-11-10 Thread Andy Bunn
Hi all (really probably just Deepayan):

In the plot below I want to add text on either side of each violin plot that
indicates the number of observations that are either positive or negative.
I'm trying to do this with ltext() and I've also monkeyed about with
panel.text(). The code below is generally what I want but my calls to
ltext() are wrong and I'm not sure how to fix them. Right now they replicate
the first column of the matrices obs.pos and obs.neg for each panel. How do
I tell ltext to advance to the next column when the next panel is plotted? I
don't see how subscripts can do it, but I bet it's something along that
line...

Thanks, Andy

rm(list = ls())
set.seed(354)
# make a bimodal dataset with three groups and three treatments
foo - c(rnorm(150,-1,0.5), rnorm(150,1,0.25))
treatment - factor(rep(seq(1,3),100), labels = c(Treatment 1, Treatment
2, Treatment 3))
group - factor(rep(seq(1,3),100), labels = c(Group A, Group B, Group
C))
group - sample(group)
# corrupt Group A, Treatment 2 for fun.
foo[group==Group A  treatment==Treatment 2][1:8] - rnorm(8,1,1)
dat - data.frame(foo,treatment,group)

# set the limits for the plot, which also tells where to put the text
my.xlim - c(-6, 6)

# make a matrix that counts the number of obs greater or less than zero
obs.pos - tapply(dat[dat[,1]  0,1], dat[dat[,1]  0,-1], length)
obs.neg - tapply(dat[dat[,1] = 0,1], dat[dat[,1] = 0,-1], length)
#write some coordinate data
x.obs.pos - rep(my.xlim[2],dim(obs.pos)[2])
y.obs.pos - 1:dim(obs.pos)[2]
x.obs.neg - rep(my.xlim[1],dim(obs.neg)[2])
y.obs.neg - 1:dim(obs.neg)[2]

bwplot(treatment~foo|group, data = dat,
   panel=function(...) {
   panel.violin(..., col = transparent, varwidth = F)
   panel.abline(v=0, lty = dotted)
   ltext(x.obs.pos, y.obs.pos, obs.pos, pos = 2)
   ltext(x.obs.neg, y.obs.neg, obs.neg, pos = 4)
   },
   par.strip.text = list(cex = 0.8),  xlim = my.xlim)
obs.pos
obs.neg

# note that the numbers in the plot only match the matrices for Group A,
# which is the first panel. Alas.

__
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-help: conversion of long decimal numbers into hexadecimal numbers

2005-11-10 Thread Antje Döring
Hi there,

 

could somebody help me to convert a decimal number into a hexadecimal number? I 
know that there is the function sprintf, but the numbers I want to convert 
consist of  20 or more numbers. Spintf is not able to convert these big 
numbers.

 

Thanks for any help.

 

Antje Döring

 

 


[[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] question about the dataset fgl

2005-11-10 Thread Liaw, Andy
`VR' is a bundle consisting of `MASS', `class', `nnet' and `spatial', as the
description says.  The fgl data is in the MASS package, so you need to load
that one.  In any case, data() would have told you that after the bundle is
installed.

Andy

 From: Huh, Seungho
 
 Dear sir or ma'am,
 
  
 
 I have a question about the dataset fgl. The dataset seems to be in
 the VR package, so I tried to download it from CRAN. However, after
 downloading, when I tried to load the package, it was not in 
 my package
 list. I am wondering what is wrong.
 
  
 
 Any advice on how to access the fgl dataset would be appreciated.
 Thanks. 
 
  
 
 Seungho Huh
 
  
 
  
 
 
   [[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 regarding mas5 normalization

2005-11-10 Thread Nayeem Quayum
Hello everybody,
I am trying to use mas5 to normalize some array data and using mas5 and
mas5calls. But I received these warning message. If anybody can explain the
problem I would really appreciate that. Thanks in advance.
background correction: mas
PM/MM correction : mas
expression values: mas
background correcting...Warning message:
'loadURL' is deprecated.
Use 'load(url())' instead.
See help(Deprecated)
Warning message:
'loadURL' is deprecated.
Use 'load(url())' instead.
See help(Deprecated)
Warning message:
'loadURL' is deprecated.
Use 'load(url())' instead.
See help(Deprecated)
There were 14 warnings (use warnings() to see them)
Note: http://www.bioconductor.org/repository/devel/package/Win32 does not
seem to have a valid repository, skipping
Note: You did not specify a download type. Using a default value of: Source
This will be fine for almost all users

Error in FUN(X[[1]], ...) : no slot of name Uses for this object of class
localPkg

[[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] order statistics / sample quantiles

2005-11-10 Thread Bickel, David
Are there any R functions or packages that can compute distributions,
expectations, or quantiles of order statistics (or sample quantiles or
extreme values) for a given distribution such as a normal distribution?
Both exact and asymptotic calculations are of interest. I am already
aware of the 'quantile' function of 'stats'.

David
___
David R. Bickel  http://davidbickel.com
Research Scientist
Pioneer Hi-Bred International (DuPont)
Bioinformatics and Exploratory Research
7200 NW 62nd Ave.; PO Box 184
Johnston, IA 50131-0184
515-334-4739 Tel
515-334-4473 Fax
[EMAIL PROTECTED], [EMAIL PROTECTED]

This communication is for use by the intended recipient and ...{{dropped}}

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


Re: [R] different functions on different vector subsets

2005-11-10 Thread Berton Gunter
The error messages mean what they say.

 I am trying to apply two different functions on on a vector as follow:
 a-c(NA,1,2,3,-3,-4,-6)
 if a0 I would like to raise it by the power of 2: 2^a and if 
 the a0 I
 would like to have the inverse value, i.e., -1/2^a.
## I assume you mean 1/(2^a). If not, modify the following appropriately.

2^(a*sign(a))  ## will do

As for your error message for:
 a[a0]-(-1)/2^a[a0]

a0 has an NA at the first index and so R doesn't know what index you want
to assign the value to. Ergo the error message.

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
The business of the statistician is to catalyze the scientific learning
process.  - George E. P. Box
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Ron Ophir
 Sent: Thursday, November 10, 2005 7:26 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] different functions on different vector subsets
 
 Hi,
 I am trying to apply two different functions on on a vector as follow:
 a-c(NA,1,2,3,-3,-4,-6)
 if a0 I would like to raise it by the power of 2: 2^a and if 
 the a0 I
 would like to have the inverse value, i.e., -1/2^a.
 so I thought of doing it two steps:
 a[a0]-2^[a0]
 a[a0]-(-1)/2^a[a0]
 I got the following error
 Error: NAs are not allowed in subscripted assignments
 any other manupulation that I did with is.na() but did not succeed.
 What is funny that the two sides of the assignment work and return the
 same vector size:
  2^a[a0]
 [1] NA  2  4  8
  a[a0]
 [1] NA  1  2  3
 
 I found a solution in term of:
 sapply(a,function(x) if (is(s.na)) NA else if (x0) (-1)/2^x else 2^x)
 but still I would like to understand why the solution above did not
 work. I think is more ellegant.
 my R version is:
  sessionInfo()
 R version 2.2.0, 2005-10-06, i386-pc-mingw32 
  
 attached base packages:
 [1] methods   stats graphics  grDevices utils
 datasets 
 [7] base 
 Thanks,
 Ron
  
 
   [[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] different functions on different vector subsets

2005-11-10 Thread Thomas Lumley
On Thu, 10 Nov 2005, Ron Ophir wrote:

 Hi,
 I am trying to apply two different functions on on a vector as follow:
 a-c(NA,1,2,3,-3,-4,-6)
 if a0 I would like to raise it by the power of 2: 2^a and if the a0 I
 would like to have the inverse value, i.e., -1/2^a.
 so I thought of doing it two steps:
 a[a0]-2^[a0]
 a[a0]-(-1)/2^a[a0]
 I got the following error
 Error: NAs are not allowed in subscripted assignments
 any other manupulation that I did with is.na() but did not succeed.
 What is funny that the two sides of the assignment work and return the
 same vector size:
 2^a[a0]
 [1] NA  2  4  8
 a[a0]
 [1] NA  1  2  3

The reason NAs are not allowed in subscripted assignments is based on 
numeric rather than logical subscripts.

For numeric subscripts the problem is ambiguity about what the NA index 
should do (we know there is ambiguity because two parts of the R code did 
different things).  For logical subscripts you could argue that the 
ambiguity isn't present and that if the index was NA the element should 
just be set to NA. This change might be worth making.


 I found a solution in term of:
 sapply(a,function(x) if (is(s.na)) NA else if (x0) (-1)/2^x else 2^x)
 but still I would like to understand why the solution above did not
 work. I think is more ellegant.

A better general solution is

  a-ifelse(a0, -1/2^a, 2^a)

An alternative for this problem that is faster when a is very large is
  a-sign(a)*2^abs(a)

-thomas

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


Re: [R] different functions on different vector subsets

2005-11-10 Thread Berton Gunter

Oops. Sorry. Should be:

sign(a)*2^a

where I assume you meant the inverse value should be -1/2^|a| = - 2^a for
a0

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
The business of the statistician is to catalyze the scientific learning
process.  - George E. P. Box
 
 

 -Original Message-
 From: bgunter 
 Sent: Thursday, November 10, 2005 9:00 AM
 To: Ron Ophir; r-help@stat.math.ethz.ch
 Subject: RE: [R] different functions on different vector subsets
 
 The error messages mean what they say.
 
  I am trying to apply two different functions on on a vector 
 as follow:
  a-c(NA,1,2,3,-3,-4,-6)
  if a0 I would like to raise it by the power of 2: 2^a and if 
  the a0 I
  would like to have the inverse value, i.e., -1/2^a.
 ## I assume you mean 1/(2^a). If not, modify the following 
 appropriately.
 
 2^(a*sign(a))  ## will do
 
 As for your error message for:
  a[a0]-(-1)/2^a[a0]
 
 a0 has an NA at the first index and so R doesn't know what 
 index you want to assign the value to. Ergo the error message.
 
 -- Bert Gunter
 Genentech Non-Clinical Statistics
 South San Francisco, CA
  
 The business of the statistician is to catalyze the 
 scientific learning process.  - George E. P. Box
  
  
 
  -Original Message-
  From: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of Ron Ophir
  Sent: Thursday, November 10, 2005 7:26 AM
  To: r-help@stat.math.ethz.ch
  Subject: [R] different functions on different vector subsets
  
  Hi,
  I am trying to apply two different functions on on a vector 
 as follow:
  a-c(NA,1,2,3,-3,-4,-6)
  if a0 I would like to raise it by the power of 2: 2^a and if 
  the a0 I
  would like to have the inverse value, i.e., -1/2^a.
  so I thought of doing it two steps:
  a[a0]-2^[a0]
  a[a0]-(-1)/2^a[a0]
  I got the following error
  Error: NAs are not allowed in subscripted assignments
  any other manupulation that I did with is.na() but did not succeed.
  What is funny that the two sides of the assignment work and 
 return the
  same vector size:
   2^a[a0]
  [1] NA  2  4  8
   a[a0]
  [1] NA  1  2  3
  
  I found a solution in term of:
  sapply(a,function(x) if (is(s.na)) NA else if (x0) 
 (-1)/2^x else 2^x)
  but still I would like to understand why the solution above did not
  work. I think is more ellegant.
  my R version is:
   sessionInfo()
  R version 2.2.0, 2005-10-06, i386-pc-mingw32 
   
  attached base packages:
  [1] methods   stats graphics  grDevices utils
  datasets 
  [7] base 
  Thanks,
  Ron
   
  
  [[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] Concurrent structures

2005-11-10 Thread Michael Kubovy
@BOOK{Mandel1995,
   title = {Analysis of two-way layouts},
   publisher = {Chapman \ Hall},
   year = {1995},
   address = {New York, NY, USA},
   author = {John Mandel},
}

describes diagnostics for identifying concurrent structures (i.e., y_ 
{ij} = A + B_{i} * C_{j} + e_{ij} ). Does anyone know of an  
implementation in R?


_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

__
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-help: conversion of long decimal numbers into hexadeci

2005-11-10 Thread Ted Harding
On 10-Nov-05 Antje Döring wrote:
 Hi there,
 
 could somebody help me to convert a decimal number into a hexadecimal
 number? I know that there is the function sprintf, but the numbers I
 want to convert consist of  20 or more numbers. Spintf is not able to
 convert these big numbers.

If I understand aright, you have decimal integers with 20 or more
digits (and you want to get these as hexadecimal).

You are probably out of luck for a direct approach, since
10^20  2^64 (indeed  2^66), so you will have overflowed a 64-bit
integer. However, I'm not sure what the limitations on integer
types are in R on all platforms.

If, however, all you need is to do these conversions, and you
do not really need to use R (how off-topic can I get ... ?),
then (at any rate on Linux/Unix systems where the program is
installed by default) you can use the aribitrary-precision
calculator 'bc'.

Session:

$ bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
obase=16

1234567898765432123456789
1056E0F555A18EBDA7D15

123456789876543212345678987654321
6163E6712EBBAA4E3D62B41F4B1

12345678987654321234567898765432123456789876543212345678987654321
1E02BC221DC9369C8981C6F859501BD313D339F09180862B41F4B1

quit


Und so weiter ... and of course you can go in the opposite
direction by ibase=16 (to set hex as the input base) and
obase=10 (to set decimal as the output base).

'bc' is a classic Unix tool, and features as an illoustration
of complex programming in C, with lex and yacc and all, in
The Unix Programming Environment (as I recall) by Kernighan
and Ritchie.

I don't need it often, but when you need it it's very handy
(e.g. now).

Hoping this helps,
Ted.

PS:

$ bc -l
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
scale=1000
pi=4*a(1)
pi
3.141592653589793238462643383279502884197169399375105820974944592307\
81640628620899862803482534211706798214808651328230664709384460955058\
22317253594081284811174502841027019385211055596446229489549303819644\
28810975665933446128475648233786783165271201909145648566923460348610\
..
08302642522308253344685035261931188171010003137838752886587533208381\
42061717766914730359825349042875546873115956286388235378759375195778\
18577805321712268066130019278766111959092164201988

(last digit wrong because of truncation)



E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 10-Nov-05   Time: 17:28:05
-- XFMail --

__
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] different functions on different vector subsets

2005-11-10 Thread Prof Brian Ripley
On Thu, 10 Nov 2005, Ron Ophir wrote:

 Hi,
 I am trying to apply two different functions on on a vector as follow:
 a-c(NA,1,2,3,-3,-4,-6)
 if a0 I would like to raise it by the power of 2: 2^a and if the a0 I
 would like to have the inverse value, i.e., -1/2^a.
 so I thought of doing it two steps:
 a[a0]-2^[a0]
 a[a0]-(-1)/2^a[a0]
 I got the following error
 Error: NAs are not allowed in subscripted assignments
 any other manupulation that I did with is.na() but did not succeed.
 What is funny that the two sides of the assignment work and return the
 same vector size:
 2^a[a0]
 [1] NA  2  4  8
 a[a0]
 [1] NA  1  2  3

 I found a solution in term of:
 sapply(a,function(x) if (is(s.na)) NA else if (x0) (-1)/2^x else 2^x)
 but still I would like to understand why the solution above did not
 work. I think is more ellegant.

What do you think the NA value in

 a  0
[1]NA  TRUE  TRUE  TRUE FALSE FALSE FALSE

means?  Should you replace a[1] or not?  You are saying you don't know, so 
what is R to do?  It tells you to make up your mind.

Try

ind - !is.na(a)  a  0
a[ind] - 2^a[ind]
ind - !is.na(a)  a  0
a[ind] - (-1)/2^a[ind]

or use ifelse as in

ifelse(a  0, 2^a, -1/2^a)

which is a lot more elegant.

-- 
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] ltext - adding text to each panel from a matrix

2005-11-10 Thread Austin, Matt
Haven't checked it too carefully, but how about:

bwplot(treatment~foo|group, data = dat,
   panel=function(x,y,...) {
   panel.violin(x,y, ..., col = transparent, varwidth = F)
   gt0 - table( x  0, y)
   panel.abline(v=0, lty = dotted)
   grid.text(as.character(gt0[1,]), unit(1, 'lines'), unit(1:3,
'native'), just='left')
   grid.text(as.character(gt0[2,]), unit(1, 'npc') - unit(1,
'lines'), unit(1:3, 'native'), just='left')
   },
   par.strip.text = list(cex = 0.8),  xlim = my.xlim)


--Matt

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of Andy Bunn
 Sent: Thursday, November 10, 2005 8:19 AM
 To: R-Help
 Subject: [R] ltext - adding text to each panel from a matrix
 
 
 Hi all (really probably just Deepayan):
 
 In the plot below I want to add text on either side of each 
 violin plot that
 indicates the number of observations that are either positive 
 or negative.
 I'm trying to do this with ltext() and I've also monkeyed about with
 panel.text(). The code below is generally what I want but my calls to
 ltext() are wrong and I'm not sure how to fix them. Right now 
 they replicate
 the first column of the matrices obs.pos and obs.neg for each 
 panel. How do
 I tell ltext to advance to the next column when the next 
 panel is plotted? I
 don't see how subscripts can do it, but I bet it's something 
 along that
 line...
 
 Thanks, Andy
 
 rm(list = ls())
 set.seed(354)
 # make a bimodal dataset with three groups and three treatments
 foo - c(rnorm(150,-1,0.5), rnorm(150,1,0.25))
 treatment - factor(rep(seq(1,3),100), labels = c(Treatment 
 1, Treatment
 2, Treatment 3))
 group - factor(rep(seq(1,3),100), labels = c(Group A, 
 Group B, Group
 C))
 group - sample(group)
 # corrupt Group A, Treatment 2 for fun.
 foo[group==Group A  treatment==Treatment 2][1:8] - rnorm(8,1,1)
 dat - data.frame(foo,treatment,group)
 
 # set the limits for the plot, which also tells where to put the text
 my.xlim - c(-6, 6)
 
 # make a matrix that counts the number of obs greater or less 
 than zero
 obs.pos - tapply(dat[dat[,1]  0,1], dat[dat[,1]  0,-1], length)
 obs.neg - tapply(dat[dat[,1] = 0,1], dat[dat[,1] = 0,-1], length)
 #write some coordinate data
 x.obs.pos - rep(my.xlim[2],dim(obs.pos)[2])
 y.obs.pos - 1:dim(obs.pos)[2]
 x.obs.neg - rep(my.xlim[1],dim(obs.neg)[2])
 y.obs.neg - 1:dim(obs.neg)[2]
 
 bwplot(treatment~foo|group, data = dat,
panel=function(...) {
panel.violin(..., col = transparent, varwidth = F)
panel.abline(v=0, lty = dotted)
ltext(x.obs.pos, y.obs.pos, obs.pos, pos = 2)
ltext(x.obs.neg, y.obs.neg, obs.neg, pos = 4)
},
par.strip.text = list(cex = 0.8),  xlim = my.xlim)
 obs.pos
 obs.neg
 
 # note that the numbers in the plot only match the matrices 
 for Group A,
 # which is the first panel. Alas.
 
 __
 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] specifying a key for a trellis display

2005-11-10 Thread Berton Gunter
Folks:

The key argument of trellis commands (e.g. xyplot()) allows one to place a
key at the top of a trellis display using 

key=list(space='top',...)

I would like to increase the space between the bottom of the key and the
trellis plots beyond the default. Is there a simple way to do this? At
present, I add an empty row (e.g. text = '', point colored in background
color) to the bottom of each key column. This seems a bit of a kludge. Is
there a slicker way to do it, i.e. a parameter that I have missed?

Cheers,
Bert

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
The business of the statistician is to catalyze the scientific learning
process.  - George E. P. Box

__
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] ltext - adding text to each panel from a matrix

2005-11-10 Thread Deepayan Sarkar
On 11/10/05, Andy Bunn [EMAIL PROTECTED] wrote:
 Hi all (really probably just Deepayan):

 In the plot below I want to add text on either side of each violin plot
 that
 indicates the number of observations that are either positive or negative.
 I'm trying to do this with ltext() and I've also monkeyed about with
 panel.text().

They are the same (at least for now).

 The code below is generally what I want but my calls to
 ltext() are wrong and I'm not sure how to fix them. Right now they
 replicate
 the first column of the matrices obs.pos and obs.neg for each panel. How do
 I tell ltext to advance to the next column when the next panel is plotted?
 I
 don't see how subscripts can do it, but I bet it's something along that
 line...

Maybe, but there's a more direct solution (somewhat artificial perhaps):

bwplot(treatment~foo|group, data = dat,
   panel=function(..., packet.number) {
   panel.violin(..., col = transparent, varwidth = F)
   panel.abline(v=0, lty = dotted)
   ltext(x.obs.pos, y.obs.pos, obs.pos[, packet.number], pos = 2)
   ltext(x.obs.neg, y.obs.neg, obs.neg[, packet.number], pos = 4)
   },
   par.strip.text = list(cex = 0.8),  xlim = my.xlim)

This is documented under 'panel' in ?xyplot.

Deepayan

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


Re: [R] write.table read.table with Dates

2005-11-10 Thread Don MacQueen
In addition to the solutions already provided, note that if *all* you 
want to do is save your dataframe in a file, and later recreate it 
from that file, you can use dump().

dump('Tall',file='Tall.r')
rm(Tall)  ## just to demonstrate that the next command will recreate Tall
source('Tall.r')

-Don

At 2:21 PM +0100 11/10/05, JeeBee wrote:
I've found several similar issues with write.table/read.table
with Dates on this list, but trying to follow this advice I still
get an error.

First, I read in data from several files, constructing several date/time
columns using ISOdatetime

  str(Tall$Begin)
'POSIXct', format: chr [1:40114] 2005-10-02 00:00:00 2005-10-02
00:00:00 ...
  length(Tall$Begin)
[1] 40114
  class(Tall$Begin)
[1] POSIXt  POSIXct

This looks good (time is not always 00:00:00 ...)
This data came from several files, now I want to store the result I have
in data.frame Tall and be able to retrieve this quickly some other time.

This is what I do:
write.table(Tall, file=somefile.csv, sep=,, qmethod=double,
row.names=FALSE)

Later, I do this to read the file again:
fieldnames=c(Begin,test-a,test-b,Eind)
T=read.table(file = somefile.csv, col.names = fieldnames,
   header = TRUE, sep = ,, quote=\, fill=FALSE)

I understand T$Begin now is a factor. I tried to simply convert it
again using (as I read on this mailinglist ...):
Q = strptime(as.character(T$Begin),format=%Y-%m-%d %H:%M:%S)

Q is looking good, though its length I don't understand .. is it a list or
something? It seems there are 40114 values in there somewhere...

  class(Q)
[1] POSIXt  POSIXlt
  length(Q)
[1] 9
  str(Q)
'POSIXlt', format: chr [1:40114] 2005-10-02 00:00:00 2005-10-02 
00:00:00 ...

T$Begin = Q ### yields this error
Error in $-.data.frame(`*tmp*`, Begin, value = list(sec = c(0, 0,  :
 replacement has 9 rows, data has 40114

Could somebody explain me how to convert the date column?
Or perhaps there is an easier way?

Thanks in advance for your time.

__
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] order statistics / sample quantiles

2005-11-10 Thread Thomas Lumley
On Thu, 10 Nov 2005, Bickel, David wrote:

 Are there any R functions or packages that can compute distributions,
 expectations, or quantiles of order statistics (or sample quantiles or
 extreme values) for a given distribution such as a normal distribution?
 Both exact and asymptotic calculations are of interest. I am already
 aware of the 'quantile' function of 'stats'.


The density function of the order statistics is given as an example in the 
FAQ.  This can then be integrated with integrate() to give expectations.

-thomas

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


Re: [R] specifying a key for a trellis display

2005-11-10 Thread Deepayan Sarkar
On 11/10/05, Berton Gunter [EMAIL PROTECTED] wrote:
 Folks:

 The key argument of trellis commands (e.g. xyplot()) allows one to place
 a
 key at the top of a trellis display using

 key=list(space='top',...)

 I would like to increase the space between the bottom of the key and the
 trellis plots beyond the default. Is there a simple way to do this? At
 present, I add an empty row (e.g. text = '', point colored in background
 color) to the bottom of each key column. This seems a bit of a kludge. Is
 there a slicker way to do it, i.e. a parameter that I have missed?

Yes, trellis.par.get(layout.heights). e.g.

xyplot(1 ~ 1, key = list(text = list(letters[1:3]), points = list(col = 1:3)),
   par.settings = list(layout.heights = list(key.axis.padding = 5)))

-Deepayan

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


Re: [R] specifying a key for a trellis display

2005-11-10 Thread Berton Gunter
Many thanks, Deepayan. As I suspected... I'll fool around with these key
arguments to see what they do.

-- Bert
 

 -Original Message-
 From: Deepayan Sarkar [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, November 10, 2005 11:31 AM
 To: Berton Gunter
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: specifying a key for a trellis display
 
 On 11/10/05, Berton Gunter [EMAIL PROTECTED] wrote:
  Folks:
 
  The key argument of trellis commands (e.g. xyplot()) 
 allows one to place
  a
  key at the top of a trellis display using
 
  key=list(space='top',...)
 
  I would like to increase the space between the bottom of 
 the key and the
  trellis plots beyond the default. Is there a simple way to 
 do this? At
  present, I add an empty row (e.g. text = '', point colored 
 in background
  color) to the bottom of each key column. This seems a bit 
 of a kludge. Is
  there a slicker way to do it, i.e. a parameter that I have missed?
 
 Yes, trellis.par.get(layout.heights). e.g.
 
 xyplot(1 ~ 1, key = list(text = list(letters[1:3]), points = 
 list(col = 1:3)),
par.settings = list(layout.heights = 
 list(key.axis.padding = 5)))
 
 -Deepayan


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


Re: [R] different functions on different vector subsets

2005-11-10 Thread Ron Ophir
Thanks Thomas,

...For logical subscripts you could argue that the 
ambiguity isn't present and that if the index was NA the element should 
just be set to NA. This change might be worth making.

I see you got my point. NA should return NA no matter what the
comparison is. But any way thanks Brian, Jim, and Berton, I have leaned
a lot. It was a good practice.
Ron

Ron Ophir, Ph.D.
Bioinformatician,
Biological Services
Weizmann Institute of Science
POB 26
Rehovot 76100
Israel
e-mail: [EMAIL PROTECTED]
Phone: 972-8-9342614
Fax:972-8-9344113
 Thomas Lumley [EMAIL PROTECTED] 11/10/05 7:04 PM 
On Thu, 10 Nov 2005, Ron Ophir wrote:

 Hi,
 I am trying to apply two different functions on on a vector as follow:
 a-c(NA,1,2,3,-3,-4,-6)
 if a0 I would like to raise it by the power of 2: 2^a and if the a0
I
 would like to have the inverse value, i.e., -1/2^a.
 so I thought of doing it two steps:
 a[a0]-2^[a0]
 a[a0]-(-1)/2^a[a0]
 I got the following error
 Error: NAs are not allowed in subscripted assignments
 any other manupulation that I did with is.na() but did not succeed.
 What is funny that the two sides of the assignment work and return the
 same vector size:
 2^a[a0]
 [1] NA  2  4  8
 a[a0]
 [1] NA  1  2  3

The reason NAs are not allowed in subscripted assignments is based on 
numeric rather than logical subscripts.

For numeric subscripts the problem is ambiguity about what the NA index 
should do (we know there is ambiguity because two parts of the R code
did 
different things).  For logical subscripts you could argue that the 
ambiguity isn't present and that if the index was NA the element should 
just be set to NA. This change might be worth making.


 I found a solution in term of:
 sapply(a,function(x) if (is(s.na)) NA else if (x0) (-1)/2^x else 2^x)
 but still I would like to understand why the solution above did not
 work. I think is more ellegant.

A better general solution is

  a-ifelse(a0, -1/2^a, 2^a)

An alternative for this problem that is faster when a is very large is
  a-sign(a)*2^abs(a)

-thomas

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


Re: [R] different functions on different vector subsets

2005-11-10 Thread Prof Brian Ripley
On Thu, 10 Nov 2005, Thomas Lumley wrote:

 On Thu, 10 Nov 2005, Ron Ophir wrote:

 Hi,
 I am trying to apply two different functions on on a vector as follow:
 a-c(NA,1,2,3,-3,-4,-6)
 if a0 I would like to raise it by the power of 2: 2^a and if the a0 I
 would like to have the inverse value, i.e., -1/2^a.
 so I thought of doing it two steps:
 a[a0]-2^[a0]
 a[a0]-(-1)/2^a[a0]
 I got the following error
 Error: NAs are not allowed in subscripted assignments
 any other manupulation that I did with is.na() but did not succeed.
 What is funny that the two sides of the assignment work and return the
 same vector size:
 2^a[a0]
 [1] NA  2  4  8
 a[a0]
 [1] NA  1  2  3

 The reason NAs are not allowed in subscripted assignments is based on
 numeric rather than logical subscripts.

 For numeric subscripts the problem is ambiguity about what the NA index
 should do (we know there is ambiguity because two parts of the R code did
 different things).  For logical subscripts you could argue that the
 ambiguity isn't present and that if the index was NA the element should
 just be set to NA. This change might be worth making.

That presumes NA is a valid value, but in general it is not. (Not for raw, 
not for lists, not for data frames, )  I don't think we want such 
inconsistent behaviour.

-- 
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] grid.remove() doesn't remove output

2005-11-10 Thread Zepu Zhang
I've found that grid.remove() doesn't clear the output when the grob is 
the only one on the device (or viewport; I didn't test it). For example:

library(grid)
grid.newpage()

grid.circle(name=cir, x=.5, y=.5, r=.3, gp=gpar(lwd=5))
grid.lines(c(.2, .8), c(.3, .7), name=lin)
grid.remove(cir)  # circle disappears
grid.remove(lin)  # object deleted, but line remains on output

If I now draw another primitive, lin disappears.

If I plotted only one thing, say cir, in the first place,
grid.remove() won't clear the output.

I'm using R 2.2. Any pointer is appreciated.

Zepu

__
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] different functions on different vector subsets

2005-11-10 Thread Thomas Lumley
On Thu, 10 Nov 2005, Ron Ophir wrote:

 Thanks Thomas,

 ...For logical subscripts you could argue that the
 ambiguity isn't present and that if the index was NA the element should
 just be set to NA. This change might be worth making.

 I see you got my point. NA should return NA no matter what the
 comparison is.

I'm not sure that I did get your point.  As Brian said, you aren't 
specifying whether or not to set the value. In your example it didn't 
matter because it would end up NA either way.

I was saying that for eg

a-c(1,2,3,4)
b-c(NA,T,F,T)

a[b]-7

we could relax the prohibition on NA indexing to give c(NA,7,7,7) as the 
result. In your case that would give what you wanted, but in other cases 
it might not.


-thomas

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


Re: [R] different functions on different vector subsets

2005-11-10 Thread Thomas Lumley
On Thu, 10 Nov 2005, Thomas Lumley wrote:

 On Thu, 10 Nov 2005, Ron Ophir wrote:

 Thanks Thomas,
 
 ...For logical subscripts you could argue that the
 ambiguity isn't present and that if the index was NA the element should
 just be set to NA. This change might be worth making.
 
 I see you got my point. NA should return NA no matter what the
 comparison is.

 I'm not sure that I did get your point.  As Brian said, you aren't specifying 
 whether or not to set the value. In your example it didn't matter because it 
 would end up NA either way.


And as Brian later pointed out, this approach wouldn't work for things 
other than simple vectors.

-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] make check failed on linux-amd64 using PGI compilers

2005-11-10 Thread Liaw, Andy
Dear R-help,

I am trying to build R-2.2.0-patched (2005-11-07 r36217) on the head node of
a Scyld cluster (dual Opteron 250s) using PGI compilers (v6.0).  I used the
flags suggested by Jennifer Lai on R-devel (taken from R-admin, except that
I had to add -L/usr/X11R6/lib64 to LDFLAGS).  The build went fine, but make
check-all failed when running tests/Examples/graphics-Ex.R, at:

 plot(1:2, xaxs = i) # 'inner-axis' w/o extra space
 stopifnot(par(xaxp)[1:2] == 1:2 
+   par(usr)[1:2] == 1:2)
Error: par(xaxp)]1:2] == 1:2  par(usr)[1:2] == 1:2 is not TRUE

The above looks a bit strange to me, as running the R built as above,
par(xaxp)[1:2] - 1:2 gives

[1] -1.110223e-16 -2.220446e-16

Is my R build faulty?  I'd very much appreciate any advise.

Best,
Andy

__
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] IF/Else

2005-11-10 Thread Guenther, Cameron
Hi,
I am trying to write a for loop with if else statements to calculate
biomass density estimates for different types of sampling gear.  
My code is:

bmd=for (i in 1:length(Gear)){
if (Gear==20) {bioden=Biomass/141}
else {if (Gear==23) {bioden=Biomass/68}}
else {if (Gear==160) {bioden=Biomass/4120}}
else {if (Gear==170) {bioden=Biomass/2210}}
else {if (Gear==300) {bioden=Biomass/(DIST_TOW*4*1853)}}
else {if (Gear==301) {bioden=Biomass/(DIST_TOW*4*1853)}}
}

The syntax that is returned is:

 bmd=for (i in 1:length(Gear)){
+ if (Gear==20) {bioden=Biomass/141}
+ else {if (Gear==23) {bioden=Biomass/68}}
+ else {if (Gear==160) {bioden=Biomass/4120}}
Error: syntax error in:
else {if (Gear==23) {bioden=Biomass/68}}
else
 else {if (Gear==170) {bioden=Biomass/2210}}
Error: syntax error in else
 else {if (Gear==300) {bioden=Biomass/(DIST_TOW*4*1853)}}
Error: syntax error in else
 else {if (Gear==301) {bioden=Biomass/(DIST_TOW*4*1853)}}
Error: syntax error in else
 }
Error: syntax error in }

It appears that the code works for the first two if/else statements and
then fails there after.  Any suggestions?

Cameron Guenther 
Associate Research Scientist
FWC/FWRI, Marine Fisheries Research
100 8th Avenue S.E.
St. Petersburg, FL 33701
(727)896-8626 Ext. 4305
[EMAIL PROTECTED]

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


[R] How to export multiple files using write.table in the loop?

2005-11-10 Thread alice.0309
Hi,
 
I tried to split a big file into some small files seperately by R.  I can only 
do that writing duplicated codes.  When I tried to write a loop, I only got one 
appned or destroyed exported file.   For example:
 
data1- read.table(file = C:\\Alice\\MBEI.txt, sep=\t, check.names=FALSE)
a-subset(data1,select=c(V1,V2,V3))
write.table-(a,file=C:\\Alice\\aa1.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
a-subset(data1,select=c(V1,V4,V5))
write.table(a,file=C:\\Alice\\aa2.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
 
or
data1- read.table(file = C:\\Alice\\MBEI.txt, sep=\t, check.names=FALSE)
a-data.frame(data1[,1],data1[,2],data1[,3]
write.table-(a,file=C:\\Alice\\aa1.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
a-data.frame(data1[,1],data1[,4],data1[,5]
write.table(a,file=C:\\Alice\\aa2.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
 
I tried to write a loop for it like :
 
 
i - 1
while (i 3)
{
qq-data.frame(test[,1],test[,2[i],test[,2[i]+1])
write.table(qq,file=C:\\Alice\\bb.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
i - i+1;
}

But it's not right.  I tried hard to revise it but I just can't make it.  If 
someone can help me out here, your help is really greatly appreciated.  Thank 
you sooo much!
 
Best,
 
Alice
 
 



-

[[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] converting a character string to a subscripted numeric variable

2005-11-10 Thread Charles Annis, P.E.
Dear R-helpers:

It seems that I have a mental block.  (Some say that it sits atop my
shoulders.)

For reasons too tedious to retell I have an R object:

 input.line[7]
[1] -13.24, -11.24, -9.24, -7.24, -5.24, -3.24, -1.24, 0.76, 2.76, 4.76,
6.76, 8.76, 10.76, 12.76, 14.76, 16.76, 18.76, 20.76, 22.76, 24.76, 26.76,
28.76, 30.76, 32.76, 34.76, 36.76, 38.76, 40.76, 42.76, 44.76, 


I would like to convert this into a subscripted variable, Beta, something
that should be straightforward if I had *almost* what I have.

I'd like to say

Beta - c(-13.24, -11.24, -9.24, -7.24, -5.24, -3.24, -1.24, 0.76, 2.76,
4.76, 6.76, 8.76, 10.76, 12.76, 14.76, 16.76, 18.76, 20.76, 22.76, 24.76,
26.76, 28.76, 30.76, 32.76, 34.76, 36.76, 38.76, 40.76, 42.76, 44.76)

but I can't because:

input.line[7] is a character string, and

it ends in a comma.


This cannot be as difficult as I have found it to be.  Can anyone help?

Copious Thanks.


Charles Annis, P.E.

[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.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] converting a character string to a subscripted numeric variable

2005-11-10 Thread Sundar Dorai-Raj


Charles Annis, P.E. wrote:
 Dear R-helpers:
 
 It seems that I have a mental block.  (Some say that it sits atop my
 shoulders.)
 
 For reasons too tedious to retell I have an R object:
 
 
input.line[7]
 
 [1] -13.24, -11.24, -9.24, -7.24, -5.24, -3.24, -1.24, 0.76, 2.76, 4.76,
 6.76, 8.76, 10.76, 12.76, 14.76, 16.76, 18.76, 20.76, 22.76, 24.76, 26.76,
 28.76, 30.76, 32.76, 34.76, 36.76, 38.76, 40.76, 42.76, 44.76, 
 
 
 I would like to convert this into a subscripted variable, Beta, something
 that should be straightforward if I had *almost* what I have.
 
 I'd like to say
 
 Beta - c(-13.24, -11.24, -9.24, -7.24, -5.24, -3.24, -1.24, 0.76, 2.76,
 4.76, 6.76, 8.76, 10.76, 12.76, 14.76, 16.76, 18.76, 20.76, 22.76, 24.76,
 26.76, 28.76, 30.76, 32.76, 34.76, 36.76, 38.76, 40.76, 42.76, 44.76)
 
 but I can't because:
 
 input.line[7] is a character string, and
 
 it ends in a comma.
 
 
 This cannot be as difficult as I have found it to be.  Can anyone help?
 
 Copious Thanks.

How about:

x - -13.24, -11.24, 
x - as.numeric(strsplit(x, ,)[[1]])
x[!is.na(x)]

--sundar

__
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] converting a character string to a subscripted numeric variable

2005-11-10 Thread Charles Annis, P.E.
Eternal gratitude to Sunbar and Matt and Patrick!

The easy solution is

Beta - as.numeric(strsplit(input.line [7], ,)[[1]])
Beta - Beta[!is.na(Beta)]
Beta

I have a slew of files to interrogate and need to know from some of the
input, what to look for in the remainder of the input.

Thanks to all!


Charles Annis, P.E.

[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 
-Original Message-
From: Sundar Dorai-Raj [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 10, 2005 5:00 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [R] converting a character string to a subscripted numeric
variable



Charles Annis, P.E. wrote:
 Dear R-helpers:
 
 It seems that I have a mental block.  (Some say that it sits atop my
 shoulders.)
 
 For reasons too tedious to retell I have an R object:
 
 
input.line[7]
 
 [1] -13.24, -11.24, -9.24, -7.24, -5.24, -3.24, -1.24, 0.76, 2.76, 4.76,
 6.76, 8.76, 10.76, 12.76, 14.76, 16.76, 18.76, 20.76, 22.76, 24.76, 26.76,
 28.76, 30.76, 32.76, 34.76, 36.76, 38.76, 40.76, 42.76, 44.76, 
 
 
 I would like to convert this into a subscripted variable, Beta, something
 that should be straightforward if I had *almost* what I have.
 
 I'd like to say
 
 Beta - c(-13.24, -11.24, -9.24, -7.24, -5.24, -3.24, -1.24, 0.76, 2.76,
 4.76, 6.76, 8.76, 10.76, 12.76, 14.76, 16.76, 18.76, 20.76, 22.76, 24.76,
 26.76, 28.76, 30.76, 32.76, 34.76, 36.76, 38.76, 40.76, 42.76, 44.76)
 
 but I can't because:
 
 input.line[7] is a character string, and
 
 it ends in a comma.
 
 
 This cannot be as difficult as I have found it to be.  Can anyone help?
 
 Copious Thanks.

How about:

x - -13.24, -11.24, 
x - as.numeric(strsplit(x, ,)[[1]])
x[!is.na(x)]

--sundar

__
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] make check failed on linux-amd64 using PGI compilers

2005-11-10 Thread Peter Dalgaard
Liaw, Andy [EMAIL PROTECTED] writes:

 Dear R-help,
 
 I am trying to build R-2.2.0-patched (2005-11-07 r36217) on the head node of
 a Scyld cluster (dual Opteron 250s) using PGI compilers (v6.0).  I used the
 flags suggested by Jennifer Lai on R-devel (taken from R-admin, except that
 I had to add -L/usr/X11R6/lib64 to LDFLAGS).  The build went fine, but make
 check-all failed when running tests/Examples/graphics-Ex.R, at:
 
  plot(1:2, xaxs = i) # 'inner-axis' w/o extra space
  stopifnot(par(xaxp)[1:2] == 1:2 
 +   par(usr)[1:2] == 1:2)
 Error: par(xaxp)]1:2] == 1:2  par(usr)[1:2] == 1:2 is not TRUE
 
 The above looks a bit strange to me, as running the R built as above,
 par(xaxp)[1:2] - 1:2 gives
 
 [1] -1.110223e-16 -2.220446e-16
 
 Is my R build faulty?  I'd very much appreciate any advise.

Relative errors of 1 ULP would not ruin my sleep.  It's not obvious to
me which is the floating point operation responsible for the effect,
though, and it is a bit suspicious given that it should just be the
x-range of the data.

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

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


Re: [R] converting a character string to a subscripted numeric variable

2005-11-10 Thread Peter Dalgaard
Charles Annis, P.E. [EMAIL PROTECTED] writes:

 Eternal gratitude to Sunbar and Matt and Patrick!
 
 The easy solution is
 
 Beta - as.numeric(strsplit(input.line [7], ,)[[1]])
 Beta - Beta[!is.na(Beta)]
 Beta

Also

x - input.line [7]

eval(parse(text=paste(c(, x, 
 
or 

x - sub(, *$,,x)
scan(textConnection(x), sep=,)


 I have a slew of files to interrogate and need to know from some of the
 input, what to look for in the remainder of the input.
 
 Thanks to all!
 
 
 Charles Annis, P.E.
 
 [EMAIL PROTECTED]
 phone: 561-352-9699
 eFax:  614-455-3265
 http://www.StatisticalEngineering.com
  
 -Original Message-
 From: Sundar Dorai-Raj [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, November 10, 2005 5:00 PM
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: Re: [R] converting a character string to a subscripted numeric
 variable
 
 
 
 Charles Annis, P.E. wrote:
  Dear R-helpers:
  
  It seems that I have a mental block.  (Some say that it sits atop my
  shoulders.)
  
  For reasons too tedious to retell I have an R object:
  
  
 input.line[7]
  
  [1] -13.24, -11.24, -9.24, -7.24, -5.24, -3.24, -1.24, 0.76, 2.76, 4.76,
  6.76, 8.76, 10.76, 12.76, 14.76, 16.76, 18.76, 20.76, 22.76, 24.76, 26.76,
  28.76, 30.76, 32.76, 34.76, 36.76, 38.76, 40.76, 42.76, 44.76, 
  
  
  I would like to convert this into a subscripted variable, Beta, something
  that should be straightforward if I had *almost* what I have.
  
  I'd like to say
  
  Beta - c(-13.24, -11.24, -9.24, -7.24, -5.24, -3.24, -1.24, 0.76, 2.76,
  4.76, 6.76, 8.76, 10.76, 12.76, 14.76, 16.76, 18.76, 20.76, 22.76, 24.76,
  26.76, 28.76, 30.76, 32.76, 34.76, 36.76, 38.76, 40.76, 42.76, 44.76)
  
  but I can't because:
  
  input.line[7] is a character string, and
  
  it ends in a comma.
  
  
  This cannot be as difficult as I have found it to be.  Can anyone help?
  
  Copious Thanks.
 
 How about:
 
 x - -13.24, -11.24, 
 x - as.numeric(strsplit(x, ,)[[1]])
 x[!is.na(x)]
 
 --sundar
 
 __
 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
 

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

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


Re: [R] IF/Else

2005-11-10 Thread Ted Harding

On 10-Nov-05 Guenther, Cameron wrote:
 Hi,
 I am trying to write a for loop with if else statements to calculate
 biomass density estimates for different types of sampling gear.  
 My code is:
 
 bmd=for (i in 1:length(Gear)){
 if (Gear==20) {bioden=Biomass/141}
 else {if (Gear==23) {bioden=Biomass/68}}
 else {if (Gear==160) {bioden=Biomass/4120}}
 else {if (Gear==170) {bioden=Biomass/2210}}
 else {if (Gear==300) {bioden=Biomass/(DIST_TOW*4*1853)}}
 else {if (Gear==301) {bioden=Biomass/(DIST_TOW*4*1853)}}
 }

In the above, you have in effect written a string of elses
following a single if, since the {if(Gear==160){...}} isolates
its if from the preceding else, etc.. But there are other
things wrong.

The following should work:

  bmd=for (i in 1:length(Gear)) {
   if (Gear==20) {bioden=Biomass/141}  else 
if (Gear==23) {bioden=Biomass/68}   else 
 if (Gear==160) {bioden=Biomass/4120}  else 
  if (Gear==170) {bioden=Biomass/2210}  else 
   if (Gear==300) {bioden=Biomass/(DIST_TOW*4*1853)}  else 
if (Gear==301) {bioden=Biomass/(DIST_TOW*4*1853)}
  }

where I have removed superfluous { on the left and } on the
right.

Putting the else at the end of the line, rather than on the
next, is needed since otherwise the line is a completed
statement befor the else is encountered and then the else
is a syntax error. With else at the end of the line, the
end of line is reached on an incomplete statement so R goes
on to the next line before making up its mind about it.

I.e. Good:

  A-2
  if(A==1){B-1} else
if(A==2){B-2} else
   if(A==3){B-3}

while Bad:
  A-2
  if(A==1){B-1}
  else if(A==2){B-2}
   else if(A==3){B-3}

Also Bad:
  A-2
  if(A==1){B-1} else
{if(A==2){B-2}} else
   {if(A==3){B-3}}

since each {if(A==2){B-2}} is a complete statement delimited
by {...} and the else is then again a syntax error, The final
statement is OK, however.

Mind you, if the cases in your code are the only possibilites
for Gear, then you don't need the final if at all -- just the
assignment, since if you get that far it's the only case left,
and you'll only reach it by falling through the preceding else.

Indeed, you could even dispense with all of the elses and
just use if statements, since only one of them will be
satisfied; but of course that is a bit inefficient in that
every statement will be tested even if one has already been
satisfied.

Hoping this helps,
Ted.

 The syntax that is returned is:
 
 bmd=for (i in 1:length(Gear)){
 + if (Gear==20) {bioden=Biomass/141}
 + else {if (Gear==23) {bioden=Biomass/68}}
 + else {if (Gear==160) {bioden=Biomass/4120}}
 Error: syntax error in:
 else {if (Gear==23) {bioden=Biomass/68}}
 else
 else {if (Gear==170) {bioden=Biomass/2210}}
 Error: syntax error in else
 else {if (Gear==300) {bioden=Biomass/(DIST_TOW*4*1853)}}
 Error: syntax error in else
 else {if (Gear==301) {bioden=Biomass/(DIST_TOW*4*1853)}}
 Error: syntax error in else
 }
 Error: syntax error in }
 
 It appears that the code works for the first two if/else statements and
 then fails there after.  Any suggestions?


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 10-Nov-05   Time: 22:44:59
-- XFMail --

__
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] make check failed on linux-amd64 using PGI compilers

2005-11-10 Thread Liaw, Andy
 From: [EMAIL PROTECTED]
 
 Liaw, Andy [EMAIL PROTECTED] writes:
 
  Dear R-help,
  
  I am trying to build R-2.2.0-patched (2005-11-07 r36217) on 
 the head node of
  a Scyld cluster (dual Opteron 250s) using PGI compilers 
 (v6.0).  I used the
  flags suggested by Jennifer Lai on R-devel (taken from 
 R-admin, except that
  I had to add -L/usr/X11R6/lib64 to LDFLAGS).  The build 
 went fine, but make
  check-all failed when running tests/Examples/graphics-Ex.R, at:
  
   plot(1:2, xaxs = i) # 'inner-axis' w/o extra space
   stopifnot(par(xaxp)[1:2] == 1:2 
  +   par(usr)[1:2] == 1:2)
  Error: par(xaxp)]1:2] == 1:2  par(usr)[1:2] == 1:2 is not TRUE
  
  The above looks a bit strange to me, as running the R built 
 as above,
  par(xaxp)[1:2] - 1:2 gives
  
  [1] -1.110223e-16 -2.220446e-16
  
  Is my R build faulty?  I'd very much appreciate any advise.
 
 Relative errors of 1 ULP would not ruin my sleep.  It's not obvious to
 me which is the floating point operation responsible for the effect,
 though, and it is a bit suspicious given that it should just be the
 x-range of the data.

It's the par() output that has storage mode double, as that stores the
coordinates.  1:2 has storage mode integer.

Those comparisons looked a bit suspicious to me.  Isn't it recommended time
and again on this list not to test for exact equality of numerics?
all.equal() of the above does return TRUE.

Andy

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


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


Re: [R] Interpretation of output from glm

2005-11-10 Thread Pedro de Barros
Dear John,

Thanks for the pointers. I will read this.

Pedro
At 14:41 10/11/2005, you wrote:
Dear Pedro,

The basic point, which relates to the principle of marginality in
formulating linear models, applies whether the predictors are factors,
covariates, or both. I think that this is a common topic in books on linear
models; I certainly discuss it in my Applied Regression, Linear Models, and
Related Methods.

Regards,
  John


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox


  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of Pedro de Barros
  Sent: Wednesday, November 09, 2005 10:45 AM
  To: r-help@stat.math.ethz.ch
  Subject: Re: [R] Interpretation of output from glm
  Importance: High
 
  Dear John,
 
  Thanks for the quick reply. I did indeed have these ideas,
  but somehow floating, and all I could find about this
  mentioned categorical predictors. Can you suggest a good book
  where I could try to learn more about this?
 
  Thanks again,
 
  Pedro
  At 01:49 09/11/2005, you wrote:
  Dear Pedro,
  
  
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Pedro de
Barros
Sent: Tuesday, November 08, 2005 9:47 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Interpretation of output from glm
Importance: High
   
I am fitting a logistic model to binary data. The
  response variable
is a factor (0 or 1) and all predictors are continuous variables.
The main predictor is LT (I expect a logistic relation between LT
and the probability of being
mature) and the other are variables I expect to modify
  this relation.
   
I want to test if all predictors contribute significantly for the
fit or not I fit the full model, and get these results
   
  summary(HMMaturation.glmfit.Full)
   
Call:
glm(formula = Mature ~ LT + CondF + Biom + LT:CondF + LT:Biom,
 family = binomial(link = logit), data = HMIndSamples)
   
Deviance Residuals:
 Min   1Q   Median   3Q  Max
-3.0983  -0.7620   0.2540   0.7202   2.0292
   
Coefficients:
   Estimate Std. Error z value Pr(|z|)
(Intercept) -8.789e-01  3.694e-01  -2.379  0.01735 *
LT   5.372e-02  1.798e-02   2.987  0.00281 **
CondF   -6.763e-02  9.296e-03  -7.275 3.46e-13 ***
Biom-1.375e-02  2.005e-03  -6.856 7.07e-12 ***
LT:CondF 2.434e-03  3.813e-04   6.383 1.74e-10 ***
LT:Biom  7.833e-04  9.614e-05   8.148 3.71e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
   
(Dispersion parameter for binomial family taken to be 1)
   
 Null deviance: 10272.4  on 8224  degrees of freedom Residual
deviance:  7185.8  on 8219  degrees of freedom
AIC: 7197.8
   
Number of Fisher Scoring iterations: 8
   
However, when I run anova on the fit, I get  
anova(HMMaturation.glmfit.Full, test='Chisq') Analysis of
  Deviance
Table
   
Model: binomial, link: logit
   
Response: Mature
   
Terms added sequentially (first to last)
   
   
Df Deviance Resid. Df Resid. Dev P(|Chi|)
NULL822410272.4
LT  1   2873.8  8223 7398.7   0.0
CondF   1  0.1  8222 7398.5   0.7
Biom1  0.2  8221 7398.3   0.7
LT:CondF1142.1  8220 7256.3 9.413e-33
LT:Biom 1 70.4  8219 7185.8 4.763e-17
Warning message:
fitted probabilities numerically 0 or 1 occurred in:
  method(x = x[,
varseq = i, drop = FALSE], y = object$y, weights =
object$prior.weights,
   
   
I am having a little difficulty interpreting these results.
The result from the fit tells me that all predictors are
significant, while the anova indicates that besides LT (the main
variable), only the interaction of the other terms is
  significant,
but the main effects are not.
I believe that in the first output (on the glm object), the
significance of all terms is calculated considering each of them
alone in the model (i.e.
removing all other terms), while the anova output is (as it says)
considering the sequential addition of the terms.
   
So, there are 2 questions:
a) Can I tell that the interactions are significant, but not the
main effects?
  
  In a model with this structure, the main effects represent slopes
  over the origin (i.e., where the other variables in the
  product terms
  are 0), and aren't meaningfully interpreted as main effects.
  (Is there
  even any data near the origin?)
  
b) Is it legitimate to consider a model where the
  interactions are
considered, but not the main effects CondF and Biom?
  
  Generally, no: That is, such a model 

Re: [R] IF/Else

2005-11-10 Thread Gabor Grothendieck
Try using switch:

bioden - Biomass /
  switch(paste(Gear),
`20` = 141,
`23` = 68,
# ... fill in the ones I have omitted ...,
`301` = DIST_TOW*4*1853)


On 11/10/05, Guenther, Cameron [EMAIL PROTECTED] wrote:
 Hi,
 I am trying to write a for loop with if else statements to calculate
 biomass density estimates for different types of sampling gear.
 My code is:

 bmd=for (i in 1:length(Gear)){
 if (Gear==20) {bioden=Biomass/141}
 else {if (Gear==23) {bioden=Biomass/68}}
 else {if (Gear==160) {bioden=Biomass/4120}}
 else {if (Gear==170) {bioden=Biomass/2210}}
 else {if (Gear==300) {bioden=Biomass/(DIST_TOW*4*1853)}}
 else {if (Gear==301) {bioden=Biomass/(DIST_TOW*4*1853)}}
 }

 The syntax that is returned is:

  bmd=for (i in 1:length(Gear)){
 + if (Gear==20) {bioden=Biomass/141}
 + else {if (Gear==23) {bioden=Biomass/68}}
 + else {if (Gear==160) {bioden=Biomass/4120}}
 Error: syntax error in:
 else {if (Gear==23) {bioden=Biomass/68}}
 else
  else {if (Gear==170) {bioden=Biomass/2210}}
 Error: syntax error in else
  else {if (Gear==300) {bioden=Biomass/(DIST_TOW*4*1853)}}
 Error: syntax error in else
  else {if (Gear==301) {bioden=Biomass/(DIST_TOW*4*1853)}}
 Error: syntax error in else
  }
 Error: syntax error in }

 It appears that the code works for the first two if/else statements and
 then fails there after.  Any suggestions?

 Cameron Guenther
 Associate Research Scientist
 FWC/FWRI, Marine Fisheries Research
 100 8th Avenue S.E.
 St. Petersburg, FL 33701
 (727)896-8626 Ext. 4305
 [EMAIL PROTECTED]

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


__
R-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 export multiple files using write.table in the loop?

2005-11-10 Thread Gabor Grothendieck
Try this:

col.list - list(1:3, c(1,4:5))
for(cols in col.list) write.table(data1[,cols], ...whatever...)


On 11/10/05, alice.0309 [EMAIL PROTECTED] wrote:
 Hi,

 I tried to split a big file into some small files seperately by R.  I can 
 only do that writing duplicated codes.  When I tried to write a loop, I only 
 got one appned or destroyed exported file.   For example:

 data1- read.table(file = C:\\Alice\\MBEI.txt, sep=\t, check.names=FALSE)
 a-subset(data1,select=c(V1,V2,V3))
 write.table-(a,file=C:\\Alice\\aa1.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
 a-subset(data1,select=c(V1,V4,V5))
 write.table(a,file=C:\\Alice\\aa2.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)

 or
 data1- read.table(file = C:\\Alice\\MBEI.txt, sep=\t, check.names=FALSE)
 a-data.frame(data1[,1],data1[,2],data1[,3]
 write.table-(a,file=C:\\Alice\\aa1.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
 a-data.frame(data1[,1],data1[,4],data1[,5]
 write.table(a,file=C:\\Alice\\aa2.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)

 I tried to write a loop for it like :


 i - 1
 while (i 3)
 {
 qq-data.frame(test[,1],test[,2[i],test[,2[i]+1])
 write.table(qq,file=C:\\Alice\\bb.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
 i - i+1;
 }

 But it's not right.  I tried hard to revise it but I just can't make it.  If 
 someone can help me out here, your help is really greatly appreciated.  Thank 
 you sooo much!

 Best,

 Alice





 -

[[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] following Appendix A results in plot.new has not been called yet

2005-11-10 Thread durbano

Hello. I was exploring the R software package and received the error
message plot.new has not been called yet when following Appendix A A
Sample Session of R-intro.pdf.  I searched the message archives and
found no similiar report to mine.

I am using R on CentOS and I am using the latest from R-project, version
2.2.0.

Here is my .Rhistory file recorded when following the appendix after the
first removal of variables (e.g. rm(x,y) ):

x - 1:20
w - 1 + sqrt(x)/2
dummy - data.frame(x=x, y=x + rnorm(x)*w)
dummy
fm - lm(y ~ x, data=dummy)
summary(fm)
fm1 - lm(y ~ x, data=dummy, weight=1/w^2)
summary(fm1)
attach(dummy)
lrf - lowess(x,y)
plot(x,y)
lines(x, lrf$y)

Results in:

Error in plot.xy(xy.coords(x, y), type = type, col = col, lty = lty,
...) :
plot.new has not been called yet

If I continue along with the list of commands, I yield similiar errors.

I am unsure if this is related to using CentOS, my installation, bad
steps in the pdf file, or a bug in the software.  I am leaning towards
the steps in the pdf.

Regards,

Daniel

__
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] following Appendix A results in plot.new has not been called yet

2005-11-10 Thread Gabor Grothendieck
You left out

y - rnorm(x)



On 11/10/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 Hello. I was exploring the R software package and received the error
 message plot.new has not been called yet when following Appendix A A
 Sample Session of R-intro.pdf.  I searched the message archives and
 found no similiar report to mine.

 I am using R on CentOS and I am using the latest from R-project, version
 2.2.0.

 Here is my .Rhistory file recorded when following the appendix after the
 first removal of variables (e.g. rm(x,y) ):

 x - 1:20
 w - 1 + sqrt(x)/2
 dummy - data.frame(x=x, y=x + rnorm(x)*w)
 dummy
 fm - lm(y ~ x, data=dummy)
 summary(fm)
 fm1 - lm(y ~ x, data=dummy, weight=1/w^2)
 summary(fm1)
 attach(dummy)
 lrf - lowess(x,y)
 plot(x,y)
 lines(x, lrf$y)

 Results in:

 Error in plot.xy(xy.coords(x, y), type = type, col = col, lty = lty,
 ...) :
plot.new has not been called yet

 If I continue along with the list of commands, I yield similiar errors.

 I am unsure if this is related to using CentOS, my installation, bad
 steps in the pdf file, or a bug in the software.  I am leaning towards
 the steps in the pdf.

 Regards,

 Daniel

 __
 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] Help regarding mas5 normalization

2005-11-10 Thread Adaikalavan Ramasamy
Please do not post to both BioConductor and R.



On Thu, 2005-11-10 at 09:51 -0700, Nayeem Quayum wrote:
 Hello everybody,
 I am trying to use mas5 to normalize some array data and using mas5 and
 mas5calls. But I received these warning message. If anybody can explain the
 problem I would really appreciate that. Thanks in advance.
 background correction: mas
 PM/MM correction : mas
 expression values: mas
 background correcting...Warning message:
 'loadURL' is deprecated.
 Use 'load(url())' instead.
 See help(Deprecated)
 Warning message:
 'loadURL' is deprecated.
 Use 'load(url())' instead.
 See help(Deprecated)
 Warning message:
 'loadURL' is deprecated.
 Use 'load(url())' instead.
 See help(Deprecated)
 There were 14 warnings (use warnings() to see them)
 Note: http://www.bioconductor.org/repository/devel/package/Win32 does not
 seem to have a valid repository, skipping
 Note: You did not specify a download type. Using a default value of: Source
 This will be fine for almost all users
 
 Error in FUN(X[[1]], ...) : no slot of name Uses for this object of class
 localPkg
 
   [[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] How to export multiple files using write.table in the loop?

2005-11-10 Thread alice.0309
Hi Gabor,
 
Thank you very very much for your help!  I'm still a little confused.  Let me 
re-state my problems here:
 
There are 29 columns in my large dataset(with 5 rows)
I need to split out 14 different files like this:
Col1, Col2, Col3--split1.txt
Col1, Col4, Col5--split2.txt
.
.
Col1, Col28,Col29-split14.txt
 
How can I do that using some functions or loop statement?
 
Sincerely,
 
Alice

Gabor Grothendieck [EMAIL PROTECTED] wrote:
Try this:

col.list - list(1:3, c(1,4:5))
for(cols in col.list) write.table(data1[,cols], ...whatever...)


On 11/10/05, alice.0309 wrote:
 Hi,

 I tried to split a big file into some small files seperately by R. I can only 
 do that writing duplicated codes. When I tried to write a loop, I only got 
 one appned or destroyed exported file. For example:

 data1- read.table(file = C:\\Alice\\MBEI.txt, sep=\t, check.names=FALSE)
 a-subset(data1,select=c(V1,V2,V3))
 write.table-(a,file=C:\\Alice\\aa1.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
 a-subset(data1,select=c(V1,V4,V5))
 write.table(a,file=C:\\Alice\\aa2.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)

 or
 data1- read.table(file = C:\\Alice\\MBEI.txt, sep=\t, check.names=FALSE)
 a-data.frame(data1[,1],data1[,2],data1[,3]
 write.table-(a,file=C:\\Alice\\aa1.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
 a-data.frame(data1[,1],data1[,4],data1[,5]
 write.table(a,file=C:\\Alice\\aa2.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)

 I tried to write a loop for it like :


 i - 1
 while (i 3)
 {
 qq-data.frame(test[,1],test[,2[i],test[,2[i]+1])
 write.table(qq,file=C:\\Alice\\bb.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
 i - i+1;
 }

 But it's not right. I tried hard to revise it but I just can't make it. If 
 someone can help me out here, your help is really greatly appreciated. Thank 
 you sooo much!

 Best,

 Alice





 -

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



-

[[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 export multiple files using write.table in the loop?

2005-11-10 Thread alice.0309
Hello!
 
I've solved the problems so don't bother.  I can use Paste function like this:
i - 1
while (i 15)
{
s-data.frame(data1[,1],data1[,(2*i)],data1[,(2*i+1)])
write.table(s,paste(F:\\s.txt,i,sep=.),quote=FALSE,row.names=FALSE,col.names=FALSE)
i - i+1;
}
 
Thank you very much and sorry for multiple e-mails!

Gabor Grothendieck [EMAIL PROTECTED] wrote:
Try this:

col.list - list(1:3, c(1,4:5))
for(cols in col.list) write.table(data1[,cols], ...whatever...)


On 11/10/05, alice.0309 wrote:
 Hi,

 I tried to split a big file into some small files seperately by R. I can only 
 do that writing duplicated codes. When I tried to write a loop, I only got 
 one appned or destroyed exported file. For example:

 data1- read.table(file = C:\\Alice\\MBEI.txt, sep=\t, check.names=FALSE)
 a-subset(data1,select=c(V1,V2,V3))
 write.table-(a,file=C:\\Alice\\aa1.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
 a-subset(data1,select=c(V1,V4,V5))
 write.table(a,file=C:\\Alice\\aa2.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)

 or
 data1- read.table(file = C:\\Alice\\MBEI.txt, sep=\t, check.names=FALSE)
 a-data.frame(data1[,1],data1[,2],data1[,3]
 write.table-(a,file=C:\\Alice\\aa1.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
 a-data.frame(data1[,1],data1[,4],data1[,5]
 write.table(a,file=C:\\Alice\\aa2.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)

 I tried to write a loop for it like :


 i - 1
 while (i 3)
 {
 qq-data.frame(test[,1],test[,2[i],test[,2[i]+1])
 write.table(qq,file=C:\\Alice\\bb.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
 i - i+1;
 }

 But it's not right. I tried hard to revise it but I just can't make it. If 
 someone can help me out here, your help is really greatly appreciated. Thank 
 you sooo much!

 Best,

 Alice





 -

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



-

[[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 export multiple files using write.table in the loop?

2005-11-10 Thread Gabor Grothendieck
In that case you can simplify it a bit like this:

fn - /s.txt
for(i in 1:14)
  write.table(data1[, c(1, 2*i, 2*i+1)], paste(fn, i, sep = .),
   quote = FALSE, row.names = FALSE, col.names = FALSE)


On 11/10/05, alice.0309 [EMAIL PROTECTED] wrote:
 Hello!

 I've solved the problems so don't bother.  I can use Paste function like
 this:
 i - 1
 while (i 15)
 {
 s-data.frame(data1[,1],data1[,(2*i)],data1[,(2*i+1)])
 write.table(s,paste(F:\\s.txt,i,sep=.),quote=FALSE,row.names=FALSE,col.names=FALSE)
 i - i+1;
 }

 Thank you very much and sorry for multiple e-mails!

 Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Try this:

 col.list - list(1:3, c(1,4:5))
 for(cols in col.list) write.table(data1[,cols], ...whatever...)


 On 11/10/05, alice.0309 wrote:
  Hi,
 
  I tried to split a big file into some small files seperately by R. I can
 only do that writing duplicated codes. When I tried to write a loop, I only
 got one appned or destroyed exported file. For example:
 
  data1- read.table(file = C:\\Alice\\MBEI.txt, sep=\t,
 check.names=FALSE)
  a-subset(data1,select=c(V1,V2,V3))
 
 write.table-(a,file=C:\\Alice\\aa1.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
  a-subset(data1,select=c(V1,V4,V5))
 
 write.table(a,file=C:\\Alice\\aa2.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
 
  or
  data1- read.table(file = C:\\Alice\\MBEI.txt, sep=\t,
 check.names=FALSE)
  a-data.frame(data1[,1],data1[,2],data1[,3]
 
 write.table-(a,file=C:\\Alice\\aa1.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
  a-data.frame(data1[,1],data1[,4],data1[,5]
 
 write.table(a,file=C:\\Alice\\aa2.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
 
  I tried to write a loop for it like :
 
 
  i - 1
  while (i 3)
  {
  qq-data.frame(test[,1],test[,2[i],test[,2[i]+1])
 
 write.table(qq,file=C:\\Alice\\bb.txt,quote=FALSE,row.names=FALSE,col.name=FALSE,sep=\t)
  i - i+1;
  }
 
  But it's not right. I tried hard to revise it but I just can't make it. If
 someone can help me out here, your help is really greatly appreciated. Thank
 you sooo much!
 
  Best,
 
  Alice
 
 
 
 
 
  -
 
  [[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
 


 
 Yahoo! FareChase - Search multiple travel sites in one click.



__
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] undefined symbol in grDevices.so

2005-11-10 Thread Juan Pablo Romero
Hello

I'm trying to use rpy with latest R (2.2.0), but unfortunately it
seems there is some kind of undefined symbol in grDevices.so
(utf8locale)

Within python, this message appears:

 import rpy
Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library
'/usr/local/lib/R/library/grDevices/libs/grDevices.so':
  /usr/local/lib/R/library/grDevices/libs/grDevices.so: undefined
symbol: utf8locale
Loading required package: grDevices
Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library
'/usr/local/lib/R/library/grDevices/libs/grDevices.so':
  /usr/local/lib/R/library/grDevices/libs/grDevices.so: undefined
symbol: utf8locale
In addition: Warning message:
package grDevices in options(defaultPackages) was not found
Error: package 'grDevices' could not be loaded

Any suggestions?

Thanks in advance.

  Juan Pablo

__
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] strange classification behaviour

2005-11-10 Thread Gabor Grothendieck
You could use cut.  The key calculation would be:

   w - .05; eps - 1e-5
   breakpoints - seq(min(kk), max(kk), .05)
   breakpoints - floor( (breakpoints + (w/2) + eps) / w) * w
   values - cut(kk, c(breakpoints, Inf), right = FALSE)
   values - ordered(values)

If you don't like the labels produced add lab = breakpoints as a cut arg.

On 11/10/05, RenE J.V. Bertin [EMAIL PROTECTED] wrote:
 Hello,

 I've written a routine that takes an input vector and returns a 'binned' 
 version with a requested bin width and converted to an ordered factor by 
 default. It also attempts to make sure that all factor levels intermediate to 
 the input range are present.

 This is the code as I currently have it:

 Classify - function( values, ClassWidth=0.05, ordered.factor=TRUE, all=TRUE )
 {
 valuesName - deparse(substitute(values))
 if( is.numeric(values) ){
  values - floor( (values+ (ClassWidth/2) ) / ClassWidth ) * 
 ClassWidth
  # determine the numerical range of the input
  levels - range( values, finite=TRUE )
  if( ordered.factor ){
   if( all ){
# if we want all levels, construct a levels vector that 
 can be passed to factor's levels argument:
levels - seq( levels[1], levels[2], by=ClassWidth )
values - factor(values, levels=levels, ordered=TRUE )
   }
   else{
values - factor(values, ordered=TRUE )
   }
  }
 }
 else{
  levels - range( values, finite=TRUE )
  if( all ){
   levels - seq( levels[1], levels[2], by=ClassWidth )
   values - factor( values, levels=levels, ordered=ordered.factor 
 )
  }
  else{
   values - factor( values, ordered=ordered.factor )
  }
 }
 comment(values) - paste( comment(values),
  ; Classify(, valuesName, , ClassWidth=, ClassWidth, , 
 ordered.factor=, ordered.factor, ),
  sep=)
 values
 }

 This does work, but has some strange side-effects that I think might be due 
 to rounding errors:

 ## kk-c(  0.854189  0.374423  0.522893  0.670796  0.913540  0.979011  
 0.510378  0.320440 -0.576764  0.940343 )

 ## Classify( kk, ClassWidth=0.05, all=FALSE )
  [1] 0.85 0.35 0.5  0.65 0.9  10.5  0.3  -0.6 0.95
 Levels: -0.6  0.3  0.35  0.5  0.65  0.85  0.9  0.95  1
 ### result as expected, but using this on the hor. axis of a graph can be ... 
 surprising.

 ## Classify( kk, ClassWidth=0.05, all=TRUE )
  [1] 0.85 NA 0.5  NA NA 10.5  NA -0.6 NA
 33 Levels: -0.6  -0.55  -0.5  -0.45  -0.4  -0.35  -0.3  -0.25  -0.2  
 -0.15  -0.1  -0.05  0  ...  1
 ## summary( Classify( kk, ClassWidth=0.05, all=TRUE ) )
  -0.6  -0.55   -0.5  -0.45
-0.4  -0.35
 1  0  0  0
   0  0
  -0.3  -0.25   -0.2  -0.15
-0.1  -0.05
 0  0  0  0
   0  0
 0 0.04990.1   0.15
 0.2   0.25
 0  0  0  0
   0  0
   0.3   0.350.4   0.45
 0.5   0.55
 0  0  0  0
   2  0
   0.6   0.650.7   0.75
 0.8   0.85
 0  0  0  0
   0  1
   0.9   0.95  1   NA's
 0  0  1  5

 ### ???

 What happens is probably that the value in my input that classify to 0.3 or 
 0.35 are not found in the list of levels that I calculate due to rounding 
 errors. Adding an element 0.05 to kk supports this idea.

 Is there a way around this, for instance a more robust way to do what I'm 
 trying to do here (or a function provided by R)?

 When I modify the relevant code above to

levels - floor( (seq( levels[1], levels[2], by=ClassWidth 
 ) + (ClassWidth/2)) / ClassWidth ) * ClassWidth
values - factor( values, levels=levels, ordered=TRUE )

 the result is as expected, but I find that not very elegant...

 Thanks in advance,
 RenE Bertin

 __
 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 on Windows XP x64

2005-11-10 Thread Feng Tai
Hi,

I am running R 2.2.0 on the Windows XP x64. The mechanism of error hanlder
seems different. It will take a very long time to pop up a error message
diaglog box, even when some simple errors happen such as Syntax error or
object  not found. Does anybody have the similar experience? Thanks
a lot.

BTW: everything works fine under 32-bit Windows XP, error messages come
out immediately.

Feng

__
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] error in rowSums:'x' must be numeric

2005-11-10 Thread Jari Oksanen
On Thu, 2005-11-10 at 16:49 +0100, Illyes Eszter wrote:
 Dear All, 
 
 It's Eszter again from Hungary. I could not solve my problem form 
 yesterday, so I still have to ask your help.
 
 I have a binary dataset of vegetation samples and species as a comma 
 separated file. I would like to calculate the Jaccard distance of the 
 dataset. I have the following error message: 
 
 Error in rowSums(x, prod(dn), p, na.rm) : 'x' must be numeric
 In addition: Warning message:
 results may be meaningless because input data have negative entries
  in: vegdist(t2, method = jaccard, binary = FALSE, diag = FALSE,  
 
 Do you have any idea what can be the problem? I have only 0 and 1 in 
 the dataset. 
 
Eszter, 

An old truth is that if The Computer is always right and you are wrong
when The Computer says that you have non-numeric data. Check your data
first. An obvious way of checking this is to repeat the command that
found the problem: rowSums(t2). After that (probably) reports the same
error, you can check your data sayin, e.g., str(t2) which displays you
the variables in a very compact form.

Now some wild speculation. When you read your data as comma separated
file, very often the column names are taken as the first variable. Check
this and remove the first column if needed. This is so common that I've
even thought that I perhaps need to write a sanitizing function for cvs
files to do the following:

   rownames(x) - x[,1]
   x - x[,-1]

or to take the first column as rownames and then remove the non-numeric
first column.

A pertinent problem in R communication with cvs files is that R assumes
that with header=TRUE the header line has one entry less than data rows.
However, popular software (read Excel) refuses to write data so: even if
you make the first column empty in your header line, the popular
software adds a comma before the first intended entry, and so you have
the same number of entries in the header line and in the data. The
result is that the column that intended as rownames is taken as a
non-numeric variable. 

This is such a common problem that an innocent user (not me: I'm no more
innocent) would expect R cope with that kind of input format.

cheers, jari oksanen
-- 
Jari Oksanen -- Dept Biology, Univ Oulu, 90014 Oulu, Finland
email [EMAIL PROTECTED], homepage http://cc.oulu.fi/~jarioksa/

__
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