[R] difference between lrm's Model L.R. and anova's Chi-Square

2008-03-02 Thread johnson4
I am running lrm() with a single factor. I then run anova() on the fitted
model to obtain a p-value associated with having that factor in the model.

I am noticing that the Model L.R. in the lrm results is almost the same
as the Chi-Square in the anova results, but not quite; the latter value
is always slightly smaller.

anova() calculates the p-value based on Chi-Square, but I have
independent evidence that Model L.R. is the actual -2*log(LR), so should
I be using that?

Why are the values different?

prob_a - inv.logit(rnorm(1,0,1))
prob_b - inv.logit(rnorm(1,0,1))
data - data.frame(
factor=c(rep(a,500),rep(b,500)),
outcome=c(sample(c(1,0),100,replace=T,prob=c(prob_a,1-prob_a)),
  sample(c(1,0),100,replace=T,prob=c(prob_b,1-prob_b
fit - lrm(outcome~factor,data)

fit   # gives Model L.R. e.g. 8.23, 11.76, 6.89...
anova(fit)# gives Chi-Square e.g. 8.19, 11.69, 6.85...

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] difference between lrm's Model L.R. and anova's Chi-Square

2008-03-02 Thread johnson4
Quoting Frank E Harrell Jr [EMAIL PROTECTED]:
 anova (anova.Design) computes Wald statistics.  When the log-likelihood
 is very quadratic, these statistics will be very close to log-likelihood
 ratio chi-square statistics.  In general LR chi-square tests are better;
 we use Wald tests for speed.  It's best to take the time and do
 lrtest(fit1,fit2) in Design, where one of the two fits is a subset of
 the other.

 Frank Harrell

Thanks, this is great, but in my case, there's just one factor,

fit1 - lrm(outcome~factor,data)

and I'm having trouble constructing the subset 'null model', as e.g.

fit2 - lrm(outcome~1,data)

returns an error message.

How do I construct a null model with lrm() so that I can use lrtest() to test a
model with only one predictor?

I apologize for asking what must be a very simple question but I have been
unable to find the answer by searching R-help.

Thanks,
Dan

P.S. Second point: I have another case where I use lmer(), and there the null
model includes a random effect so I don't get the problem above. It looks like
with lmer objects anova() uses LLR, not Wald. Is that right?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Poisson regression in R

2008-03-02 Thread Peter Dalgaard
glmstat wrote:
 I have these questions:
 (1) Use Poisson regression to estimate the main effects of car, age, and
 dist (each treated as categorical and modelled using indicator variables)
 and interaction terms.  
 (2) It was determined by one study that all the interactions were
 unimportant and decided that age and car could be treated as though they
 were continuous variables. Fit a model incorporating these features and
 compare it with the best model obtained in (1). 

   
This looks like homework, so only hints are offered.

You don't seem to be using n, consider incorporating an offset (I would 
expect most texts on Poison regr. to discuss this).

 n is the number of insurance policies
 y is the number of claims
 car is the car in an insurance category
 age is the age of policy holder
 dist is the district where the policy holder lived (1 for London and other
 major cities, and 0 otherwise)

 Data:

 car   age disty   n
 1 1   0   65  317
 1 2   0   65  476
 1 3   0   52  486
 1 4   0   310 3259
 2 1   0   98  486
 2 2   0   159 1004
 2 3   0   175 1355
 2 4   0   877 7660
 3 1   0   41  223
 3 2   0   117 539
 3 3   0   137 697
 3 4   0   477 3442
 4 1   0   11  40
 4 2   0   35  148
 4 3   0   39  214
 4 4   0   167 1019
 1 1   1   2   20
 1 2   1   5   33
 1 3   1   4   40
 1 4   1   36  316
 2 1   1   7   31
 2 2   1   10  81
 2 3   1   22  122
 2 4   1   102 724
 3 1   1   5   18
 3 2   1   7   39
 3 3   1   16  68
 3 4   1   63  344
 4 1   1   0   3
 4 2   1   6   16
 4 3   1   8   25
 4 4   1   33  114


 
 I need help finding the correct R code to construct models. According to the
 previous study, the model in (2) is simpler than (1), fits well (deviance =
 53.11, d.f. = 60, p-value = 0.72) and gives coefficients (standard errors):
 AGE, – 0.177 (0.018); CAR, 0.198 (0.021); DIST, 0.210 (0.059). 

 As of the first model, I think that I should use this code, but not sure:

   
 firstmodel-glm(y~factor(age)*factor(car)*factor(dist),family=poisson)
 

 As of the second model, I used this code, but it produces results that
 contradict what the previous study says (and deleting intercept does not
 help):

   
 secondmodel-glm(y~age+car+factor(dist),family=poisson)
 summary(secondmodel)
 
 Call:
 glm(formula = y ~ age + car + factor(dist), family = poisson)

 Deviance Residuals: 
  Min1QMedian3Q   Max  
 -14.0258   -3.3200   -0.62962.0575   18.1442  

 Coefficients:
   Estimate Std. Error z value Pr(|z|)
 (Intercept)3.082220.08127   37.92   2e-16 ***
 age0.836640.02067   40.48   2e-16 ***
 car   -0.167230.01612  -10.37   2e-16 ***
 factor(dist)1 -2.159370.05849  -36.92   2e-16 ***
 ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

 (Dispersion parameter for poisson family taken to be 1)

 Null deviance: 5660.6  on 31  degrees of freedom
 Residual deviance: 1154.5  on 28  degrees of freedom
 AIC: 1330.8

 Number of Fisher Scoring iterations: 5
   


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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Could not install aroma.affymetrix

2008-03-02 Thread Henrik Bengtsson
Hi My,

On Sat, Mar 1, 2008 at 8:04 PM, My Coyne [EMAIL PROTECTED] wrote:
 I don't know if this is the correct forum to ask the following question;
  however, when I search the aroma.affymetrix discussion group, it suggested
  that I should posted the question to r-help.  Here it goes.

I think you have misinterpreted some message(s), because I don't know
of any place where we suggest that you should ask r-help list about
installation problems on aroma.affymetrix.  Let me know if I am wrong
so the documentation can be corrected.




  I followed the instructions on aroma.affymetrix trying to install the
  packages; following are the steps:



   install.packages(c(R.oo, R.utils),
  contriburl=http://www.braju.com/R/repos/;)

That explains how to install the R.oo and R.utils packages, but it is
certainly not the suggested way to install aroma.affymetrix.  *Please*
let me know where you got this from.

See the Page 'Installation, Updates  Patches' on the aroma.affymetrix
website (http://www.braju.com/R/aroma.affymetrix/) for installation
instructions.

/Henrik


  trying URL 'http://www.braju.com/R/repos//R.oo_1.4.1.zip'

  Content type 'application/zip' length 889981 bytes (869 Kb)

  opened URL

  downloaded 869 Kb



  trying URL 'http://www.braju.com/R/repos//R.utils_1.0.0.zip'

  Content type 'application/zip' length 893989 bytes (873 Kb)

  opened URL

  downloaded 873 Kb



  package 'R.oo' successfully unpacked and MD5 sums checked

  package 'R.utils' successfully unpacked and MD5 sums checked



  The downloaded packages are in

 C:\Documents and Settings\mcoyne\Local
  Settings\Temp\Rtmpjhahhp\downloaded_packages

  updating HTML package descriptions





  However, when I tried to load the package aroma.affymetrix I got the
  following error:



library (aroma.affymetrix)

  Error in library(aroma.affymetrix) :

   there is no package called 'aroma.affymetrix'



  Any help is greatly appreciated.



  My D. Coyne










 [[alternative HTML version deleted]]

  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Newbie: Incorrect number of dimensions

2008-03-02 Thread Keizer_71

Here is the structure

 str(all_differ)
 num [1:6280, 1:8] 2.22e-16 2.22e-16 2.22e-16 2.22e-16 2.22e-16 ...
 - attr(*, dimnames)=List of 2
  ..$ : NULL
  ..$ : chr [1:8] rawp Bonferroni Holm Hochberg ...

I tried, but it still giving me the same error message Incorrect Dimension

probe.names-all_differ[[1]][all_differ[[6280]][,BY]=0.01]

Am i using the wrong dimension?

thanks,
Keizer



jholtman wrote:
 
 It would be helpful if you provided commented, minimal,
 self-contained, reproducible code.
 
 What does str(all_differ) say?  That will tell you the structure of
 the object that you are trying to work with.
 
 On Sat, Mar 1, 2008 at 3:35 AM, Keizer_71 [EMAIL PROTECTED] wrote:

  dim(data.sub)
 [1] 1   140

 #extracting all differentially express genes##
 library(multtest)
 two_side- (1-pt(abs(data.sub),50))*2
 diff- mt.rawp2adjp(two_side)
 all_differ-diff[[1]][37211:1,]
 all_differ

 #list of differentially expressed genes##
  probe.names-
 + all_differ[[2]][all_differ[[1]][,BY]=0.01]

 Error in all_differ[[1]][, BY] : incorrect number of dimensions

 Hi,

 I am pretty new with R. What i am trying to do is to find all
 differentially
 express genes and list of differentially expressed genes. Am i doing
 something wrong?

 I keep getting incorrect number of dimensions. How do i find out the
 correct
 dimensions?

 thanks,
 Keizer

 --
 View this message in context:
 http://www.nabble.com/Newbie%3A-Incorrect-number-of-dimensions-tp15773090p15773090.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

 
 
 
 -- 
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390
 
 What is the problem you are trying to solve?  Tell me what you want to
 do, not how you want to do it.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Newbie%3A-Incorrect-number-of-dimensions-tp15773090p15785977.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Newbie: Incorrect number of dimensions

2008-03-02 Thread Henrique Dallazuanna
You have a 'matrix' not a 'list', so
I think you want something like this:

all_differ[all_differ[, 'BY'] = 0.01, 'BY'], this will return the
values where column is 'BY' in all rows which is less or equal to
0.01.


On 02/03/2008, Keizer_71 [EMAIL PROTECTED] wrote:

 Here is the structure

  str(all_differ)
  num [1:6280, 1:8] 2.22e-16 2.22e-16 2.22e-16 2.22e-16 2.22e-16 ...
  - attr(*, dimnames)=List of 2
   ..$ : NULL
   ..$ : chr [1:8] rawp Bonferroni Holm Hochberg ...

 I tried, but it still giving me the same error message Incorrect Dimension

 probe.names-all_differ[[1]][all_differ[[6280]][,BY]=0.01]

 Am i using the wrong dimension?

 thanks,
 Keizer



 jholtman wrote:
 
  It would be helpful if you provided commented, minimal,
  self-contained, reproducible code.
 
  What does str(all_differ) say?  That will tell you the structure of
  the object that you are trying to work with.
 
  On Sat, Mar 1, 2008 at 3:35 AM, Keizer_71 [EMAIL PROTECTED] wrote:
 
   dim(data.sub)
  [1] 1   140
 
  #extracting all differentially express genes##
  library(multtest)
  two_side- (1-pt(abs(data.sub),50))*2
  diff- mt.rawp2adjp(two_side)
  all_differ-diff[[1]][37211:1,]
  all_differ
 
  #list of differentially expressed genes##
   probe.names-
  + all_differ[[2]][all_differ[[1]][,BY]=0.01]
 
  Error in all_differ[[1]][, BY] : incorrect number of dimensions
 
  Hi,
 
  I am pretty new with R. What i am trying to do is to find all
  differentially
  express genes and list of differentially expressed genes. Am i doing
  something wrong?
 
  I keep getting incorrect number of dimensions. How do i find out the
  correct
  dimensions?
 
  thanks,
  Keizer
 
  --
  View this message in context:
 
 http://www.nabble.com/Newbie%3A-Incorrect-number-of-dimensions-tp15773090p15773090.html
  Sent from the R help mailing list archive at Nabble.com.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
  --
  Jim Holtman
  Cincinnati, OH
  +1 513 646 9390
 
  What is the problem you are trying to solve?  Tell me what you want to
  do, not how you want to do it.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 

 --
 View this message in context:
 http://www.nabble.com/Newbie%3A-Incorrect-number-of-dimensions-tp15773090p15785977.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] jpeg and margin text

2008-03-02 Thread Jim Lemon
Thomas Schwander wrote:
 Hi guys,
 
  
 
 I use R 2.6.2 and Windows XP.
 
  
 
 I’ve got the following question: I wrote a lot of text into the margin of a
 plot. When I use the “jpeg”-function, only a little part of the margin text
 is displayed in the final jpeg? Any ideas to change it?
 
  
 
 Source-Code:
 
  
 
 datenbankdaten-data.frame(LETTERS[1:20],
 
 c(8,4.8,3.8,2.7,2.6,2.1,2,1.9,1.6,1,0.99,0.98,0.98,0.97,0.96,.96,0.8,0.8,0.7
 ,0.6),
 
 c(8,4.8,3.8,0,2.6,2.1,2,1.9,1.6,1.1,0.99,0.98,0.97,0.97,0.96,.95,0.8,0.8,0,0
 .6))
 
  
 
 Zugehoerigkeit-LETTERS[1:20]
 
  
 
 Bezeichnung-letters[1:20]
 
  
 
 colnames(datenbankdaten)-c(Bezeichnung,A,B)
 
  
 
 # par = Setzt die Grafikparameter, die durch plot automatisch verwendet
 werden 
 
 # mar = Anzahl der Textzeilen von den inneren Achsen des Schaubild zum Rand
 
 # Zeilenvektor: c(bottom, left, top, right)
 
 par(mar=c(3,4,4,25),family=serif)
 
  
 
 Fontparameter-1
 
  
 
 today-Sys.Date()
 
 Vormonat-Sys.Date()-20
 
  
 
 Stand_aktuell-format(today, %B %Y)
 
 Stand_Vormonat-format(Vormonat, %B %Y)
 
 jpeg(paste(C:\\TOP-20.jpeg,sep=),quality=100,width=1024, height=768)
 
  
 plot(datenbankdaten[,2],ylim=c(0,max(datenbankdaten[,2],datenbankdaten[,3]))
 ,
 
   xlab=, ylab=,
 
  
 font.axis=Fontparameter,font.lab=Fontparameter,font.main=Fontparameter,font.
 sub=Fontparameter,
 
   bty=n,axes=F)
 
   axis(1,at=1:20,label=rep(,20))
 
   axis(1,at=1:9,label=sprintf(0%.0f,1:9))
 
   axis(1,at=10:20,label=10:20)
 
   Maximum-max(datenbankdaten[,2],datenbankdaten[,3])
 
   axis(2,at=0:Maximum,label=sprintf(%.2f,0:Maximum))
 
   for(i in 1:(length(datenbankdaten[,2])+2)){
 
 abline(h=i-1)
 
   }
 
   for(i in 1:20){
 
 if(datenbankdaten[i,2]=datenbankdaten[i,3]) farbe=red else
 farbe=green
 
  
 arrows(i,datenbankdaten[i,2],i,datenbankdaten[i,3],col=farbe,length=0,lwd=1.
 5)
 
 points(i,datenbankdaten[i,2],pch=22,col=light blue,bg=light
 blue,cex=1.7)
 
  
 points(i,datenbankdaten[i,3],pch=21,col=grey,bg=grey,cex=1.5)
 
   }
 
   
 
   for(i in 1:20){
 
 if(datenbankdaten[i,2]datenbankdaten[i,3])
 
 #dreieck nach oben
 
  
 points(i,datenbankdaten[i,2]-0.1,pch=24,col=red,bg=red)
 
 if(datenbankdaten[i,2]datenbankdaten[i,3])
 
 #dreieck nach unten
 
  
 points(i,datenbankdaten[i,2]+0.1,pch=25,col=green,bg=green)
 
   }
 
   # Legend muss noch in die Ränder geschrieben werden, würde besser aussehen
 
  
 
 Verkleinern-0.8
 
  
 
 for(i in 1:20){
 
  
 
 if(i=9) text(par(usr)[2] + 0.5, Maximum-(i-1)*0.4, srt=0, adj = 0, labels
 = sprintf(0%.0f,i),xpd = TRUE,cex=Verkleinern)
 
 else text(par(usr)[2] + 0.5, Maximum-(i-1)*0.4, srt=0, adj = 0, labels =
 i,xpd = TRUE,cex=Verkleinern)
 
  
 
 text(par(usr)[2] + 1, Maximum-(i-1)*0.4, srt=0, adj = 0,
 labels = Zugehoerigkeit[i], 
 
 xpd = TRUE,cex=Verkleinern)
 
 text(par(usr)[2] + 3.6, Maximum-(i-1)*0.4, srt=0, adj = 0,
 labels = Bezeichnung[i], 
 
 xpd = TRUE,cex=Verkleinern)
 
 }
 
  
 
 lines(c(par(usr)[2] + 0.4,par(usr)[2] +
 0.4),c(Maximum+0.1,0.25),xpd=TRUE)
 
 lines(c(par(usr)[2] + 11.5,par(usr)[2] +
 11.5),c(Maximum+0.1,0.25),xpd=TRUE)
 
 lines(c(par(usr)[2] + 0.9,par(usr)[2] +
 0.9),c(Maximum+0.1,0.25),xpd=TRUE)
 
 lines(c(par(usr)[2] + 3.45,par(usr)[2] +
 3.45),c(Maximum+0.1,0.25),xpd=TRUE)
 
  
 
 Abstand-Maximum-0.15
 
  
 
 # aktueller Standpunkt
 
 for(i in 1:20){
 
 lines(c(par(usr)[2] + 0.4,par(usr)[2] +
 11.5),c(Maximum+0.1-Abstand*(i-1)/20,Maximum+0.1-Abstand*(i-1)/20),xpd=TRUE)
 
 }
 
 lines(c(par(usr)[2] + 0.4,par(usr)[2] + 11.5),c(0.25,0.25),xpd=TRUE)
 
  
 
 #Ende Test
 
  
 
 legend(topright,legend=c(Stand_aktuell,Stand_Vormonat),pch=c(22,21),
 
 bty=o,pt.bg=c(light blue,grey),cex=0.8,bg=white)
 
  
 
 dev.off()
 
Hi Thomas,
You seem to have a very wide table on the right of the plot, try this:

x11(width=10,height=7)
par(mar=c(5,4,4,20))
plot(...

Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] an efficient pairwise matrix cell's comparison function

2008-03-02 Thread jim holtman
Does this do what you want?

 A - matrix(sample(0:2, 25, TRUE), ncol=5)
 B - matrix(1:25, ncol=5)
 C - ifelse(A == 0, 0, B)
 A
 [,1] [,2] [,3] [,4] [,5]
[1,]11121
[2,]10110
[3,]00102
[4,]01200
[5,]12122
 B
 [,1] [,2] [,3] [,4] [,5]
[1,]16   11   16   21
[2,]27   12   17   22
[3,]38   13   18   23
[4,]49   14   19   24
[5,]5   10   15   20   25
 C
 [,1] [,2] [,3] [,4] [,5]
[1,]16   11   16   21
[2,]20   12   170
[3,]00   130   23
[4,]09   1400
[5,]5   10   15   20   25



On Sun, Mar 2, 2008 at 7:11 AM, Diogo André Alagador
[EMAIL PROTECTED] wrote:
 To all,



 I am undergoing an analysis involving big matrices of about 3x200 which
 I have to handle in a more efficient way. So I would like some advice to
 build such efficient function to deliver the following result:



 -  starting with 2 matrices of the same dimension (eg. A and B)



   0  0  3  5  6  0  0  5

 A=   0  0  6  4  B=   0  4  3  5

 0  0  5  0  1  0  0  9



 -  the function should deliver a C matrix (same dimension too),
 where at each position C(i,j), compares A and B.

  if A(i,j)=0, than C(i,j)=0,

  if A(i,j)!=0, than C(i,j)=B(i,j)



  6  0  0  5

 C= 0  0  3  5

  0  0  0  0



 Although not an expert I could build a function with 2 cycles (reading
 columns and rows) which is not quick. Maybe you can help me in this
 challenge.



 Much thanks in advance,




 Diogo André Alagador
 Biodiversity  Global Change Lab, Museo Nacional de Ciencias Naturales,
 CSIC, Madrid, España
 Forest Research Centre, Instituto Superior de Agronomia, Universidade
 Técnica de Lisboa, Lisboa, Portugal


[[alternative HTML version deleted]]


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.





-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] an efficient pairwise matrix cell's comparison function

2008-03-02 Thread Prof Brian Ripley

C - B
C[A==0] - 0

would be somewhat more efficient.

On Sun, 2 Mar 2008, jim holtman wrote:


Does this do what you want?


A - matrix(sample(0:2, 25, TRUE), ncol=5)
B - matrix(1:25, ncol=5)
C - ifelse(A == 0, 0, B)
A

[,1] [,2] [,3] [,4] [,5]
[1,]11121
[2,]10110
[3,]00102
[4,]01200
[5,]12122

B

[,1] [,2] [,3] [,4] [,5]
[1,]16   11   16   21
[2,]27   12   17   22
[3,]38   13   18   23
[4,]49   14   19   24
[5,]5   10   15   20   25

C

[,1] [,2] [,3] [,4] [,5]
[1,]16   11   16   21
[2,]20   12   170
[3,]00   130   23
[4,]09   1400
[5,]5   10   15   20   25





On Sun, Mar 2, 2008 at 7:11 AM, Diogo André Alagador
[EMAIL PROTECTED] wrote:

To all,



I am undergoing an analysis involving big matrices of about 3x200 which
I have to handle in a more efficient way. So I would like some advice to
build such efficient function to deliver the following result:



-  starting with 2 matrices of the same dimension (eg. A and B)



  0  0  3  5  6  0  0  5

A=   0  0  6  4  B=   0  4  3  5

0  0  5  0  1  0  0  9



-  the function should deliver a C matrix (same dimension too),
where at each position C(i,j), compares A and B.

 if A(i,j)=0, than C(i,j)=0,

 if A(i,j)!=0, than C(i,j)=B(i,j)



 6  0  0  5

C= 0  0  3  5

 0  0  0  0



Although not an expert I could build a function with 2 cycles (reading
columns and rows) which is not quick. Maybe you can help me in this
challenge.



Much thanks in advance,




Diogo André Alagador
Biodiversity  Global Change Lab, Museo Nacional de Ciencias Naturales,
CSIC, Madrid, España
Forest Research Centre, Instituto Superior de Agronomia, Universidade
Técnica de Lisboa, Lisboa, Portugal


   [[alternative HTML version deleted]]


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.






--
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] [OT] normal (as in Guassian)

2008-03-02 Thread Ted Harding
Hi Folks,
Apologies to anyone who'd prefer not to see this query
on this list; but I'm asking because it is probably the
forum where I'm most likely to get a good answer!

I'm interested in the provenance of the name normal
distribution (for what I'd really prefer to call the
Gaussian distribution).

According to Wikipedia, The name normal distribution
was coined independently by Charles S. Peirce, Francis
Galton and Wilhelm Lexis around 1875.

So be it, if that was the case -- but I would like to
know why they chose the name normal: what did they
intend to convey?

As background: I'm reflecting a bit on the usage in
statistics of everyday language as techincal terms,
as in significantly different. This, for instance,
is likely to be misunderstood by the general publidc
when they encounter statements in the media.

Likewise, normally distributed would probably be
interpreted as distributed in the way one would
normally expect or, perhaps, there was nothing
unusual about the distribution.

Comments welcome!
With thanks,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 02-Mar-08   Time: 13:04:17
-- XFMail --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Newbie: Incorrect number of dimensions

2008-03-02 Thread Christophe Lo
This is exactly what i am looking for.

many thanks
Chris


On 3/2/08, Henrique Dallazuanna [EMAIL PROTECTED] wrote:

 You have a 'matrix' not a 'list', so
 I think you want something like this:

 all_differ[all_differ[, 'BY'] = 0.01, 'BY'], this will return the
 values where column is 'BY' in all rows which is less or equal to
 0.01.


 On 02/03/2008, Keizer_71 [EMAIL PROTECTED] wrote:
 
  Here is the structure
 
   str(all_differ)
   num [1:6280, 1:8] 2.22e-16 2.22e-16 2.22e-16 2.22e-16 2.22e-16 ...
   - attr(*, dimnames)=List of 2
..$ : NULL
..$ : chr [1:8] rawp Bonferroni Holm Hochberg ...
 
  I tried, but it still giving me the same error message Incorrect
 Dimension
 
  probe.names-all_differ[[1]][all_differ[[6280]][,BY]=0.01]
 
  Am i using the wrong dimension?
 
  thanks,
  Keizer
 
 
 
  jholtman wrote:
  
   It would be helpful if you provided commented, minimal,
   self-contained, reproducible code.
  
   What does str(all_differ) say?  That will tell you the structure of
   the object that you are trying to work with.
  
   On Sat, Mar 1, 2008 at 3:35 AM, Keizer_71 [EMAIL PROTECTED]
 wrote:
  
dim(data.sub)
   [1] 1   140
  
   #extracting all differentially express genes##
   library(multtest)
   two_side- (1-pt(abs(data.sub),50))*2
   diff- mt.rawp2adjp(two_side)
   all_differ-diff[[1]][37211:1,]
   all_differ
  
   #list of differentially expressed genes##
probe.names-
   + all_differ[[2]][all_differ[[1]][,BY]=0.01]
  
   Error in all_differ[[1]][, BY] : incorrect number of dimensions
  
   Hi,
  
   I am pretty new with R. What i am trying to do is to find all
   differentially
   express genes and list of differentially expressed genes. Am i doing
   something wrong?
  
   I keep getting incorrect number of dimensions. How do i find out the
   correct
   dimensions?
  
   thanks,
   Keizer
  
   --
   View this message in context:
  
 
 http://www.nabble.com/Newbie%3A-Incorrect-number-of-dimensions-tp15773090p15773090.html
   Sent from the R help mailing list archive at Nabble.com.
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
  
  
  
   --
   Jim Holtman
   Cincinnati, OH
   +1 513 646 9390
  
   What is the problem you are trying to solve?  Tell me what you want to
   do, not how you want to do it.
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
  
 
  --
  View this message in context:
 
 http://www.nabble.com/Newbie%3A-Incorrect-number-of-dimensions-tp15773090p15785977.html
  Sent from the R help mailing list archive at Nabble.com.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


 --
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O




-- 
Christophe Lo
(078) 8275 7029
[EMAIL PROTECTED]

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] question on lag.zoo

2008-03-02 Thread Bo Zhou

Hi Guys,

I'm using zoo package now.  I found lag is not doing what I assumed.

 x - zoo(11:21)
 z - zoo(1:10, yearqtr(seq(1959.25, 1961.5, by = 0.25)), frequency = 4)
 x
 1  2  3  4  5  6  7  8  9 10 11 
11 12 13 14 15 16 17 18 19 20 21 
 lag(x)
 1  2  3  4  5  6  7  8  9 10 
12 13 14 15 16 17 18 19 20 21 
 z
1959 Q2 1959 Q3 1959 Q4 1960 Q1 1960 Q2 1960 Q3 1960 Q4 1961 Q1 1961 Q2 1961 Q3 
  1   2   3   4   5   6   7   8   9  10 
 lag(z)
1959 Q1 1959 Q2 1959 Q3 1959 Q4 1960 Q1 1960 Q2 1960 Q3 1960 Q4 1961 Q1 1961 Q2 
  1   2   3   4   5   6   7   8   9  10 


Why z and lag (z) are of same length while lag(x) is shorter by one than x?

I assume lag(z) would give me like this:
1959 Q3 1959 Q4 1960 Q1 1960 Q2 1960 Q3 1960 Q4 1961 Q1 1961 Q2 1961 Q3 
 2   3   4   5   6   7   8   9  10 
ie preserve the relationship between timestamp and the value.

Same things applies to lag(x) but I guess both make sense:
 1  2  3  4  5  6  7  8  9 10 

12 13 14 15 16 17 18 19 20 21 
or
 2  3  4  5  6  7  8  9 10 11 

12 13 14 15 16 17 18 19 20 21 


Any insight?

Cheers,

Bo

_
[[elided Hotmail spam]]

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] difference between lrm's Model L.R. and anova's Chi-Square

2008-03-02 Thread Frank E Harrell Jr
[EMAIL PROTECTED] wrote:
 Quoting Frank E Harrell Jr [EMAIL PROTECTED]:
 anova (anova.Design) computes Wald statistics.  When the log-likelihood
 is very quadratic, these statistics will be very close to log-likelihood
 ratio chi-square statistics.  In general LR chi-square tests are better;
 we use Wald tests for speed.  It's best to take the time and do
 lrtest(fit1,fit2) in Design, where one of the two fits is a subset of
 the other.

 Frank Harrell
 
 Thanks, this is great, but in my case, there's just one factor,
 
 fit1 - lrm(outcome~factor,data)
 
 and I'm having trouble constructing the subset 'null model', as e.g.
 
 fit2 - lrm(outcome~1,data)
 
 returns an error message.
 
 How do I construct a null model with lrm() so that I can use lrtest() to test 
 a
 model with only one predictor?

The overall LR chi-square test statistic is in the standard output of 
lrm (which uses print.lrm).

 
 I apologize for asking what must be a very simple question but I have been
 unable to find the answer by searching R-help.
 
 Thanks,
 Dan
 
 P.S. Second point: I have another case where I use lmer(), and there the null
 model includes a random effect so I don't get the problem above. It looks like
 with lmer objects anova() uses LLR, not Wald. Is that right?

Please check the lmer documentation.

Frank

 


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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] question on lag.zoo

2008-03-02 Thread Gabor Grothendieck
On Sun, Mar 2, 2008 at 9:28 AM, Gabor Grothendieck
[EMAIL PROTECTED] wrote:
 Its a FAQ.  x is of class zoo but z is of class zooreg so one is using

That should be lag.zooreg

 zoo.lag and the is using zooreg.lag.  See question #6 in the zoo FAQ:
   vignette(zoo-faq)
 and also
   ?lag.zoo


 On Sun, Mar 2, 2008 at 9:12 AM, Bo Zhou [EMAIL PROTECTED] wrote:
 
  Hi Guys,
 
  I'm using zoo package now.  I found lag is not doing what I assumed.
 
   x - zoo(11:21)
   z - zoo(1:10, yearqtr(seq(1959.25, 1961.5, by = 0.25)), frequency = 4)
   x
   1  2  3  4  5  6  7  8  9 10 11
  11 12 13 14 15 16 17 18 19 20 21
   lag(x)
   1  2  3  4  5  6  7  8  9 10
  12 13 14 15 16 17 18 19 20 21
   z
  1959 Q2 1959 Q3 1959 Q4 1960 Q1 1960 Q2 1960 Q3 1960 Q4 1961 Q1 1961 Q2 
  1961 Q3
   1   2   3   4   5   6   7   8   9  
  10
   lag(z)
  1959 Q1 1959 Q2 1959 Q3 1959 Q4 1960 Q1 1960 Q2 1960 Q3 1960 Q4 1961 Q1 
  1961 Q2
   1   2   3   4   5   6   7   8   9  
  10
 
 
  Why z and lag (z) are of same length while lag(x) is shorter by one than x?
 
  I assume lag(z) would give me like this:
  1959 Q3 1959 Q4 1960 Q1 1960 Q2 1960 Q3 1960 Q4 1961 Q1 1961 Q2 1961 Q3
   2   3   4   5   6   7   8   9  10
  ie preserve the relationship between timestamp and the value.
 
  Same things applies to lag(x) but I guess both make sense:
   1  2  3  4  5  6  7  8  9 10
 
  12 13 14 15 16 17 18 19 20 21
  or
   2  3  4  5  6  7  8  9 10 11
 
  12 13 14 15 16 17 18 19 20 21
 
 
  Any insight?
 
  Cheers,
 
  Bo
 
  _
  [[elided Hotmail spam]]
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Idioms for a timeseries operation - moving window

2008-03-02 Thread Gabor Grothendieck
See

?embed

and from zoo see:
?rollapply
?rollmean
?rollmax

There is a function coded in C in the caTools package for speed.


On Sun, Mar 2, 2008 at 9:24 AM, Bo Zhou [EMAIL PROTECTED] wrote:

 Hi Guys,

 Need your wisdom on this.

 Say I have a time series (in zoo format) like this


  x - zoo(11:21)
  x
  1  2  3  4  5  6  7  8  9 10 11
 11 12 13 14 15 16 17 18 19 20 21


 I want to do a moving window sampling of it. The result can either be a 
 matrix or a dataframe like this

 my.super.moving.window(x, length=3, by=1)

 11 12 13
 12 13 14
 13 14 15
 14 15 16
 
 18 19 20
 19 20 21

 This shouldn't be new. Many many people must have done this before. Any idea 
 what's the best(efficient and elegant) way to do this?

 Cheers,

 Bo




 _
 Climb to the top of the charts! Play the word scramble challenge with star 
 power.

[[alternative HTML version deleted]]


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Idioms for a timeseries operation - moving window

2008-03-02 Thread Bo Zhou

Hi Guys,

Need your wisdom on this.

Say I have a time series (in zoo format) like this


 x - zoo(11:21)
 x
 1  2  3  4  5  6  7  8  9 10 11 
11 12 13 14 15 16 17 18 19 20 21 


I want to do a moving window sampling of it. The result can either be a 
matrix or a dataframe like this

my.super.moving.window(x, length=3, by=1)

11 12 13
12 13 14
13 14 15
14 15 16

18 19 20
19 20 21

This shouldn't be new. Many many people must have done this before. Any idea 
what's the best(efficient and elegant) way to do this?

Cheers,

Bo




_
Climb to the top of the charts! Play the word scramble challenge with star 
power.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Idioms for a timeseries operation - moving window

2008-03-02 Thread Gabor Grothendieck
Time to upgrade to the latest version of zoo.  You can also read it online
here:
http://cran.r-project.org/web/packages/zoo

On Sun, Mar 2, 2008 at 9:47 AM, Bo Zhou [EMAIL PROTECTED] wrote:
 Ah! Gabor is the man.

 BTW I don't have zoo-faq. (I actually googled it out)

 This is what I have:

 Vignettes in package 'zoo':

 zoo-quickrefzoo Quick Reference (source, pdf)
 zoo zoo: An S3 Class and Methods for Indexed
 Totally Ordered Observations
 (source, pdf)

 It's a typical windows xp install of R 2.6.1.

 Any idea why?

 Cheers,

 Bo

  Date: Sun, 2 Mar 2008 09:40:09 -0500
  From: [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Subject: Re: [R] Idioms for a timeseries operation - moving window
  CC: r-help@r-project.org


 
  See
 
  ?embed
 
  and from zoo see:
  ?rollapply
  ?rollmean
  ?rollmax
 
  There is a function coded in C in the caTools package for speed.
 
 
  On Sun, Mar 2, 2008 at 9:24 AM, Bo Zhou [EMAIL PROTECTED] wrote:
  
   Hi Guys,
  
   Need your wisdom on this.
  
   Say I have a time series (in zoo format) like this
  
  
x - zoo(11:21)
x
   1 2 3 4 5 6 7 8 9 10 11
   11 12 13 14 15 16 17 18 19 20 21
  
  
   I want to do a moving window sampling of it. The result can either be
 a matrix or a dataframe like this
  
   my.super.moving.window(x, length=3, by=1)
  
   11 12 13
   12 13 14
   13 14 15
   14 15 16
   
   18 19 20
   19 20 21
  
   This shouldn't be new. Many many people must have done this before. Any
 idea what's the best(efficient and elegant) way to do this?
  
   Cheers,
  
   Bo
  
  
  
  
   _
   Climb to the top of the charts! Play the word scramble challenge with
 star power.
  
   [[alternative HTML version deleted]]
  
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
  

 
 Connect and share in new ways with Windows Live. Get it now!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Newbie:Export Data into Excel from R

2008-03-02 Thread Keizer_71

Hi,

All i want is to export my list into c: drive and save it as csv file and
manually import into Excel.

I have the read the article but i am having issues
http://pbil.univ-lyon1.fr/library/base/html/write.table.html


 excel-write.table(probe_gene, file = c:\foo.csv, sep = ,, col.names =
 NA)
Error in file(file, ifelse(append, a, w)) : 

unable to open connection
In addition: Warning message:
cannot open file 'c:\foo.csv', reason 'Invalid argument' 

any suggestions?

thanks,
chris


-- 
View this message in context: 
http://www.nabble.com/Newbie%3AExport-Data-into-Excel-from-R-tp15788950p15788950.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Idioms for a timeseries operation - moving window

2008-03-02 Thread Bo Zhou

Thanks. Problem solved.

 rollapply(x,3,force, align=left)

1 1 2  3
2 2 3  4
3 3 4  5
4 4 5  6
5 5 6  7
6 6 7  8
7 7 8  9
8 8 9 10

 x-1:10
 embed(x, 3)[, 3:1]
 [,1] [,2] [,3]
[1,]123
[2,]234
[3,]345
[4,]456
[5,]567
[6,]678
[7,]789
[8,]89   10
 


 Date: Sun, 2 Mar 2008 10:04:38 -0500
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: Re: [R] Idioms for a timeseries operation - moving window
 CC: r-help@r-project.org
 
 Try:
 
 rollapply(x, 3, force)
 
 or
 
 embed(x, 3)[, 3:1]
 
 On Sun, Mar 2, 2008 at 9:53 AM, Bo Zhou [EMAIL PROTECTED] wrote:
 
  I needed that matrix for following calculations. So I don't think roll*
  would work for me.
 
  Re: embed
 
   x - 1:10
   embed (x, 3)
   [,1] [,2] [,3]
  [1,]321
  [2,]432
  [3,]543
  [4,]654
  [5,]765
  [6,]876
  [7,]987
  [8,]   1098
   x
   [1]  1  2  3  4  5  6  7  8  9 10
 
  The matrix is in revered order. Anyway to put the matrix in the original
  order? Ie
  1 2 3
  2 3 4
  ...
 
 
  Cheers,
  Bo
 
 
 
 
   Date: Sun, 2 Mar 2008 09:40:09 -0500
   From: [EMAIL PROTECTED]
   To: [EMAIL PROTECTED]
   Subject: Re: [R] Idioms for a timeseries operation - moving window
   CC: r-help@r-project.org
  
 
   See
  
   ?embed
  
   and from zoo see:
   ?rollapply
   ?rollmean
   ?rollmax
  
   There is a function coded in C in the caTools package for speed.
  
  
   On Sun, Mar 2, 2008 at 9:24 AM, Bo Zhou [EMAIL PROTECTED] wrote:
   
Hi Guys,
   
Need your wisdom on this.
   
Say I have a time series (in zoo format) like this
   
   
 x - zoo(11:21)
 x
1 2 3 4 5 6 7 8 9 10 11
11 12 13 14 15 16 17 18 19 20 21
   
   
I want to do a moving window sampling of it. The result can either be
  a matrix or a dataframe like this
   
my.super.moving.window(x, length=3, by=1)
   
11 12 13
12 13 14
13 14 15
14 15 16

18 19 20
19 20 21
   
This shouldn't be new. Many many people must have done this before. Any
  idea what's the best(efficient and elegant) way to do this?
   
Cheers,
   
Bo
   
   
   
   
_
Climb to the top of the charts! Play the word scramble challenge with
  star power.
   
[[alternative HTML version deleted]]
   
   
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
   
   
 
  
  Shed those extra pounds with MSN and The Biggest Loser! Learn more.

_
[[elided Hotmail spam]]

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Idioms for a timeseries operation - moving window

2008-03-02 Thread Bo Zhou


Ah! Gabor is the man.



BTW I don't have zoo-faq. (I actually googled it out)



This is what I have:



Vignettes in package ‘zoo’:



zoo-quickrefzoo Quick Reference (source, pdf)

zoo zoo: An S3 Class and Methods for Indexed 
Totally Ordered Observations

(source, pdf)



It's a typical windows xp install of R 2.6.1.



Any idea why?



Cheers,



Bo

 Date: Sun, 2 Mar 2008 09:40:09 -0500
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: Re: [R] Idioms for a timeseries operation - moving window
 CC: r-help@r-project.org
 
 See
 
 ?embed
 
 and from zoo see:
 ?rollapply
 ?rollmean
 ?rollmax
 
 There is a function coded in C in the caTools package for speed.
 
 
 On Sun, Mar 2, 2008 at 9:24 AM, Bo Zhou [EMAIL PROTECTED] wrote:
 
  Hi Guys,
 
  Need your wisdom on this.
 
  Say I have a time series (in zoo format) like this
 
 
   x - zoo(11:21)
   x
   1  2  3  4  5  6  7  8  9 10 11
  11 12 13 14 15 16 17 18 19 20 21
 
 
  I want to do a moving window sampling of it. The result can either be a 
  matrix or a dataframe like this
 
  my.super.moving.window(x, length=3, by=1)
 
  11 12 13
  12 13 14
  13 14 15
  14 15 16
  
  18 19 20
  19 20 21
 
  This shouldn't be new. Many many people must have done this before. Any 
  idea what's the best(efficient and elegant) way to do this?
 
  Cheers,
 
  Bo
 
 
 
 
  _
  Climb to the top of the charts! Play the word scramble challenge with star 
  power.
 
 [[alternative HTML version deleted]]
 
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 

_


08
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Idioms for a timeseries operation - moving window

2008-03-02 Thread Bo Zhou


I needed that matrix for following calculations. So I don't think roll* would 
work for me.

Re: embed

 x - 1:10
 embed (x, 3)
 [,1] [,2] [,3]
[1,]321
[2,]432
[3,]543
[4,]654
[5,]765
[6,]876
[7,]987
[8,]   1098
 x
 [1]  1  2  3  4  5  6  7  8  9 10

The matrix is in revered order. Anyway to put the matrix in the original order? 
Ie 
1 2 3
2 3 4
...

Cheers,
Bo




 Date: Sun, 2 Mar 2008 09:40:09 -0500
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: Re: [R] Idioms for a timeseries operation - moving window
 CC: r-help@r-project.org
 
 See
 
 ?embed
 
 and from zoo see:
 ?rollapply
 ?rollmean
 ?rollmax
 
 There is a function coded in C in the caTools package for speed.
 
 
 On Sun, Mar 2, 2008 at 9:24 AM, Bo Zhou [EMAIL PROTECTED] wrote:
 
  Hi Guys,
 
  Need your wisdom on this.
 
  Say I have a time series (in zoo format) like this
 
 
   x - zoo(11:21)
   x
   1  2  3  4  5  6  7  8  9 10 11
  11 12 13 14 15 16 17 18 19 20 21
 
 
  I want to do a moving window sampling of it. The result can either be a 
  matrix or a dataframe like this
 
  my.super.moving.window(x, length=3, by=1)
 
  11 12 13
  12 13 14
  13 14 15
  14 15 16
  
  18 19 20
  19 20 21
 
  This shouldn't be new. Many many people must have done this before. Any 
  idea what's the best(efficient and elegant) way to do this?
 
  Cheers,
 
  Bo
 
 
 
 
  _
  Climb to the top of the charts! Play the word scramble challenge with star 
  power.
 
 [[alternative HTML version deleted]]
 
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 

_
[[elided Hotmail spam]]

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Make plots with GNUplot. Have anyone tried that?

2008-03-02 Thread Louise Hoffman
 There is a very basic interface between R and gnuplot in the TeachingDemos
 package.  Look at the help for gp.plot.
[snip]

This looks mighty interesting =)

Is it possible to plot with lines (gnuplot syntex) so all the data
points are connected?

Also is it possible to make it write the output to a pdf file? (I
using the gnuplot cvs which have pdfcairo support)

When I try this, it doesn't write the pdf file. it works with gnuplot cvs.

library(TeachingDemos)
fuelData-read.table('fuel.csv',header=TRUE, sep=',')
attach(fuelData)
gp.open(where='/usr/local/bin/gnuplot')
gp.send('set terminal pdfcairo font 'cmr10' size 8cm,4.6cm')
gp.send('set output '../figures/q1-raw-data-gp.pdf'')
gp.send('unset key')
gp.send('set xlabel 'rtime'')
gp.send('set ylabel 'FPI'')
gp.send('set xrange [1979:2005]')
gp.plot(rtime,fpi)
gp.send('unset output')
gp.close()

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Newbie:Export Data into Excel from R

2008-03-02 Thread John Kane
R uses unix type slashes  that is / rather than \
even if you're using Windows

You probably need either to write 
file =c:/foo.csv or escape the \ thusly
file =
 c:\\foo.csv

Either way should work. Personally find it easier to
use '/.


--- Keizer_71 [EMAIL PROTECTED] wrote:

 
 Hi,
 
 All i want is to export my list into c: drive and
 save it as csv file and
 manually import into Excel.
 
 I have the read the article but i am having issues

http://pbil.univ-lyon1.fr/library/base/html/write.table.html
 
 
  excel-write.table(probe_gene, file =
 c:\foo.csv, sep = ,, col.names =
  NA)
 Error in file(file, ifelse(append, a, w)) : 
 
 unable to open connection
 In addition: Warning message:
 cannot open file 'c:\foo.csv', reason 'Invalid
 argument' 
 
 any suggestions?
 
 thanks,
 chris
 
 
 -- 
 View this message in context:

http://www.nabble.com/Newbie%3AExport-Data-into-Excel-from-R-tp15788950p15788950.html
 Sent from the R help mailing list archive at
 Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Newbie:Export Data into Excel from R

2008-03-02 Thread Charilaos Skiadas
You will likely need to escape that backslash, i.e. c:\\foo.csv.

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College

On Mar 2, 2008, at 10:12 AM, Keizer_71 wrote:


 Hi,

 All i want is to export my list into c: drive and save it as csv  
 file and
 manually import into Excel.

 I have the read the article but i am having issues
 http://pbil.univ-lyon1.fr/library/base/html/write.table.html


 excel-write.table(probe_gene, file = c:\foo.csv, sep = ,,  
 col.names =
 NA)
 Error in file(file, ifelse(append, a, w)) :

 unable to open connection
 In addition: Warning message:
 cannot open file 'c:\foo.csv', reason 'Invalid argument'

 any suggestions?

 thanks,
 chris


 -- 
 View this message in context: http://www.nabble.com/Newbie%3AExport- 
 Data-into-Excel-from-R-tp15788950p15788950.html
 Sent from the R help mailing list archive at Nabble.com.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [OT] normal (as in Guassian)

2008-03-02 Thread Gabor Csardi
I'm not a statistician, but do i remember well that among all 
distributions with a given mean and variance, the normal distribution
has the highest entropy? This is good enough for me to call it 
normal

Gabor

On Sun, Mar 02, 2008 at 10:10:21AM -0600, roger koenker wrote:
 A nice survey of this territory is:
 
 http://books.google.com/books?id=TN3_d7ibo30Cpg=PA85lpg=PA85dq=stigler+normal+oxymoronsource=webots=OwGhmnDk3Osig=J7ou_L8-_Mu4L14c3KJAhefrD4Ihl=en
 
 I particularly like the phrase:  [normal] is in this respect
 a rare one-word oxymoron.
 
 url:www.econ.uiuc.edu/~rogerRoger Koenker
 email   [EMAIL PROTECTED]   Department of Economics
 vox:217-333-4558University of Illinois
 fax:217-244-6678Champaign, IL 61820
 
 
 On Mar 2, 2008, at 7:33 AM, (Ted Harding) wrote:
 
  Hi Folks,
  Apologies to anyone who'd prefer not to see this query
  on this list; but I'm asking because it is probably the
  forum where I'm most likely to get a good answer!
 
  I'm interested in the provenance of the name normal
  distribution (for what I'd really prefer to call the
  Gaussian distribution).
 
  According to Wikipedia, The name normal distribution
  was coined independently by Charles S. Peirce, Francis
  Galton and Wilhelm Lexis around 1875.
 
  So be it, if that was the case -- but I would like to
  know why they chose the name normal: what did they
  intend to convey?
 
  As background: I'm reflecting a bit on the usage in
  statistics of everyday language as techincal terms,
  as in significantly different. This, for instance,
  is likely to be misunderstood by the general publidc
  when they encounter statements in the media.
 
  Likewise, normally distributed would probably be
  interpreted as distributed in the way one would
  normally expect or, perhaps, there was nothing
  unusual about the distribution.
 
  Comments welcome!
  With thanks,
  Ted.
 
  
  E-Mail: (Ted Harding) [EMAIL PROTECTED]
  Fax-to-email: +44 (0)870 094 0861
  Date: 02-Mar-08   Time: 13:04:17
  -- XFMail --
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [OT] normal (as in Guassian)

2008-03-02 Thread roger koenker
A nice survey of this territory is:

http://books.google.com/books?id=TN3_d7ibo30Cpg=PA85lpg=PA85dq=stigler+normal+oxymoronsource=webots=OwGhmnDk3Osig=J7ou_L8-_Mu4L14c3KJAhefrD4Ihl=en

I particularly like the phrase:  [normal] is in this respect
a rare one-word oxymoron.

url:www.econ.uiuc.edu/~rogerRoger Koenker
email   [EMAIL PROTECTED]   Department of Economics
vox:217-333-4558University of Illinois
fax:217-244-6678Champaign, IL 61820


On Mar 2, 2008, at 7:33 AM, (Ted Harding) wrote:

 Hi Folks,
 Apologies to anyone who'd prefer not to see this query
 on this list; but I'm asking because it is probably the
 forum where I'm most likely to get a good answer!

 I'm interested in the provenance of the name normal
 distribution (for what I'd really prefer to call the
 Gaussian distribution).

 According to Wikipedia, The name normal distribution
 was coined independently by Charles S. Peirce, Francis
 Galton and Wilhelm Lexis around 1875.

 So be it, if that was the case -- but I would like to
 know why they chose the name normal: what did they
 intend to convey?

 As background: I'm reflecting a bit on the usage in
 statistics of everyday language as techincal terms,
 as in significantly different. This, for instance,
 is likely to be misunderstood by the general publidc
 when they encounter statements in the media.

 Likewise, normally distributed would probably be
 interpreted as distributed in the way one would
 normally expect or, perhaps, there was nothing
 unusual about the distribution.

 Comments welcome!
 With thanks,
 Ted.

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 02-Mar-08   Time: 13:04:17
 -- XFMail --

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Newbie:Export Data into Excel from R

2008-03-02 Thread David Winsemius
Keizer_71 [EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]: 


 All i want is to export my list into c: drive and save it as csv
 file and manually import into Excel.
 
 I have the read the article but i am having issues
 http://pbil.univ-lyon1.fr/library/base/html/write.table.html
 
 
 excel-write.table(probe_gene, file = c:\foo.csv, sep = ,,
 col.names = NA)
 Error in file(file, ifelse(append, a, w)) : 
 
 unable to open connection
 In addition: Warning message:
 cannot open file 'c:\foo.csv', reason 'Invalid argument' 
 
 any suggestions?
 

One can use the file.choose() function  in place of a quoted file name. I 
do so because it gets around the \, /, \\ confusion in my brain, 
... and it's faster. 

R does not use solitary \'s in its filenames for directory separation. 
It's the escape character for regular expressions, and R's development 
in the *nix world trumped any need to be consistent with the dark side's 
use of \ as a directory separator. You can use single / as well as 
\\


-- 
David Winsemius

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] COMPAR.GEE Output

2008-03-02 Thread Ben Bolker
Charles Willis willis.charlie at gmail.com writes:

 
 Hello,
 
 I am running the program COMPAR.GEE within the package APE. My dependent
 variable is binomial, while my independent variable is a multi-state
 categorical variable. The output reports an estimate for each state of the
 independent variable except the first one. For example, for the variable X
 with 3 states, the output is:
 
 intercept  (estimate)
 X2   (estimate)
 X3   (estimate)
 
 I have two questions: 1) Why does it not give me an intercept for the first
 variable and how do i get it; 2) can a get a general estimate of
 correlation, like a wald's statistic for the variable?

  1. It's useful to provide a small self-contained example, as recommended
by the posting guide (referred to after every r-help message).
  2. I would suggest asking this kind of question on the r-sig-phylo
mailing list, which is devoted to phylogenetic and comparative analyses
in R.
  3. In order to understand the output, you have to understand the
way in which R parameterizes statistical models.  I'm guessing
that you specified family=binomial in your compar.gee call, which
would mean by default assuming binomial error structure and a
logit link (if you don't know what that means, you should probably
read up on generalized linear models a bit ...).  X1 is then
the estimated logit-probability for state 1, X2 is the estimated
*difference* in logit-prob between states 1 and 2, similarly for
X3.  If you just want the estimated probabilities for the three
groups you can fit a model without an intercept using something
like response~predictor-1 as your formula.
  4. When you print the model object (e.g. c1=compar.gee(...); c1)
it gives you standard errors and t statistics for each parameter
which are (I believe) essentially Wald statistics, although
you should certainly check the reference given in ?compar.gee ...

  good luck,
Ben Bolker

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] summarizing matrix data

2008-03-02 Thread Emilio Gagliardi
Hi everyone,

I'm sure this is simple, but I can't seem to figure this out.

Situation.  3 different groups of subjects each submit n X n matrices of
scores.  What I want to do is aggregate each group of scores into a summary
n X n matrix.  I need the result to be a matrix so that I can calculate a
dissimilarity structure on it.  So I thought I would create a
multi-dimensional array and store the data that way.

The first two dimensions represent the data, the third the group membership
(say 3 groups), and forth represents subjects(30 subjects per group)...

subject.data - array(NA, dim=c(3,3,3,10))

data.1 - matrix(seq(from=1,to=9,by=1),nrow=3,ncol=3)
data.2 - matrix(seq(from=11,to=19,by=1),nrow=3,ncol=3)
data.3 - matrix(seq(from=21,to=29,by=1),nrow=3,ncol=3)
data.4 - matrix(seq(from=31,to=39,by=1),nrow=3,ncol=3)
data.5 - matrix(seq(from=41,to=49,by=1),nrow=3,ncol=3)
data.6 - matrix(seq(from=51,to=59,by=1),nrow=3,ncol=3)

subject.data[,,1,1] - data.1   # subject 1 group 1
subject.data[,,2,1] - data.2   # subject 1 group 2
subject.data[,,3,1] - data.3   # subject 1 group 3
subject.data[,,3,2] - data.4   # subject 2 group 3
subject.data[,,2,2] - data.5   # subject 2 group 2
subject.data[,,1,2] - data.6   # subject 2 group 1

what I want is conceptually:
array.group1 - apply(subject.data[,,1,],mean)
array.group2 - apply(subject.data[,,2,],mean)
array.group3 - apply(subject.data[,,3,],mean)

each of the summary matrices then contain the mean for each cell across all
subjects within a group so that it has the same size as the subject data.
Also, after I've populated subject.data, there will be segments that will
only contain NAs, how do you grab just the portions of the array that
contain data? I know the function is.na() will get me an index I just don't
know how to write it correctly.  something like
only.data - subject.data[!is.na(subject.data)]

Does that make?  I would appreciate any help regarding a better way to store
the data and obviously how to get back these summary matrices...

Thanks very much for your help.

emilio

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] elegant way to minus on each row of a matrix

2008-03-02 Thread Bo Zhou

How to do this in an elegant way formatrix/data frame/zoo?

mat=
1 2 3
4 5 6
7 8 9

vector=
1
2
3


result=
0 1 2
2 3 4
4 5 6

ie
1-1  2-1  3-1
4-2  5-2  6-2
7-3  8-3  9-3

Thanks in advance.

_


08
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Variance Calculation in R

2008-03-02 Thread Keizer_71

sorry...in step 4-i need the R code to output in this format when i export to
excel.

ProbeID Variance
1   224588_at   21.58257457

thanks 



Keizer_71 wrote:
 
 Hello,
 
 Thanks everyone for helping me with the previous queries.
 
 step 1: Here is the orginal data: short sample
 
   ProbeID Sample_1_D  Sample_1_CSample_2_D   Sample_2_C
 1 224588_at   2.425509867 11.34031409   11.46868531  11.75741478
 
 step 2: i calculate the variance of the sample using this R code
 
 x-1:2
 y-2:141
 data.matrix-data.matrix(data[,y])#create data.matrix
 variableprobe-apply(data.matrix[x,],1,var)
 
 step 3: however, when i type in variableprobe, it gives me this.
 
 1 21.58257457
 
 step 4: I need the code to output this:
 
   ProbeID Variance
 1 224588_at   21.58257457
 
 
 What do i need to do to modify the code to give me better description like
 the one above?
 
 thank.
 Keizer
   
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Variance-Calculation-in-R-tp15790621p15790768.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] regression output to latex

2008-03-02 Thread Luca Braglia
hello everybody

i was seeking a converter beetween R regression output (eg with
summary) and the conventional way to present regression output in
paper: every model as a vertical vector with \beta, t beetween
parenthesis below the first, and other statistics (R^2 etc) .

I've seen hmisc and xtable, and if I didn't miss something, they
don't include something like that.

Thank you

   Luca

-- 
 Luca Braglia, aka Bragliozzo
   http://bragliozzo.altervista.org

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Variance Calculation in R

2008-03-02 Thread Keizer_71

Hello,

Thanks everyone for helping me with the previous queries.

step 1: Here is the orginal data: short sample

ProbeID Sample_1_D  Sample_1_CSample_2_D   Sample_2_C
1   224588_at   2.425509867 11.34031409   11.46868531  11.75741478

step 2: i calculate the variance of the sample using this R code

x-1:2
y-2:141
data.matrix-data.matrix(data[,y])#create data.matrix
variableprobe-apply(data.matrix[x,],1,var)

step 3: however, when i type in variableprobe, it gives me this.

1   21.58257457

step 4: I need the code to output this:

ProbeID Variance
1   224588_at   21.58257457


What do i need to do to modify the code to give me better description like
the one above?

thank.
Keizer



-- 
View this message in context: 
http://www.nabble.com/Variance-Calculation-in-R-tp15790621p15790621.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Imputation Packages

2008-03-02 Thread ArunPrasad

Hi everyone,
  I am looking for a package in R which can help me in using the
imputation technique to find the missing values for my regression analysis.
Any help would be appreciated.

Cheers
Arun
-- 
View this message in context: 
http://www.nabble.com/Imputation-Packages-tp15790749p15790749.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] elegant way to minus on each row of a matrix

2008-03-02 Thread Bo Zhou

Brilliant! 

 t1=matrix(1:15,5,3)
 t1
 [,1] [,2] [,3]
[1,]16   11
[2,]27   12
[3,]38   13
[4,]49   14
[5,]5   10   15
 t2=1:5
 t2
[1] 1 2 3 4 5

 sweep(t1, 1, t2)
 [,1] [,2] [,3]
[1,]05   10
[2,]05   10
[3,]05   10
[4,]05   10
[5,]05   10

 Date: Sun, 2 Mar 2008 14:56:22 -0300
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: Re: [R] elegant way to minus on each row of a matrix
 CC: r-help@r-project.org
 
 Try this:
 
 sweep(mat, 1, vec)
 
 
 On 02/03/2008, Bo Zhou [EMAIL PROTECTED] wrote:
 
  How to do this in an elegant way formatrix/data frame/zoo?
 
  mat=
  1 2 3
  4 5 6
  7 8 9
 
  vector=
  1
  2
  3
 
 
  result=
  0 1 2
  2 3 4
  4 5 6
 
  ie
  1-1  2-1  3-1
  4-2  5-2  6-2
  7-3  8-3  9-3
 
  Thanks in advance.
 
  _
 
 
  08
  [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 -- 
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O

_
Need to know the score, the latest news, or you need your Hotmail®-get your 
fix.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Variance Calculation in R

2008-03-02 Thread Henrique Dallazuanna
Try this:

write.table(cbind(data.matrix[1], Variance = apply(data.matrix[,-1],
1, var)),file='file.xls')


On 02/03/2008, Keizer_71 [EMAIL PROTECTED] wrote:

 sorry...in step 4-i need the R code to output in this format when i export
 to
 excel.

   ProbeID Variance
 1 224588_at   21.58257457

 thanks



 Keizer_71 wrote:
 
  Hello,
 
  Thanks everyone for helping me with the previous queries.
 
  step 1: Here is the orginal data: short sample
 
  ProbeID Sample_1_D  Sample_1_CSample_2_D   Sample_2_C
  1   224588_at   2.425509867 11.34031409   11.46868531  11.75741478
 
  step 2: i calculate the variance of the sample using this R code
 
  x-1:2
  y-2:141
  data.matrix-data.matrix(data[,y])#create data.matrix
  variableprobe-apply(data.matrix[x,],1,var)
 
  step 3: however, when i type in variableprobe, it gives me this.
 
  1   21.58257457
 
  step 4: I need the code to output this:
 
  ProbeID Variance
  1   224588_at   21.58257457
 
 
  What do i need to do to modify the code to give me better description like
  the one above?
 
  thank.
  Keizer
  
 
 
 

 --
 View this message in context:
 http://www.nabble.com/Variance-Calculation-in-R-tp15790621p15790768.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] elegant way to minus on each row of a matrix

2008-03-02 Thread Bo Zhou

Hi Dimitris and everyone

I tried this but now I know why it didn't work out for me initially.

 t1=matrix(1:10,5,2)
 t2=matrix(1,5,1)
 t2
 [,1]
[1,]1
[2,]1
[3,]1
[4,]1
[5,]1
 t1
 [,1] [,2]
[1,]16
[2,]27
[3,]38
[4,]49
[5,]5   10
 t1-as.vector(t2)
 [,1] [,2]
[1,]05
[2,]16
[3,]27
[4,]38
[5,]49
 t1-t2
Error in t1 - t2 : non-conformable arrays

I'm too used to Matlab I guess.

Cheers,

Bo


 Date: Sun, 2 Mar 2008 18:56:15 +0100
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 CC: r-help@r-project.org
 Subject: Re: [R] elegant way to minus on each row of a matrix
 
 try this:
 
 mat - matrix(1:9, 3, 3, TRUE)
 dat - as.data.frame(mat)
 vec - 1:3
 
 result.mat - mat - vec
 result.dat - dat - vec
 result.mat
 result.dat
 
 
 I hope it helps.
 
 Best,
 Dimitris
 
 
 Dimitris Rizopoulos
 Biostatistical Centre
 School of Public Health
 Catholic University of Leuven
 
 Address: Kapucijnenvoer 35, Leuven, Belgium
 Tel: +32/(0)16/336899
 Fax: +32/(0)16/337015
 Web: http://med.kuleuven.be/biostat/
   http://www.student.kuleuven.be/~m0390867/dimitris.htm
 
 
 Quoting Bo Zhou [EMAIL PROTECTED]:
 
 
  How to do this in an elegant way formatrix/data frame/zoo?
 
  mat=
  1 2 3
  4 5 6
  7 8 9
 
  vector=
  1
  2
  3
 
 
  result=
  0 1 2
  2 3 4
  4 5 6
 
  ie
  1-1  2-1  3-1
  4-2  5-2  6-2
  7-3  8-3  9-3
 
  Thanks in advance.
 
  _
 
 
  08
  [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
 
 Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
 

_


08
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] elegant way to minus on each row of a matrix

2008-03-02 Thread Henrique Dallazuanna
Try this:

sweep(mat, 1, vec)


On 02/03/2008, Bo Zhou [EMAIL PROTECTED] wrote:

 How to do this in an elegant way formatrix/data frame/zoo?

 mat=
 1 2 3
 4 5 6
 7 8 9

 vector=
 1
 2
 3


 result=
 0 1 2
 2 3 4
 4 5 6

 ie
 1-1  2-1  3-1
 4-2  5-2  6-2
 7-3  8-3  9-3

 Thanks in advance.

 _


 08
   [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] summarizing matrix data

2008-03-02 Thread Henrique Dallazuanna
One options is:

data.1 - matrix(seq(from=1,to=9,by=1),nrow=3,ncol=3)
data.2 - matrix(seq(from=11,to=19,by=1),nrow=3,ncol=3)
data.3 - matrix(seq(from=21,to=29,by=1),nrow=3,ncol=3)
data.4 - matrix(seq(from=31,to=39,by=1),nrow=3,ncol=3)
data.5 - matrix(seq(from=41,to=49,by=1),nrow=3,ncol=3)
data.6 - matrix(seq(from=51,to=59,by=1),nrow=3,ncol=3)

patt - ls(patt='^data\\.[0-9]')
nsubs - 2
ngroups - 3
apply(array(as.vector(sapply(patt, get)), dim = c(dim(get(patt[1])),
ngroups, nsubs)),  3, mean)


On 02/03/2008, Emilio Gagliardi [EMAIL PROTECTED] wrote:
 Hi everyone,

 I'm sure this is simple, but I can't seem to figure this out.

 Situation.  3 different groups of subjects each submit n X n matrices of
 scores.  What I want to do is aggregate each group of scores into a summary
 n X n matrix.  I need the result to be a matrix so that I can calculate a
 dissimilarity structure on it.  So I thought I would create a
 multi-dimensional array and store the data that way.

 The first two dimensions represent the data, the third the group membership
 (say 3 groups), and forth represents subjects(30 subjects per group)...

 subject.data - array(NA, dim=c(3,3,3,10))

 data.1 - matrix(seq(from=1,to=9,by=1),nrow=3,ncol=3)
 data.2 - matrix(seq(from=11,to=19,by=1),nrow=3,ncol=3)
 data.3 - matrix(seq(from=21,to=29,by=1),nrow=3,ncol=3)
 data.4 - matrix(seq(from=31,to=39,by=1),nrow=3,ncol=3)
 data.5 - matrix(seq(from=41,to=49,by=1),nrow=3,ncol=3)
 data.6 - matrix(seq(from=51,to=59,by=1),nrow=3,ncol=3)

 subject.data[,,1,1] - data.1   # subject 1 group 1
 subject.data[,,2,1] - data.2   # subject 1 group 2
 subject.data[,,3,1] - data.3   # subject 1 group 3
 subject.data[,,3,2] - data.4   # subject 2 group 3
 subject.data[,,2,2] - data.5   # subject 2 group 2
 subject.data[,,1,2] - data.6   # subject 2 group 1

 what I want is conceptually:
 array.group1 - apply(subject.data[,,1,],mean)
 array.group2 - apply(subject.data[,,2,],mean)
 array.group3 - apply(subject.data[,,3,],mean)

 each of the summary matrices then contain the mean for each cell across all
 subjects within a group so that it has the same size as the subject data.
 Also, after I've populated subject.data, there will be segments that will
 only contain NAs, how do you grab just the portions of the array that
 contain data? I know the function is.na() will get me an index I just don't
 know how to write it correctly.  something like
 only.data - subject.data[!is.na(subject.data)]

 Does that make?  I would appreciate any help regarding a better way to store
 the data and obviously how to get back these summary matrices...

 Thanks very much for your help.

 emilio

   [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] elegant way to minus on each row of a matrix

2008-03-02 Thread Bo Zhou

Hi Mark, (CC'ing r-help)


Only need to change the parameter from 1 to 2 after that it worked great. Thanks



 t1=matrix(1:15,5,3)

 t1

 [,1] [,2] [,3]

[1,]16   11

[2,]27   12

[3,]38   13

[4,]49   14

[5,]5   10   15

 t2=1:5

 t2

[1] 1 2 3 4 5

 apply(t1,2, function(x) x - t2)

 [,1] [,2] [,3]

[1,]05   10

[2,]05   10

[3,]05   10

[4,]05   10

[5,]05   10

 

 Date: Sun, 2 Mar 2008 12:51:53 -0500
 From: [EMAIL PROTECTED]
 Subject: RE: [R] elegant way to minus on each row of a matrix
 To: [EMAIL PROTECTED]
 
 try result-apply(mat,1, function(.row) .row - vector) but I don't have R
 here so make sure it works.
 
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
 Behalf Of Bo Zhou
 Sent: Sunday, March 02, 2008 12:43 PM
 To: r-help@r-project.org
 Subject: [R] elegant way to minus on each row of a matrix
 
 
 How to do this in an elegant way formatrix/data frame/zoo?
 
 mat=
 1 2 3
 4 5 6
 7 8 9
 
 vector=
 1
 2
 3
 
 
 result=
 0 1 2
 2 3 4
 4 5 6
 
 ie
 1-1  2-1  3-1
 4-2  5-2  6-2
 7-3  8-3  9-3
 
 Thanks in advance.
 
 _
 
 
 08
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

_


08
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] elegant way to minus on each row of a matrix

2008-03-02 Thread Dimitris Rizopoulos
try this:

mat - matrix(1:9, 3, 3, TRUE)
dat - as.data.frame(mat)
vec - 1:3

result.mat - mat - vec
result.dat - dat - vec
result.mat
result.dat


I hope it helps.

Best,
Dimitris


Dimitris Rizopoulos
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
  http://www.student.kuleuven.be/~m0390867/dimitris.htm


Quoting Bo Zhou [EMAIL PROTECTED]:


 How to do this in an elegant way formatrix/data frame/zoo?

 mat=
 1 2 3
 4 5 6
 7 8 9

 vector=
 1
 2
 3


 result=
 0 1 2
 2 3 4
 4 5 6

 ie
 1-1  2-1  3-1
 4-2  5-2  6-2
 7-3  8-3  9-3

 Thanks in advance.

 _


 08
   [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.





Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Variance Calculation in R

2008-03-02 Thread Keizer_71

Hi Henrique,

It is definitely better, but it doesn't show me the ProbeID which identify
the probes name

Here was the result when i export to excel with your code.

 Variance 
1 2.425509867 21.6216446425273  


any suggestions?

thanks,
Kei


Keizer_71 wrote:
 
 Hello,
 
 Thanks everyone for helping me with the previous queries.
 
 step 1: Here is the orginal data: short sample
 
   ProbeID Sample_1_D  Sample_1_CSample_2_D   Sample_2_C
 1 224588_at   2.425509867 11.34031409   11.46868531  11.75741478
 
 step 2: i calculate the variance of the sample using this R code
 
 x-1:2
 y-2:141
 data.matrix-data.matrix(data[,y])#create data.matrix
 variableprobe-apply(data.matrix[x,],1,var)
 
 step 3: however, when i type in variableprobe, it gives me this.
 
 1 21.58257457
 
 step 4: I need the code to output this:
 
   ProbeID Variance
 1 224588_at   21.58257457
 
 
 What do i need to do to modify the code to give me better description like
 the one above?
 
 thank.
 Keizer
   
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Variance-Calculation-in-R-tp15790621p15791115.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Make plots with GNUplot. Have anyone tried that?

2008-03-02 Thread Paul Murrell
Hi


Louise Hoffman wrote:
 [snip]
  Seriously. Be specific if you have a problem. (read the posting guide). R 
 can
  also plot. If you don't like R's plots (which I could not understand) you 
 can
  export data and import them to gnuplot. So what?
 
 Okay, my post was not very good.
 
 The reason (I think) I need GNUplot, is that I would like to include
 the plots from R in a Latex report, where I would like to have all the
 text and equations in the plots with the same font as used in Latex.


Take a look at Non-standard fonts in PostScript and PDF graphics in
http://cran.r-project.org/doc/Rnews/Rnews_2006-2.pdf, plus
http://www.stat.auckland.ac.nz/~paul/R/CM/CMR.html

These describe one way to use LaTeX fonts in R plots.

Paul


 So when I read about opening and closing dev for making a pdf I
 figured that the plots that R produces are like the once Matlab makes;
 shows what they ought to, nothing more, nothing less.
 
 So I was wondering if anyone know of an GNUplot friendly format and
 the code that would produce that text file.
 
 I am new to both R and GNUplot, so I am pure ears if someone knows how
 to make such plots in R.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] summarizing matrix data

2008-03-02 Thread Henrique Dallazuanna
Then you can try this:

apply(array(as.vector(sapply(patt, get)), dim = c(dim(get(patt[1])),
ngroups, nsubs)), 1:3, mean)


For create the matrices in a loop one option is:

lapply(seq(1, 51, by=10), function(x)matrix(seq(x, x+8), nrow=3, ncol=3))



On 02/03/2008, Emilio Gagliardi [EMAIL PROTECTED] wrote:
 Hi Henrique,

 Thank you for your help, but it doesn't produce what I'm looking for...

 On Sun, Mar 2, 2008 at 10:50 AM, Henrique Dallazuanna [EMAIL PROTECTED]
 wrote:

  One options is:
 
  data.1 - matrix(seq(from=1,to=9,by=1),nrow=3,ncol=3)
  data.2 - matrix(seq(from=11,to=19,by=1),nrow=3,ncol=3)
  data.3 - matrix(seq(from=21,to=29,by=1),nrow=3,ncol=3)
  data.4 - matrix(seq(from=31,to=39,by=1),nrow=3,ncol=3)
  data.5 - matrix(seq(from=41,to=49,by=1),nrow=3,ncol=3)
  data.6 - matrix(seq(from=51,to=59,by=1),nrow=3,ncol=3)
 
  patt - ls(patt='^data\\.[0-9]')
  nsubs - 2
  ngroups - 3
  apply(array(as.vector(sapply(patt, get)), dim = c(dim(get(patt[1])),
  ngroups, nsubs)),  3, mean)


 generated [1] 20 30 40

 but what I need is an average per cell...so in the above, there are 6 (3 x
 3) matrices across 3 groups ( 2 subjects per group)..what I need is 1 matrix
 per group, not one mean.  Moreover, I'm storing the data in a single
 multi-dimensional array, not as a collection of arrays since I'm creating
 each data matrix within a loop (I read a file, create the data matrix, store
 it in a larger structure) so that I can perform operations on all the data
 outside of the loop...

 for(i in 1:6)
 {
  str - paste(test,i,sep=.)
  str - matrix(seq(from=1,to=9,by=1),nrow=3,ncol=3) # works, creates 6
 matrices
 }
 pattern - ls(patt='^test\\.[0-9]') # doesn't work variables only exist in
 the loop

 which is why I had:
 subject.data[,,1,1] - data.1   # subject 1 group 1
 subject.data[,,2,1] - data.2   # subject 1 group 2
 subject.data[,,3,1] - data.3   # subject 1 group 3
 subject.data[,,3,2] - data.4   # subject 2 group 3
 subject.data[,,2,2] - data.5   # subject 2 group 2
 subject.data[,,1,2] - data.6   # subject 2 group 1

 to demonstrate all the data was in a meta structure so that I could access
 them later...am I making this more complicated than it needs to be? How can
 I create the matrices inside a loop and have them available outside of it?

 thanks again,

   [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Variance Calculation in R

2008-03-02 Thread Henrique Dallazuanna
Then you can try:

rownames(data.matrix) - as.character(data.matrix$ProbeID)
data.matrix - data.matrix[-1]

as.matrix(apply(data.matrix1, 1, var))

or

out - apply(data.matrix1, 1, var)
data.frame(ProbeID = names(out), Variance = unname(out))

Works for me


On 02/03/2008, Keizer_71 [EMAIL PROTECTED] wrote:

 Hi Henrique,

 It is definitely better, but it doesn't show me the ProbeID which identify
 the probes name

 Here was the result when i export to excel with your code.

  Variance   
 1 2.425509867 21.6216446425273


 any suggestions?

 thanks,
 Kei


 Keizer_71 wrote:
 
  Hello,
 
  Thanks everyone for helping me with the previous queries.
 
  step 1: Here is the orginal data: short sample
 
  ProbeID Sample_1_D  Sample_1_CSample_2_D   Sample_2_C
  1   224588_at   2.425509867 11.34031409   11.46868531  11.75741478
 
  step 2: i calculate the variance of the sample using this R code
 
  x-1:2
  y-2:141
  data.matrix-data.matrix(data[,y])#create data.matrix
  variableprobe-apply(data.matrix[x,],1,var)
 
  step 3: however, when i type in variableprobe, it gives me this.
 
  1   21.58257457
 
  step 4: I need the code to output this:
 
  ProbeID Variance
  1   224588_at   21.58257457
 
 
  What do i need to do to modify the code to give me better description like
  the one above?
 
  thank.
  Keizer
  
 
 
 

 --
 View this message in context:
 http://www.nabble.com/Variance-Calculation-in-R-tp15790621p15791115.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Imputation Packages

2008-03-02 Thread Dieter Menne
ArunPrasad agurubar at uark.edu writes:

   I am looking for a package in R which can help me in using the
 imputation technique to find the missing values for my regression analysis.

The recommended search for imputation in r-project gave me 400 citations. I
assume you have tried this.

Dieter

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] new to latex to pdf

2008-03-02 Thread Mike Babyak
Dear All,

I'm trying to teach myself latex along with the latex function in Hmisc 
and have hit a roadblock that I can't seem to get around. I'd greatly 
appreciate any pointers.

I'm running R 2.6.0 on Windows XP and have Miktex 2.7 installed. 

I've reproduced the code below, taken from Frank Harrell's latexsummary 
introduction.  My question relates to getting a pdf version of the table 
from the following code.  The pdfs of the graphics (f1a and f1b) 
generated by setpdf are fine.  However, after a number of attempts using 
different methods, I don't seem to be able to get a pdf of the table 
from the s1 object (I see the right table in my previewer just fine).  
I've tried texi2dvi (texfilename, pdf=T) but get only a series of errors 
and an unformatted table in the pdf. 

I'm sure I'm missing some fundamental concept here, but I'm afraid I'm 
not seeing it.  I'd appreciate if anyone could point me in the right 
direction. ( I have no trouble writing my own simple latex code and 
converting it to pdf using pdftex in miktex).

Thanks,

Mike Babyak
Department of Psychiatry and Behavioral Science
Duke University Medical Center

**
Here's the code:

library(Hmisc)
library(survival)
 
getHdata(pbc)
pbc-upData(pbc, moveUnits=TRUE,
labels=c(stage='Histologic Stage\nLudwig Criteria'))

kmsurv - function(S, times) {
f - survfit.km(factor(rep(1,nrow(S))), S)
tt - c(0, f$time)
ss - c(1, f$surv) # add first point to survival curve
approx(tt, ss, xout=times, method='constant', f=0)$y
}
 
describe.survival - function(y) {
km - kmsurv(y, c(2,5))
c('2 Year'=km[1], '5 Year'=km[2], 'Mean, y'=sum(y[,1])/sum(y[,2]))
}

S - with(pbc, Surv(fu.days/365.25, status))
s1 - summary(S ~ age + albumin + ascites + bili + drug + edema + chol,
fun=describe.survival, data=pbc)
 
for(w in 1:2) {
if(w==1) setpdf(f1a,sublines=1,h=5.25) else
setpdf(f1b,sublines=1,h=5)
plot(s1, which=if(w==1)1:2 else 3,
cex.labels=.7, cex.group.labels=.7*1.15, subtitles=T, main='',
pch=if(w==2) 16 else c('2','5'), # 16=solid circle
xlab=if(w==2)'Survival Time' else 'Survival Probability')
dev.off()
}

w - latex(s1, cdec=c(2,2,1), ctable=TRUE, caption='Survival')

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] About R-Project

2008-03-02 Thread Ion Andronache
Hello,
My name is Ion Andronache and I am a candidate for a doctor's degree on
geomorphology in Braila, Romania. I would like to ask for some advice. I
would like to make an analysis on the Danube's flow capacity and to
determine the circles  and periodicity using the Schuster system. I
understood that your soft can do these operations but I don't know how.
Would you be so kind to guide me?
Best wishes,
Ion Andronache.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [OT] normal (as in Guassian)

2008-03-02 Thread Johannes Hüsing
Am 02.03.2008 um 17:44 schrieb Gabor Csardi:

 I'm not a statistician, but do i remember well that among all
 distributions with a given mean and variance, the normal distribution
 has the highest entropy? This is good enough for me to call it
 normal

There's more. Among all rotation-symmetric distributions,
the standard bivariate normal is the only one where x and
y are independent.

Also, the formula for the standard normal distribution is
the only one that is its own Fourier transform. So, if we
assume the same distribution for a momentum and
a location of a physical object, according to Heisenberg's
Law it has to be the normal.

Whereas we ought to be wary about assumption of normality
for the distribution of phenomena in nature, the normal and
its henchmen play a defendable role when describing summaries
of phenomena, like arithmetic means. I'd even go as far as
buy into Youden's hype described in that Kruskal and Stigler
essay.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Need help to locate my mistake

2008-03-02 Thread Louise Hoffman
Dear readers

I would like to make General Linear Model (GLM) for the following data set
http://louise.hoffman.googlepages.com/fuel.csv

The code I have written is

fuelData-read.table('fuel.csv',header=TRUE, sep=',')
n-dim(fuelData)[1]
xOnes- matrix(1,nrow=n,ncol=1)
x-cbind(xOnes,fuelData[,3])
y-fuelData[,4]
theta-((t(x)%*%x)^(-1))%*%t(x)%*%y

which gives

 theta
[,1]
[1,] 215.8374077
[2,]   0.1083491

When I do it in Matlab I get theta to be
79.69
0.18

which is correct. ~79 is the crossing of the y-axis.

Have I perhaps written theta wrong? The formula for theta is
(alpha,beta)^T = (x^T * x)^(-1) * x^T * Y

where ^T means transposed.

Can someone see where the mistake is?

Hugs,
Louise

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] summarizing matrix data

2008-03-02 Thread Emilio Gagliardi
Henrique,

Again, thank you very much for your code snippets, I am learning from them,
but they are also creating as many questions as answers...

On Sun, Mar 2, 2008 at 11:48 AM, Henrique Dallazuanna [EMAIL PROTECTED]
wrote:

 Then you can try this:

 apply(array(as.vector(sapply(patt, get)), dim = c(dim(get(patt[1])),
 ngroups, nsubs)), 1:3, mean)


 For create the matrices in a loop one option is:

 lapply(seq(1, 51, by=10), function(x)matrix(seq(x, x+8), nrow=3, ncol=3))


if I use the above code, I get back a list of matrices, which is awesome!
The problem is that your code to get the means doesn't work on it (
apply(array(as.vector(...))...additionally, I'm not creating the data, but
reading it in, file by file and I don't know what group to assign a file
until I open it (group2, group4, group4,group1,group3,group2,group1,etc)

so I have 120 files to open and process and each file can be assigned to 1
of 4 groups(or lists as your code demonstrates)...but I don't know until I
open the file which group hence my loop and meta structure approach.  So I
need to open the file, create a matrix from it (which I have working), store
it along with other data from the same group, and then after I've read all
the files and associated the data with a group, then I can generate the
means per cell.

So I can create 4 lists of matrices, which is fine by me but I don't see how
I extend your code snippets to the case of reading the data from files...I
currently have 1 master matrix which holds all the subject data as I
mentioned in my previous post.
data[3,3,1,nsubjects] represents all the subject data in group 1
data[3,3,2,nsubjects] represents all the subject data in group 2
data[3,3,3,nsubjects] represents all the subject data in group 3

how do i pullout just one group's worth of data and apply the mean function
to each cell ?
group1 - get(data[,,1,] ?
group2 - get(data[,,2,] ?
mean1 - apply(group1,1:3,mean) # mean per cell, so nine means (3 x 3) for
each group...
mean2 - apply(group2,1:3,mean) # mean per cell, so nine means (3 x 3) for
each group...

thanks so much for your patience!
emilio

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Variance Calculation in R

2008-03-02 Thread Keizer_71

unfortunately, it is not showing probeID



Henrique Dallazuanna wrote:
 
 Try this:
 
 write.table(cbind(data.matrix[1], Variance = apply(data.matrix[,-1],
 1, var)),file='file.xls')
 
 
 On 02/03/2008, Keizer_71 [EMAIL PROTECTED] wrote:

 sorry...in step 4-i need the R code to output in this format when i
 export
 to
 excel.

  ProbeID Variance
 1224588_at   21.58257457

 thanks



 Keizer_71 wrote:
 
  Hello,
 
  Thanks everyone for helping me with the previous queries.
 
  step 1: Here is the orginal data: short sample
 
 ProbeID Sample_1_D  Sample_1_CSample_2_D   Sample_2_C
  1  224588_at   2.425509867 11.34031409   11.46868531  11.75741478
 
  step 2: i calculate the variance of the sample using this R code
 
  x-1:2
  y-2:141
  data.matrix-data.matrix(data[,y])#create data.matrix
  variableprobe-apply(data.matrix[x,],1,var)
 
  step 3: however, when i type in variableprobe, it gives me this.
 
  1  21.58257457
 
  step 4: I need the code to output this:
 
 ProbeID Variance
  1  224588_at   21.58257457
 
 
  What do i need to do to modify the code to give me better description
 like
  the one above?
 
  thank.
  Keizer
 
 
 
 

 --
 View this message in context:
 http://www.nabble.com/Variance-Calculation-in-R-tp15790621p15790768.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

 
 
 -- 
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Variance-Calculation-in-R-tp15790621p15792364.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] discrete variable

2008-03-02 Thread Pete Dorothy
Hello,

I am sorry for asking such a basic question. I could not find an answer to
it using google.

I have a discrete variable (a vector x) taking for example the following
values : 0, 3, 4, 3, 15, 5, 6, 5

Is it possible to know how many different values (modalities) it takes ?
Here it takes 6 different values but the length of the vector is 8.

I would like to know if there is a way to get the set of the
modalities {0,3,4,15,5,6} with the number of times each one is taken
{1,2,1,1,2,1}

Thank you very much

P.S. : is there some useful functions for discrete variables ?

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] emacs and R

2008-03-02 Thread John Sorkin
At the suggestion of many people, I have installed emacs on my linux (Fedora 
8.0) computer with the intention of using emacs as window interface to R 
(2.6.0). I have gone though the emacs tutorial and don't see any information 
about how I should use emacs to run R. Can anyone suggest a document that I 
might read? In the past I have used R on a Windows XP system and used the 
built-in windowing interface.
Thank you,
John

John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
Baltimore VA Medical Center GRECC,
University of Maryland School of Medicine Claude D. Pepper OAIC,
University of Maryland Clinical Nutrition Research Unit, and
Baltimore VA Center Stroke of Excellence

University of Maryland School of Medicine
Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524

(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
[EMAIL PROTECTED]
Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] emacs and R

2008-03-02 Thread Louise Hoffman
 At the suggestion of many people, I have installed emacs on my linux (Fedora 
 8.0) computer with the intention of using emacs as window interface to R 
 (2.6.0). I have gone though the emacs tutorial and don't see any information 
 about how I should use emacs to run R. Can anyone suggest a document that I 
 might read? In the past I have used R on a Windows XP system and used the 
 built-in windowing interface.

Download Emacs Speak Statistics which is a LISP package for emacs.
http://ess.r-project.org/

When installed you can e.g.

M-x R Start an R process in Emacs
%
C-c C-c   Sends a Control-C signal to the ESS process.
  This has the effect of aborting the current command.
%
C-c M-b   Send the contents of the edit buffer to the ESS process
  and returns you to the ESS process buffer as well.
%
C-c M-r   Send the text between point and mark to the ESS process and
  returns to the ESS process buffer afterwards.
%
C-c M-j   Send the line containing point to the ESS process, and
  return to the ESS process buffer.
%
C-c C-n   Sends the current line to the ESS process,
  echoing it in the process buffer, and moves point to the
next line.
%
C-M-q Indents each line in the expression.
%
M-;   Indents an existing comment line appropriately, or inserts
  an appropriate comment marker.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] discrete variable

2008-03-02 Thread Henrique Dallazuanna
See

 length(unique(x))
[1] 6

 table(x)

On 02/03/2008, Pete Dorothy [EMAIL PROTECTED] wrote:
 Hello,

 I am sorry for asking such a basic question. I could not find an answer to
 it using google.

 I have a discrete variable (a vector x) taking for example the following
 values : 0, 3, 4, 3, 15, 5, 6, 5

 Is it possible to know how many different values (modalities) it takes ?
 Here it takes 6 different values but the length of the vector is 8.

 I would like to know if there is a way to get the set of the
 modalities {0,3,4,15,5,6} with the number of times each one is taken
 {1,2,1,1,2,1}

 Thank you very much

 P.S. : is there some useful functions for discrete variables ?

   [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] summarizing matrix data

2008-03-02 Thread Henrique Dallazuanna
On 02/03/2008, Emilio Gagliardi [EMAIL PROTECTED] wrote:
 Henrique,

 Again, thank you very much for your code snippets, I am learning from them,
 but they are also creating as many questions as answers...

 On Sun, Mar 2, 2008 at 11:48 AM, Henrique Dallazuanna [EMAIL PROTECTED]
 wrote:

  Then you can try this:
 
  apply(array(as.vector(sapply(patt, get)), dim = c(dim(get(patt[1])),
  ngroups, nsubs)), 1:3, mean)
 
 
  For create the matrices in a loop one option is:
 
  lapply(seq(1, 51, by=10), function(x)matrix(seq(x, x+8), nrow=3, ncol=3))
 

 if I use the above code, I get back a list of matrices, which is awesome!
 The problem is that your code to get the means doesn't work on it (
 apply(array(as.vector(...))...additionally, I'm not creating the data, but
 reading it in, file by file and I don't know what group to assign a file
 until I open it (group2, group4, group4,group1,group3,group2,group1,etc)

 so I have 120 files to open and process and each file can be assigned to 1
 of 4 groups(or lists as your code demonstrates)...but I don't know until I
 open the file which group hence my loop and meta structure approach. So I
 need to open the file, create a matrix from it (which I have working), store
 it along with other data from the same group, and then after I've read all
 the files and associated the data with a group, then I can generate the
 means per cell.

 So I can create 4 lists of matrices, which is fine by me but I don't see how
 I extend your code snippets to the case of reading the data from files...I
 currently have 1 master matrix which holds all the subject data as I
 mentioned in my previous post.
 data[3,3,1,nsubjects] represents all the subject data in group 1
 data[3,3,2,nsubjects] represents all the subject data in group 2
 data[3,3,3,nsubjects] represents all the subject data in group 3

 how do i pullout just one group's worth of data and apply the mean function
 to each cell ?
 group1 - get(data[,,1,] ?

Here, don't needed 'get' :

group1 - data[,,1,]
mean1 - apply(group1, 1:2, mean)

 group2 - get(data[,,2,] ?
 mean1 - apply(group1,1:3,mean) # mean per cell, so nine means (3 x 3) for
 each group...
 mean2 - apply(group2,1:3,mean) # mean per cell, so nine means (3 x 3) for
 each group...

 thanks so much for your patience!
 emilio

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] discrete variable

2008-03-02 Thread Ted Harding
On 02-Mar-08 20:27:20, Pete Dorothy wrote:
 Hello,
 
 I am sorry for asking such a basic question. I could not find
 an answer to it using google.
 
 I have a discrete variable (a vector x) taking for example the
 following values : 0, 3, 4, 3, 15, 5, 6, 5
 
 Is it possible to know how many different values (modalities)
 it takes?
 Here it takes 6 different values but the length of the vector is 8.
 
 I would like to know if there is a way to get the set of the
 modalities {0,3,4,15,5,6} with the number of times each one is
 taken {1,2,1,1,2,1}

This particulat kind of question is very simple:

table(c(0, 3, 4, 3, 15, 5, 6, 5))
# 0  3  4  5  6 15
# 1  2  1  2  1  1 

Note that the first row of the output is simply the column
names, and is not part of the value returned by table() in
this case, which is the vector c(1,2,1,2,1,1) printed in
the second row.

table(c(0, 3, 4, 3, 15, 5, 6, 5))[4]
# 5 
# 2 

table(c(0, 3, 4, 3, 15, 5, 6, 5))[4] + 1.1
#   5 
# 3.1 

sum(table(c(0, 3, 4, 3, 15, 5, 6, 5)))
# [1] 8

Hoping this helps.

 Thank you very much
 
 P.S. : is there some useful functions for discrete variables ?

Many!

Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 02-Mar-08   Time: 20:52:40
-- XFMail --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] discrete variable

2008-03-02 Thread Andrew Robinson
Pete,

try

x - c(0, 3, 4, 3, 15, 5, 6, 5)

table(x)

or

length(table(x))

Cheers

Andrew


On Sun, Mar 02, 2008 at 09:27:20PM +0100, Pete Dorothy wrote:
 Hello,
 
 I am sorry for asking such a basic question. I could not find an answer to
 it using google.
 
 I have a discrete variable (a vector x) taking for example the following
 values : 0, 3, 4, 3, 15, 5, 6, 5
 
 Is it possible to know how many different values (modalities) it takes ?
 Here it takes 6 different values but the length of the vector is 8.
 
 I would like to know if there is a way to get the set of the
 modalities {0,3,4,15,5,6} with the number of times each one is taken
 {1,2,1,1,2,1}
 
 Thank you very much
 
 P.S. : is there some useful functions for discrete variables ?
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Andrew Robinson  
Department of Mathematics and StatisticsTel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to locate my mistake

2008-03-02 Thread Rolf Turner

On 3/03/2008, at 9:18 AM, Louise Hoffman wrote:

 Dear readers

 I would like to make General Linear Model (GLM) for the following  
 data set
 http://louise.hoffman.googlepages.com/fuel.csv

 The code I have written is

 fuelData-read.table('fuel.csv',header=TRUE, sep=',')
 n-dim(fuelData)[1]
 xOnes- matrix(1,nrow=n,ncol=1)
 x-cbind(xOnes,fuelData[,3])
 y-fuelData[,4]
 theta-((t(x)%*%x)^(-1))%*%t(x)%*%y

 which gives

 theta
 [,1]
 [1,] 215.8374077
 [2,]   0.1083491

 When I do it in Matlab I get theta to be
 79.69
 0.18

 which is correct. ~79 is the crossing of the y-axis.

This is certainly ***NOT*** correct. (If you really got those numbers
from Matlab, then Matlab is up to Puttee.)

Have you plotted your data?

(1) Fitting a straight line is ridiculous.

(2) If you are so foolish as to fit a straight line, you get
theta to have entries -4197.96 (intercept) and 2.16 (slope).
The line y = 79.69 + 0.18*x is off the edge of the graph and
does not even appear.

 Have I perhaps written theta wrong?

Yes.  The expression (t(x)%*%x)^(-1) is the matrix of entry
by entry reciprocals of the entries of t(x)%*%x.

You want:

theta - solve(t(x)%*%x))%*%t(x)%*%y


Anyhow, if you're going to use R, why not ***use R***?

fit - lm(fpi ~ rtime,data=fuelData)
theta - coef(fit)

This gives an answer identical to that from the corrected version of
your ``from scratch'' expression.  (That expression, while  
theoretically
correct, is numerically ill-advised.  The cognoscenti use either the
Choleski or the ``qr'' decomposition of t(x)%*%x to effect the  
calculations.
One of these is what is going on in the bowels of lm().  But here I  
speak
of that of which I know little.)

cheers,

Rolf Turner



##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to locate my mistake

2008-03-02 Thread Ted Harding
On 02-Mar-08 20:18:29, Louise Hoffman wrote:
 Dear readers
 
 I would like to make General Linear Model (GLM) for the
 following data set http://louise.hoffman.googlepages.com/fuel.csv
 
 The code I have written is
 
 fuelData-read.table('fuel.csv',header=TRUE, sep=',')
 n-dim(fuelData)[1]
 xOnes- matrix(1,nrow=n,ncol=1)
 x-cbind(xOnes,fuelData[,3])
 y-fuelData[,4]
 theta-((t(x)%*%x)^(-1))%*%t(x)%*%y
 
 which gives
 
 theta
 [,1]
 [1,] 215.8374077
 [2,]   0.1083491
 
 When I do it in Matlab I get theta to be
 79.69
 0.18
 
 which is correct. ~79 is the crossing of the y-axis.
 
 Have I perhaps written theta wrong? The formula for theta is
 (alpha,beta)^T = (x^T * x)^(-1) * x^T * Y
 
 where ^T means transposed.

Unfortunately, x^(-1) is not the inverse of x:

x-matrix(c(2,4,4,5),nrow=2)
x
#  [,1] [,2]
# [1,]24
# [2,]45

x^(-1)
#  [,1] [,2]
# [1,] 0.50 0.25
# [2,] 0.25 0.20

i.e. it is the matrix which you get by applying the operation
(...)^(-1) to each element of x.

In R, the inverse of a non-singular matrix is (somewhat obscurely)
denoted by solve(x):

solve(x)
#[,1]   [,2]
# [1,] -0.833  0.667
# [2,]  0.667 -0.333

solve(x)%*%x
#  [,1] [,2]
# [1,]1 1.110223e-16
# [2,]0 1.00e+00
(Note the slight rounding error); whereas

(x^(-1))%*%x
#  [,1] [,2]
# [1,]  2.0 3.25
# [2,]  1.3 2.00

Best wishes,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 02-Mar-08   Time: 21:05:50
-- XFMail --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] listing components of an object

2008-03-02 Thread Nair, Murlidharan T
Is there a method to list the components of an object, instead of looking at 
the help for that method?  Let me be more clear with an example

data(iris)
  ## tune `svm' for classification with RBF-kernel (default in svm),
  ## using one split for training/validation set

  obj - tune(svm, Species~., data = iris,
  ranges = list(gamma = 2^(-1:1), cost = 2^(2:4)),
  tunecontrol = tune.control(sampling = fix)
 )

  ## alternatively:
  ## obj - tune.svm(Species~., data = iris, gamma = 2^(-1:1), cost = 2^(2:4))

  summary(obj)
  plot(obj)
-
For tune, an object of class tune, including the components:

best.parameters a 1 x k data frame, k number of parameters.
best.performance best achieved performance.
performances if requested, a data frame of all parameter combinations along 
with the corresponding performance results.
train.ind list of index vectors used for splits into training and validation 
sets.
best.model if requested, the model trained on the complete training data using 
the best parameter combination.

I got the above by doing ?tune.

Is there a function that helps be do this?
Thanks ../Murli

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [OT] normal (as in Guassian)

2008-03-02 Thread Ken Knoblauch
Johannes Hüsing johannes at huesing.name writes:

 
 Am 02.03.2008 um 17:44 schrieb Gabor Csardi:
 
  I'm not a statistician, but do i remember well that among all
  distributions with a given mean and variance, the normal distribution
  has the highest entropy? This is good enough for me to call it
  normal
 

 Also, the formula for the standard normal distribution is
 the only one that is its own Fourier transform. So, if we
 assume the same distribution for a momentum and
 a location of a physical object, according to Heisenberg's
 Law it has to be the normal.
 
It's not the only one.  There is also the comb function, an infinite train of
evenly spaced impulse functions that is its own transform, and then there is
abs(x)^-0.5 and sech(x), but I'm just reading out of the appendix of 
Bracewell, 1978, The Fourier Transformation and Its Applications, McGraw-Hill.

best,

Ken

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [PS] discrete variable

2008-03-02 Thread Ben Fairbank
Try table(), with the name of your vector inside the parentheses.

Ben 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Pete Dorothy
Sent: Sunday, March 02, 2008 2:27 PM
To: r-help@r-project.org
Subject: [PS] [R] discrete variable

Hello,

I am sorry for asking such a basic question. I could not find an answer
to
it using google.

I have a discrete variable (a vector x) taking for example the following
values : 0, 3, 4, 3, 15, 5, 6, 5

Is it possible to know how many different values (modalities) it takes ?
Here it takes 6 different values but the length of the vector is 8.

I would like to know if there is a way to get the set of the
modalities {0,3,4,15,5,6} with the number of times each one is taken
{1,2,1,1,2,1}

Thank you very much

P.S. : is there some useful functions for discrete variables ?

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] emacs and R

2008-03-02 Thread Peter Dalgaard
Louise Hoffman wrote:
 At the suggestion of many people, I have installed emacs on my linux (Fedora 
 8.0) computer with the intention of using emacs as window interface to R 
 (2.6.0). I have gone though the emacs tutorial and don't see any information 
 about how I should use emacs to run R. Can anyone suggest a document that I 
 might read? In the past I have used R on a Windows XP system and used the 
 built-in windowing interface.
 

 Download Emacs Speak Statistics which is a LISP package for emacs.
 http://ess.r-project.org/
   
It's easier still (on F8):

yum install emacs-ess

and you may also notice the user-friendly menus supplementing the key 
combinations below. These appear automagically if you are in an R 
interaction buffer, or a .R or .Rout file.

-p
 When installed you can e.g.

 M-x R Start an R process in Emacs
 %
 C-c C-c   Sends a Control-C signal to the ESS process.
   This has the effect of aborting the current command.
 %
 C-c M-b   Send the contents of the edit buffer to the ESS process
   and returns you to the ESS process buffer as well.
 %
 C-c M-r   Send the text between point and mark to the ESS process and
   returns to the ESS process buffer afterwards.
 %
 C-c M-j   Send the line containing point to the ESS process, and
   return to the ESS process buffer.
 %
 C-c C-n   Sends the current line to the ESS process,
   echoing it in the process buffer, and moves point to the
 next line.
 %
 C-M-q Indents each line in the expression.
 %
 M-;   Indents an existing comment line appropriately, or inserts
   an appropriate comment marker.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
   


-- 
   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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] listing components of an object

2008-03-02 Thread Charilaos Skiadas
On Mar 2, 2008, at 4:12 PM, Nair, Murlidharan T wrote:

 Is there a method to list the components of an object, instead of  
 looking at the help for that method?  Let me be more clear with an  
 example

 data(iris)
   ## tune `svm' for classification with RBF-kernel (default in svm),
   ## using one split for training/validation set

   obj - tune(svm, Species~., data = iris,
   ranges = list(gamma = 2^(-1:1), cost = 2^(2:4)),
   tunecontrol = tune.control(sampling = fix)
  )

   ## alternatively:
   ## obj - tune.svm(Species~., data = iris, gamma = 2^(-1:1), cost  
 = 2^(2:4))

   summary(obj)
   plot(obj)
 -
 For tune, an object of class tune, including the components:

 best.parameters a 1 x k data frame, k number of parameters.
 best.performance best achieved performance.
 performances if requested, a data frame of all parameter  
 combinations along with the corresponding performance results.
 train.ind list of index vectors used for splits into training and  
 validation sets.
 best.model if requested, the model trained on the complete training  
 data using the best parameter combination.

 I got the above by doing ?tune.

 Is there a function that helps be do this?

Usually str(obj), or possibly as.list(obj) for many objects, will  
give you the sort of information that I think you want, but what's  
wrong with ?tune ? In other words, why do you want this list?  
Typically, it is advisable that one uses methods to access the  
components of an object, like for instance coef(obj) for the  
coefficients in a model object. This is so that the internal  
representation of an object can change without breaking your code,  
and a host of other reasons.

 Thanks ../Murli

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [OT] normal (as in Guassian)

2008-03-02 Thread Katharine Mullen
There is some information and references regarding the name 'normal' in
the internet article 'Earliest Known Uses of Some of the Words of
Mathematics (N)', http://members.aol.com/jeff570/n.html, by John Aldrich.

It contains the comment, Galton does not explain why he uses the term
normal but the sense of conforming to a norm ( = 'A standard, model,
pattern, type.' (OED)) seems implied.

On Sun, 2 Mar 2008 [EMAIL PROTECTED] wrote:

 Hi Folks,
 Apologies to anyone who'd prefer not to see this query
 on this list; but I'm asking because it is probably the
 forum where I'm most likely to get a good answer!

 I'm interested in the provenance of the name normal
 distribution (for what I'd really prefer to call the
 Gaussian distribution).

 According to Wikipedia, The name normal distribution
 was coined independently by Charles S. Peirce, Francis
 Galton and Wilhelm Lexis around 1875.

 So be it, if that was the case -- but I would like to
 know why they chose the name normal: what did they
 intend to convey?

 As background: I'm reflecting a bit on the usage in
 statistics of everyday language as techincal terms,
 as in significantly different. This, for instance,
 is likely to be misunderstood by the general publidc
 when they encounter statements in the media.

 Likewise, normally distributed would probably be
 interpreted as distributed in the way one would
 normally expect or, perhaps, there was nothing
 unusual about the distribution.

 Comments welcome!
 With thanks,
 Ted.

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 02-Mar-08   Time: 13:04:17
 -- XFMail --

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] emacs and R

2008-03-02 Thread Gavin Simpson
On Sun, 2008-03-02 at 21:45 +0100, Louise Hoffman wrote:
  At the suggestion of many people, I have installed emacs on my linux
 (Fedora 8.0) computer with the intention of using emacs as window
 interface to R (2.6.0). I have gone though the emacs tutorial and
 don't see any information about how I should use emacs to run R. Can
 anyone suggest a document that I might read? In the past I have used R
 on a Windows XP system and used the built-in windowing interface.
 
 Download Emacs Speak Statistics which is a LISP package for emacs.
 http://ess.r-project.org/

On a Fedora 8 box, one can install ess from exiting Fedora package
repositories.

yum install emacs-ess

as root in a terminal (or use Pirut via Applications Menu  Add/Remove
software) to install ESS.

Then follow Louise's crib sheet to start R within Emacs etc.

There is nothing wrong with installing from the tar ball at the ess
homepage, but with the availability of a Fedora package I keep ESS more
up-to-date than I ever did when I had to manually upgrade.

G

 
 When installed you can e.g.
 
 M-x R Start an R process in Emacs
 %
 C-c C-c   Sends a Control-C signal to the ESS process.
   This has the effect of aborting the current command.
 %
 C-c M-b   Send the contents of the edit buffer to the ESS process
   and returns you to the ESS process buffer as well.
 %
 C-c M-r   Send the text between point and mark to the ESS process and
   returns to the ESS process buffer afterwards.
 %
 C-c M-j   Send the line containing point to the ESS process, and
   return to the ESS process buffer.
 %
 C-c C-n   Sends the current line to the ESS process,
   echoing it in the process buffer, and moves point to the
 next line.
 %
 C-M-q Indents each line in the expression.
 %
 M-;   Indents an existing comment line appropriately, or inserts
   an appropriate comment marker.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Recommended Packages

2008-03-02 Thread Murray Jorgensen
Having just update to R 2.6.2 on my old Windows laptop I notice that the 
number of packages is growing exponentially and my usual approach of 
get-em-all may not be viable much longer. Has any thought been given to 
dividing contributed binaries into a recommended set, perhaps a couple 
of hundred, and the remained. That way one could install the recommended 
ones routinely and add in the others as required. Any comments?

Murray Jorgensen

-- 
Dr Murray Jorgensen  http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: [EMAIL PROTECTED]Fax 7 838 4155
Phone  +64 7 838 4773 wkHome +64 7 825 0441Mobile 021 1395 862

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [OT] normal (as in Guassian)

2008-03-02 Thread Ted Harding
Thanks, Katherine! Now I wonder what, in particular, Peirce
might have had in mind (he was a particularly sharp
philosophical thinker, and might be expected to pay attention
to the semantic baggage of what he said).

I'm also enjoying the other delightful OT (= On Tangent)
responses that my query has prompted!

Best wishes to all,
Ted.

On 02-Mar-08 21:19:24, Katharine Mullen wrote:
 There is some information and references regarding the name 'normal' in
 the internet article 'Earliest Known Uses of Some of the Words of
 Mathematics (N)', http://members.aol.com/jeff570/n.html, by John
 Aldrich.
 
 It contains the comment, Galton does not explain why he uses the term
 normal but the sense of conforming to a norm ( = 'A standard, model,
 pattern, type.' (OED)) seems implied.
 
 On Sun, 2 Mar 2008 [EMAIL PROTECTED] wrote:
 
 Hi Folks,
 Apologies to anyone who'd prefer not to see this query
 on this list; but I'm asking because it is probably the
 forum where I'm most likely to get a good answer!

 I'm interested in the provenance of the name normal
 distribution (for what I'd really prefer to call the
 Gaussian distribution).

 According to Wikipedia, The name normal distribution
 was coined independently by Charles S. Peirce, Francis
 Galton and Wilhelm Lexis around 1875.

 So be it, if that was the case -- but I would like to
 know why they chose the name normal: what did they
 intend to convey?

 As background: I'm reflecting a bit on the usage in
 statistics of everyday language as techincal terms,
 as in significantly different. This, for instance,
 is likely to be misunderstood by the general publidc
 when they encounter statements in the media.

 Likewise, normally distributed would probably be
 interpreted as distributed in the way one would
 normally expect or, perhaps, there was nothing
 unusual about the distribution.

 Comments welcome!
 With thanks,
 Ted.

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 02-Mar-08   Time: 13:04:17
 -- XFMail --

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 02-Mar-08   Time: 21:52:20
-- XFMail --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] discrete variable

2008-03-02 Thread David Winsemius
Pete Dorothy [EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]: 

 Hello,
 
 I am sorry for asking such a basic question. I could not find an
 answer to it using google.
 
 I have a discrete variable (a vector x) taking for example the
 following values : 0, 3, 4, 3, 15, 5, 6, 5



 
 Is it possible to know how many different values (modalities) it
 takes ? Here it takes 6 different values but the length of the
 vector is 8. 

Try:

test - c(0, 3, 4, 3, 15, 5, 6, 5)
length(table(test))
#[1] 6


 I would like to know if there is a way to get the set of the
 modalities {0,3,4,15,5,6} with the number of times each one is taken
 {1,2,1,1,2,1}

table(test)
#test
# 0  3  4  5  6 15 
# 1  2  1  2  1  1 


 
 Thank you very much
 
 P.S. : is there some useful functions for discrete variables ?

Yes...

https://home.comcast.net/~lthompson221/Splusdiscrete2.pdf

-- 
David Winsemius

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] help.start() on linux (fedora 8) when firefox alreading running - a way to open a new tab?

2008-03-02 Thread Dale Steele
Using linux fedora 8 (x86_64) I get the following when firefox is
already running.  Is there a way to adjust settings in either R or
firefox to open a new tab when help.start() is invoked?  Thanks.
--Dale

 help.start()
Making links in per-session dir ...
If '/usr/bin/firefox' is already running, it is *not* restarted, and
you must switch to its window.
Otherwise, be patient ...

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Runtime error

2008-03-02 Thread Gwénaël Leday
Hi everybody!

I try to implements Self-Organizing Maps with R and the Kohonen package.
I have made an algorithm that try differents width and height. For each
step, Silhouette index, Davies-Bouldin index and Dunn index are computed.
However, there is always after severals minutes a *Runtime error* appears on
the window:

Microsoft visual c++ runtime library
this application has requested the runtime to terminate 
or
R for Windows GUI front-end has encountered a problem and needs to close.
We are sorry for the inconvenience.

it happens also that the window disppeared without message error

Please, if you have already see this problem or if you understand it and
know the solution, please contact me...


code:

results.som - matrix(NA, 7, 7)
results.sil - matrix(NA, 7, 7)
results.dbi - matrix(NA, 7, 7)
results.dun - matrix(NA, 7, 7)

for (i in 8:14){
 for (j in 8:14){
  # SOM with Kohonen package
  som - som(data.scaled, grid = somgrid(i, j, hexagonal),
  radius=j, rlen=1000)

  # Summary SOM
  results.som[i-7,j-7] - mean(som$distances)

  # Indexes
  results.sil[i-7,j-7] - summary(silhouette(som$unit.classif,
dist))$avg.width
  results.dbi[i-7,j-7] - index.DB(species.data,som$unit.classif)$DB
  results.dun[i-7,j-7] - dunn(dist, som$unit.classif)
 }
}




-- 
Gwénaël Leday
Bio-Protection and Ecology Division
Lincoln University
New Zealand
[EMAIL PROTECTED]

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] plotting to stdout (while reading from stdin?)

2008-03-02 Thread Gene Selkov
Hi Dirk,

I didn't at first pay attention to your comment about littler, as my 
original problem of plotting to stdout was solved. But it was just part of 
the larger problem: I actually need to be piping the data with the code 
for making the picture in, and getting the picture out without opening any 
files. This is to be run in a server environment, where the use of temp 
files is not really acceptable.

Having solved half of the problem, I feel cornered again, because I 
haven't found a nice way of mixing code and data in R.

I am aware that this issue was brought up before; I am not sure I like the 
solutions suggested, because they involve the R language parsing and 
interpreting for each data row -- if I understand correctly.

   http://tolstoy.newcastle.edu.au/R/help/03a/6750.html

Are these solutions the best currently available? That thread is almost 5 
years old now.

Let me give you an example of what I would like to be possible:

In postgres, I can read this from stdin:

CREATE TABLE remark (
  case smallint,
  text text
);

COPY remark (case, text) FROM stdin;
877 lymph node biopsy
909 Unresectable mass in the body of the pancreas
\.

... more SQL 

It allows the code and input chunks to be mixed, because the 
input for stdin is always terminated by a special token, '\.', and so the 
parser can skip the data chunks without interpreting them.

Almost similarly, perl has the __DATA__ token, that allows a portion of 
text within a program to be treated as stdin.

I wonder whether anything like this is possible in R or littler.


Thanks,

--Gene


On Fri, 7 Sep 2007, Dirk Eddelbuettel wrote:

 On Fri, Sep 07, 2007 at 02:27:00PM -0400, Duncan Murdoch wrote:
 On 9/7/2007 2:15 PM, Gene Selkov wrote:
 Thanks a ton, Duncan!

 So I have verified that this line works:

echo postscript(file=\\, command=\cat\); plot(0) | r --vanilla 
 --slave

 Wonderful! (albeit a little unobvious)

 I would include an explicit dev.off() after the plotting; I'm not sure
 all devices guarantee a clean shutdown when R quits.

 And for the record, both littler and Rscript can do that without the
 need for double quotes, at least under Linux.  E.g. both

 $ r -e 'postscript(file=, command=cat); plot(0)' | head
 $ Rscript -e 'postscript(file=, command=cat); plot(0)' | head

 provide the same output (of the beginning of the postscript output).
 Our r is as usual somewhat faster, not that this matters in this
 non-repeat context.

 Dirk

 -- 
 Three out of two people have difficulties with fractions.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Recommended Packages

2008-03-02 Thread Gavin Simpson
On Mon, 2008-03-03 at 10:52 +1300, Murray Jorgensen wrote:
 Having just update to R 2.6.2 on my old Windows laptop I notice that the 
 number of packages is growing exponentially and my usual approach of 
 get-em-all may not be viable much longer. Has any thought been given to 
 dividing contributed binaries into a recommended set, perhaps a couple 
 of hundred, and the remained. That way one could install the recommended 
 ones routinely and add in the others as required. Any comments?
 
 Murray Jorgensen

Hi Murray,

What is one person's recommended set might not correspond with the
recommended set of another nor that of a third party.

Grouping contributed packages into topics or themes might be a more
appropriate classification, and to that end we have CRAN Task Views
(thanks to Achim Zeileis and Kurt Hornik and their band of merry
CTV-maintainers). There are some 15 of these views now available. Using
the tools in the ctv package a user can install these groupings of
packages. Do these Task Views meet, or go some way towards, your goal?

See:

http://cran.r-project.org/web/views/

HTH

G
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to locate my mistake

2008-03-02 Thread Louise Hoffman
  This is certainly ***NOT*** correct. (If you really got those numbers
  from Matlab, then Matlab is up to Puttee.)

It was my mistake =) I had calculated the straight line so the edge of
the plot was the y-axis =)

  Have you plotted your data?

 (1) Fitting a straight line is ridiculous.

Yes, I guess we have to realise that in the project, and explain why
it is not good enough =) Next step is to use exponential smoothing =)

 (2) If you are so foolish as to fit a straight line, you get
 theta to have entries -4197.96 (intercept) and 2.16 (slope).
 The line y = 79.69 + 0.18*x is off the edge of the graph and
 does not even appear.

It was clearly a bad mistake of mine! =(

 Yes.  The expression (t(x)%*%x)^(-1) is the matrix of entry
 by entry reciprocals of the entries of t(x)%*%x.

 You want:

 theta - solve(t(x)%*%x))%*%t(x)%*%y

Thanks =)

 Anyhow, if you're going to use R, why not ***use R***?

 fit - lm(fpi ~ rtime,data=fuelData)
 theta - coef(fit)

 This gives an answer identical to that from the corrected version of
 your ``from scratch'' expression.  (That expression, while
  theoretically
 correct, is numerically ill-advised.  The cognoscenti use either the
 Choleski or the ``qr'' decomposition of t(x)%*%x to effect the
  calculations.

This is great stuff!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] About R-Project

2008-03-02 Thread Spencer Graves
  I'm not familiar with the Schuster system, but 
RSiteSearch(Schuster) produced 34 hits and RSiteSearch(river, fun) 
produced 133 for me just now. 

  If this does not lead you to an answer to your question, PLEASE do 
read the posting guide http://www.R-project.org/posting-guide.html and 
provide commented, minimal, self-contained, reproducible code.

  Spencer

Ion Andronache wrote:
 Hello,
 My name is Ion Andronache and I am a candidate for a doctor's degree on
 geomorphology in Braila, Romania. I would like to ask for some advice. I
 would like to make an analysis on the Danube's flow capacity and to
 determine the circles  and periodicity using the Schuster system. I
 understood that your soft can do these operations but I don't know how.
 Would you be so kind to guide me?
 Best wishes,
 Ion Andronache.

   [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] insert vector image into a plot

2008-03-02 Thread William Morris
How can I insert a vector image in svg or pdf format into a plot.  
Basically i need the equivalent of what the 'pixmap' package does for  
bitmap images.

Cheers,

Will Morris

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] emacs and R

2008-03-02 Thread Wensui Liu
Hi, John,
you don't have to switch to linux in order to use ess + emacs with R.
just follow the installation instruction of ess and it will take you 5
minutes at most. i also feel that xemacs seems more friendly than
gnuemacs for windows user.

On Sun, Mar 2, 2008 at 3:40 PM, John Sorkin [EMAIL PROTECTED] wrote:
 At the suggestion of many people, I have installed emacs on my linux (Fedora 
 8.0) computer with the intention of using emacs as window interface to R 
 (2.6.0). I have gone though the emacs tutorial and don't see any information 
 about how I should use emacs to run R. Can anyone suggest a document that I 
 might read? In the past I have used R on a Windows XP system and used the 
 built-in windowing interface.
  Thank you,
  John

  John Sorkin M.D., Ph.D.
  Chief, Biostatistics and Informatics
  Baltimore VA Medical Center GRECC,
  University of Maryland School of Medicine Claude D. Pepper OAIC,
  University of Maryland Clinical Nutrition Research Unit, and
  Baltimore VA Center Stroke of Excellence

  University of Maryland School of Medicine
  Division of Gerontology
  Baltimore VA Medical Center
  10 North Greene Street
  GRECC (BT/18/GR)
  Baltimore, MD 21201-1524

  (Phone) 410-605-7119
  (Fax) 410-605-7913 (Please call phone number above prior to faxing)
  [EMAIL PROTECTED]
  Confidentiality Statement:
  This email message, including any attachments, is for th...{{dropped:6}}

  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.




-- 
===
WenSui Liu
ChoicePoint Precision Marketing
Phone: 678-893-9457
Email : [EMAIL PROTECTED]
Blog   : statcompute.spaces.live.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Need help to locate my mistake

2008-03-02 Thread Rolf Turner

On 3/03/2008, at 1:58 PM, Louise Hoffman wrote:

 What if I need to calculate the variance for the fuel data?

 Are there a 'R' way to do that?

 I have derived
 variance = (Y-x*theta)^T * (Y - x*theta) / (n-p)

This should be (something like)

tr((Y - X%*%theta))%*%(Y-X%*%theta)/(n-p)

where X is your design matrix.

To get the information in R:

fit - lm(fpi ~ rtime,data=fuelData)
summary(fit)

This tells you the residual standard error (standard deviation) is
7.681.  Typing

summary(fit)$sigma

gives the answer to more decimal places --- 7.681288.

The residual variance can of course be obtained by

summary(fit)$sigma^2

Note that the name ``sigma'' is bad --- this terminology should
be reserved for population quantities.  What we have is ``sigma-hat'',
an *estimate* of sigma.

Note also that for your fuel data the residual variance is pretty
much meaningless since your model is highly inappropriate for these  
data.

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] insert vector image into a plot

2008-03-02 Thread William Morris
Thanks Paul.
As always you spend an hour searching and find nothing, if i'd used  
the search term import instead of insert I would have found it in  
2 secs.
Lesson learnt, again.

Cheers,

Will Morris

On 03/03/2008, at 12:50 PM, Paul Murrell wrote:

 Hi


 William Morris wrote:
 How can I insert a vector image in svg or pdf format into a plot.
 Basically i need the equivalent of what the 'pixmap' package does for
 bitmap images.


 'grImport'

 See ...
 http://cran.r-project.org/web/packages/grImport/index.html
 http://www.stat.auckland.ac.nz/~paul/Talks/import.pdf

 Paul


 Cheers,

 Will Morris

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

 -- 
 Dr Paul Murrell
 Department of Statistics
 The University of Auckland
 Private Bag 92019
 Auckland
 New Zealand
 64 9 3737599 x85392
 [EMAIL PROTECTED]
 http://www.stat.auckland.ac.nz/~paul/


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R data Export to Excel

2008-03-02 Thread Keizer_71

Here is my R Code

x-1:2
y-2:141
data.matrix-data.matrix(data[,y])#create data.matrix
variableprobe-apply(data.matrix[x,],1,var)
variableprobe #output variance across probesets 
hist(variableprobe) #displaying histogram of variableprobe
write.table(cbind(data[1],
Variance=apply(data[,y],1,var)),file='c://variance.csv')
#export as a .csv file. 

Output in Excel
all in 1 column.

ProbeID Variance
1 224588_at 21.5825745738848

How do i separate them so that i can have three columns

 ProbeID  Variance
1   224588_at   21.582.

thanks,
Kei


-- 
View this message in context: 
http://www.nabble.com/R-data-Export-to-Excel-tp15796903p15796903.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] glm: offset

2008-03-02 Thread John Sorkin
R 2.6.0
Windows XP

A question about running a generalized linear model.

I am running a glm with
(1) a poisson distribution and a log link:
   family=poisson(link = log)
and an offset.
I would like to know if I should express the offset as the log of the offset 
value, i.e.
offset=log(NumUniqPt)
or as:
offset=NumUniqPt

I suspect I need to use the log, bu t I can't find any discussion of this in 
MASS 1994 or on the man page for glm.
Thanks 
John


John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R data Export to Excel

2008-03-02 Thread jim holtman
If you are asking how to convert to multiple columns in Excel, look at
the text to column option in I think the data tab.

On Sun, Mar 2, 2008 at 9:59 PM, Keizer_71 [EMAIL PROTECTED] wrote:

 Here is my R Code

 x-1:2
 y-2:141
 data.matrix-data.matrix(data[,y])#create data.matrix
 variableprobe-apply(data.matrix[x,],1,var)
 variableprobe #output variance across probesets
 hist(variableprobe) #displaying histogram of variableprobe
 write.table(cbind(data[1],
 Variance=apply(data[,y],1,var)),file='c://variance.csv')
 #export as a .csv file.

 Output in Excel
 all in 1 column.

 ProbeID Variance
 1 224588_at 21.5825745738848

 How do i separate them so that i can have three columns

 ProbeID  Variance
 1   224588_at   21.582.

 thanks,
 Kei


 --
 View this message in context: 
 http://www.nabble.com/R-data-Export-to-Excel-tp15796903p15796903.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] unable to start device PNG and unable to open connection to X11 display

2008-03-02 Thread Ng Stanley
Hi,

I have installed R on a computational cluster, and am using putty to access
R. Please help on how to solve the problem of saving png files.

 png(file=myplot.png, bg=transparent)
Error in X11(paste(png::, filename, sep = ), width, height, pointsize,
:
unable to start device PNG
In addition: Warning message:
unable to open connection to X11 display ''

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] glm: offset

2008-03-02 Thread Simon Blomberg
Yes, use the log. I've had the same problem in the past, too. Try it on
a toy example to confirm it for yourself.

Cheers,

Simon.

On Sun, 2008-03-02 at 22:01 -0500, John Sorkin wrote:
 R 2.6.0
 Windows XP
 
 A question about running a generalized linear model.
 
 I am running a glm with
 (1) a poisson distribution and a log link:
family=poisson(link = log)
 and an offset.
 I would like to know if I should express the offset as the log of the offset 
 value, i.e.
 offset=log(NumUniqPt)
 or as:
 offset=NumUniqPt
 
 I suspect I need to use the log, bu t I can't find any discussion of this in 
 MASS 1994 or on the man page for glm.
 Thanks 
 John
 
 
 John Sorkin M.D., Ph.D.
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)
 
 Confidentiality Statement:
 This email message, including any attachments, is for th...{{dropped:6}}
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R data Export to Excel

2008-03-02 Thread Wensui Liu
hi,
did you try write.xls in xlsReadWrite package?


On Sun, Mar 2, 2008 at 9:59 PM, Keizer_71 [EMAIL PROTECTED] wrote:

  Here is my R Code

  x-1:2
  y-2:141
  data.matrix-data.matrix(data[,y])#create data.matrix
  variableprobe-apply(data.matrix[x,],1,var)
  variableprobe #output variance across probesets
  hist(variableprobe) #displaying histogram of variableprobe
  write.table(cbind(data[1],
  Variance=apply(data[,y],1,var)),file='c://variance.csv')
  #export as a .csv file.

  Output in Excel
  all in 1 column.

  ProbeID Variance
  1 224588_at 21.5825745738848

  How do i separate them so that i can have three columns

  ProbeID  Variance
  1   224588_at   21.582.

  thanks,
  Kei


  --
  View this message in context: 
 http://www.nabble.com/R-data-Export-to-Excel-tp15796903p15796903.html
  Sent from the R help mailing list archive at Nabble.com.

  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.




-- 
===
WenSui Liu
ChoicePoint Precision Marketing
Phone: 678-893-9457
Email : [EMAIL PROTECTED]
Blog   : statcompute.spaces.live.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R data Export to Excel

2008-03-02 Thread Christophe Lo
thanks for your response. How do i install it? I try looking at the manual
it doesn't seem indicate any installation instruction. I also download a
windows version but it doesn't have an exe file.

http://cran.r-project.org/web/packages/xlsReadWrite/index.html

Newbie,
Kei


On 3/3/08, Wensui Liu [EMAIL PROTECTED] wrote:

 hi,
 did you try write.xls in xlsReadWrite package?


 On Sun, Mar 2, 2008 at 9:59 PM, Keizer_71 [EMAIL PROTECTED] wrote:
 
   Here is my R Code
 
   x-1:2
   y-2:141
   data.matrix-data.matrix(data[,y])#create data.matrix
   variableprobe-apply(data.matrix[x,],1,var)
   variableprobe #output variance across probesets
   hist(variableprobe) #displaying histogram of variableprobe
   write.table(cbind(data[1],
   Variance=apply(data[,y],1,var)),file='c://variance.csv')
   #export as a .csv file.
 
   Output in Excel
   all in 1 column.
 
   ProbeID Variance
   1 224588_at 21.5825745738848
 
   How do i separate them so that i can have three columns
 
   ProbeID  Variance
   1   224588_at   21.582.
 
   thanks,
   Kei
 
 
   --
   View this message in context:
 http://www.nabble.com/R-data-Export-to-Excel-tp15796903p15796903.html
   Sent from the R help mailing list archive at Nabble.com.
 
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
 



 --
 ===
 WenSui Liu
 ChoicePoint Precision Marketing
 Phone: 678-893-9457
 Email : [EMAIL PROTECTED]
 Blog   : statcompute.spaces.live.com
 ===




-- 
Christophe Lo
(078) 8275 7029
[EMAIL PROTECTED]

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R data Export to Excel

2008-03-02 Thread Wensui Liu
i think you simply install it in the way you install other R packages.

On Sun, Mar 2, 2008 at 10:40 PM, Christophe Lo [EMAIL PROTECTED] wrote:
 thanks for your response. How do i install it? I try looking at the manual
 it doesn't seem indicate any installation instruction. I also download a
 windows version but it doesn't have an exe file.

 http://cran.r-project.org/web/packages/xlsReadWrite/index.html

 Newbie,
 Kei




 On 3/3/08, Wensui Liu [EMAIL PROTECTED] wrote:
  hi,
  did you try write.xls in xlsReadWrite package?
 
 
  On Sun, Mar 2, 2008 at 9:59 PM, Keizer_71 [EMAIL PROTECTED] wrote:
  
Here is my R Code
  
x-1:2
y-2:141
data.matrix-data.matrix(data[,y])#create data.matrix
variableprobe-apply(data.matrix[x,],1,var)
variableprobe #output variance across probesets
hist(variableprobe) #displaying histogram of variableprobe
write.table(cbind(data[1],
Variance=apply(data[,y],1,var)),file='c://variance.csv')
#export as a .csv file.
  
Output in Excel
all in 1 column.
  
ProbeID Variance
1 224588_at 21.5825745738848
  
How do i separate them so that i can have three columns
  
ProbeID  Variance
1   224588_at   21.582.
  
thanks,
Kei
  
  
--
View this message in context:
 http://www.nabble.com/R-data-Export-to-Excel-tp15796903p15796903.html
Sent from the R help mailing list archive at Nabble.com.
  
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
  
 
 
 
  --
  ===
  WenSui Liu
  ChoicePoint Precision Marketing
  Phone: 678-893-9457
  Email : [EMAIL PROTECTED]
  Blog   : statcompute.spaces.live.com
  ===
 



 --
 Christophe Lo
 (078) 8275 7029
 [EMAIL PROTECTED]



-- 
===
WenSui Liu
ChoicePoint Precision Marketing
Phone: 678-893-9457
Email : [EMAIL PROTECTED]
Blog   : statcompute.spaces.live.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] plotting to stdout (while reading from stdin?)

2008-03-02 Thread Gene Selkov


On Sun, 2 Mar 2008, Gabor Grothendieck wrote:

 You can do this:

 Lines - A,B
 1,2
 3,4
 DF - read.csv(textConnection(Lines))

 which is slightly simpler than the examples there.

Thank you Gabor,

I made it even simpler by replacing the Lines object with a string 
contstant.

It works perfectly well for me.

Cheers,

--Gene

 On Sun, Mar 2, 2008 at 5:59 PM, Gene Selkov [EMAIL PROTECTED] wrote:
 Hi Dirk,

 I didn't at first pay attention to your comment about littler, as my
 original problem of plotting to stdout was solved. But it was just part of
 the larger problem: I actually need to be piping the data with the code
 for making the picture in, and getting the picture out without opening any
 files. This is to be run in a server environment, where the use of temp
 files is not really acceptable.

 Having solved half of the problem, I feel cornered again, because I
 haven't found a nice way of mixing code and data in R.

 I am aware that this issue was brought up before; I am not sure I like the
 solutions suggested, because they involve the R language parsing and
 interpreting for each data row -- if I understand correctly.

   http://tolstoy.newcastle.edu.au/R/help/03a/6750.html

 Are these solutions the best currently available? That thread is almost 5
 years old now.

 Let me give you an example of what I would like to be possible:

 In postgres, I can read this from stdin:

CREATE TABLE remark (
  case smallint,
  text text
);

COPY remark (case, text) FROM stdin;
877 lymph node biopsy
909 Unresectable mass in the body of the pancreas
\.

... more SQL 

 It allows the code and input chunks to be mixed, because the
 input for stdin is always terminated by a special token, '\.', and so the
 parser can skip the data chunks without interpreting them.

 Almost similarly, perl has the __DATA__ token, that allows a portion of
 text within a program to be treated as stdin.

 I wonder whether anything like this is possible in R or littler.


 Thanks,

 --Gene


 On Fri, 7 Sep 2007, Dirk Eddelbuettel wrote:

 On Fri, Sep 07, 2007 at 02:27:00PM -0400, Duncan Murdoch wrote:
 On 9/7/2007 2:15 PM, Gene Selkov wrote:
 Thanks a ton, Duncan!

 So I have verified that this line works:

echo postscript(file=\\, command=\cat\); plot(0) | r --vanilla 
 --slave

 Wonderful! (albeit a little unobvious)

 I would include an explicit dev.off() after the plotting; I'm not sure
 all devices guarantee a clean shutdown when R quits.

 And for the record, both littler and Rscript can do that without the
 need for double quotes, at least under Linux.  E.g. both

 $ r -e 'postscript(file=, command=cat); plot(0)' | head
 $ Rscript -e 'postscript(file=, command=cat); plot(0)' | head

 provide the same output (of the beginning of the postscript output).
 Our r is as usual somewhat faster, not that this matters in this
 non-repeat context.

 Dirk

 --
 Three out of two people have difficulties with fractions.


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R function to convert a number to text

2008-03-02 Thread lin tang
hi, Dear R users -

I wonder is there a written R function to convert a number to a text, say 
convert 1 to one , 100  to one hundred. I know in xls. has such a function 
BAHTTEXT, does anybody know is there a similar function in R ? Thanks.

Lin

   
-

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] insert vector image into a plot

2008-03-02 Thread Paul Murrell
Hi


William Morris wrote:
 How can I insert a vector image in svg or pdf format into a plot.  
 Basically i need the equivalent of what the 'pixmap' package does for  
 bitmap images.


'grImport'

See ...
http://cran.r-project.org/web/packages/grImport/index.html
http://www.stat.auckland.ac.nz/~paul/Talks/import.pdf

Paul


 Cheers,
 
 Will Morris
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Constrained regression

2008-03-02 Thread Carlos Alzola
Dear list members,

I am trying to get information on how to fit a linear regression with
constrained parameters. Specifically, I have 8 predictors , their
coeffiecients should all be non-negative and add up to 1. I understand it is
a quadratic programming problem but I have no experience in the subject. I
searched the archives but the results were inconclusive. 

Could someone provide suggestions and references to the literature, please?

Thank you very much.

Carlos

Carlos Alzola
[EMAIL PROTECTED]
(703) 242-6747 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] handling big data set in R

2008-03-02 Thread shu zhang
Hello R users,

I'm wondering whether it is possible to manage big data set in R? I
have a data set with  3 million rows and 3 columns (X,Y,Z), where X is
the group id. For each X, I need to run 2 regression on the submatrix.
I used the function split:

datamatrix-read.csv(datas.csv, header=F, sep=,)
dim(datamatrix)
# [1] 2980523  3
names(datamatrix)-c(X,Y,Z)

attach(datamatrix)

subX-split(X, X)
subY-split(Y,X)
subZ-split(Z,X)
n-length(subdata)  ### number of groups
s1-s2-rep(NA, n)  ### vector to store the regression slope

for (i in 1:n){
   a-table(Y[[i]])
   table.x-as.numeric(names(a))
   table.y-as.numeric(a)
   fit1-lm(table.y~table.x)# find the slope of the histogram of y
   s1[i]-fit$coefficients[2]

   fit2-lm(subY[[i]]~subZ[[i]])  ### regress y on z
   s2[i]-fit$coefficients[2]
}


But my R died before completing the loop... (I've thought about doing
it in SAS, but I don't know how to write a loop combined with a PROC
REG...)

One thing that might be helpful is that my data set has already been
sorted based on X. I don't know whether this can be any helpful for
managing the dataset.

Any suggestion would be appreciated!


Thanks!
-Shu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] handling big data set in R

2008-03-02 Thread shu zhang
Hello R users,

I'm wondering whether it is possible to manage big data set in R? I
have a data set with  3 million rows and 3 columns (X,Y,Z), where X is
the group id. For each X, I need to run 2 regression on the submatrix.
I used the function split:

datamatrix-read.csv(datas.csv, header=F, sep=,)
dim(datamatrix)
# [1] 2980523  3
names(datamatrix)-c(X,Y,Z)

attach(datamatrix)

subX-split(X, X)
subY-split(Y,X)
subZ-split(Z,X)
n-length(subdata)  ### number of groups
s1-s2-rep(NA, n)  ### vector to store the regression slope

for (i in 1:n){
  a-table(Y[[i]])
  table.x-as.numeric(names(a))
  table.y-as.numeric(a)
  fit1-lm(table.y~table.x)# find the slope of the histogram of y
  s1[i]-fit$coefficients[2]

  fit2-lm(subY[[i]]~subZ[[i]])  ### regress y on z
  s2[i]-fit$coefficients[2]
}


But my R died before completing the loop... (I've thought about doing
it in SAS, but I don't know how to write a loop combined with a PROC
REG...)

One thing that might be helpful is that my data set has already been
sorted based on X. I don't know whether this can be any helpful for
managing the dataset.

Any suggestion would be appreciated!


Thanks!
-Shu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem with PCA

2008-03-02 Thread Richard Rowe
This is a homework problem.  I know how to do a PCA, you need to learn.
I suggest you visit your textbook, then check the documentation for R's 
various PCA implementations to work out how to effect the analysis.



phthao05 wrote:
 I have an exercise. With 3 kinds of yohourt a,b,c. There are 25
 participatients estimate 3 norms: taste (va,vb,vc), structure (ca,cb,cc) and
 price (ga,gb,gc) and give the mark from 1 to 5. I don't know how to PCA this
 data. Please help me!
 I attached the data file follow:
 VaVb  Vc  Ca  Cb  Cc  Ga  Gb  Gc
 4 2   4   5   5   5   4   4   2
 2 2   4   3   2   5   4   5   1
 2 2   1   2   3   3   3   1   4
 1 1   2   2   3   3   4   3   2
 3 4   4   4   3   1   2   1   2
 1 1   1   1   2   4   3   2   4
 4 4   2   2   2   1   2   1   3
 2 3   3   3   4   3   1   1   1
 4 5   1   3   3   2   4   2   4
 2 2   5   1   1   3   2   3   3
 4 2   4   5   3   3   4   4   4
 3 4   2   1   2   2   1   2   4
 1 2   1   2   3   3   3   1   4
 3 4   1   1   2   1   2   3   3
 5 4   3   4   3   1   1   1   2
 4 4   2   2   2   1   4   2   4
 2 2   1   1   2   4   3   2   4
 3 1   3   4   2   5   3   4   1
 1 1   2   2   3   3   4   3   2
 2 3   4   3   4   4   4   3   1
 2 3   3   3   4   3   1   1   1
 4 3   1   1   1   2   2   3   3
 1 1   1   1   2   4   3   2   4
 3 4   2   1   2   2   3   1   3
 3 4   2   1   2   2   1   2   4
  
   


-- 
Dr Richard Rowe
Zoology  Tropical Ecology
School of Marine  Tropical Biology
James Cook University
Townsville 4811
AUSTRALIA

ph +61 7 47 81 4851
fax +61 7 47 25 1570
JCU has CRICOS Provider Code 00117J

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] unable to start device PNG and unable to open connection to X11 display

2008-03-02 Thread Prof Brian Ripley
Please consult the help page for png.

On Mon, 3 Mar 2008, Ng Stanley wrote:

 Hi,

 I have installed R on a computational cluster, and am using putty to access
 R. Please help on how to solve the problem of saving png files.

 png(file=myplot.png, bg=transparent)
 Error in X11(paste(png::, filename, sep = ), width, height, pointsize,
 :
unable to start device PNG
 In addition: Warning message:
 unable to open connection to X11 display ''

   [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


-- 
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R data Export to Excel

2008-03-02 Thread Hans-Peter

 it doesn't seem indicate any installation instruction.
 http://cran.r-project.org/web/packages/xlsReadWrite/index.html


As  Wensui Liu already mentioned, installation is the same as with other
packages: In the RGui menu select Packages-Install Packages...-(Select a
CRAN mirror)-(Select the package)-done.

Best regards,
Hans-Peter

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Attempting to connect to an Empress RDBMS via RODBC 1.2-3 causes R 2.6.2.pat to segfault

2008-03-02 Thread Michael Manning
Hi

I've experienced some unpleasant behaviour while attempting to connect to an 
Empress 8.6.2 RDBMS via RODBC 1.2-3 and a freshly minted R 2.6.2.pat on a SLED 
linux system where a call to odbcConnect() to initiate the odbc connection 
causes R 2.6.2.pat to segfault.

The odbcConnect call is

CHANNEL - odbcConnect(myEmpressDB, uid=myusername, pwd=mysecurepassword, 
believeNRows=FALSE)

where myEmpressDB is an apparently correctly configured ODBC datasource 
pointing at the Empress RDBMS I wish to access on my system. The R version data 
for my system are

platform   i686-pc-linux-gnu  
arch   i686   
os linux-gnu  
system i686, linux-gnu
status Patched
major  2  
minor  6.2
year   2008   
month  03 
day02 
svn rev44661  
language   R  
version.string R version 2.6.2 Patched (2008-03-02 r44661)

All a bit surprising (to me, at least) as: (i) testing connections to the 
Empress datasource with isql on my SLED linux system is successful, suggesting 
to me that the Empress driver and the datasource are correctly configured; (ii) 
I am able to successfully initiate a connection to a non-Empress odbc 
datasource (postgres and mysql databases) on my SLED linux system within R and 
to send and retrieve data from these; and (iii) an analogous setup (R, Empress 
odbc driver, datasource,...) on a windows XP system that I have access to works 
flawlessly.

Any suggestions about how to proceed?

Thanks muchly,

Michael







   _  



begin:vcard
fn:Michael J. Manning
n:Manning;Michael
org:National Institute of Water and Atmospheric Research (NIWA);Inshore and 
Pelagic Fisheries
adr:295-301 Evans Bay Parade, Kilbirnie;;Private Bag 14901;Wellington;;;New 
Zealand
email;internet:[EMAIL PROTECTED]
title:Scientist
tel;work:+64 (0)4 386 0851
tel;fax:+64 (0)4 386 0574
x-mozilla-html:FALSE
url:http://www.niwascience.co.nz
version:2.1
end:vcard

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Formating a zoo dataset .

2008-03-02 Thread Megh Dal
Suppose I have following dataset :
   head(data1)
  Date  Return
1 03/31/00  0.14230650
2 04/28/00 -0.03276228
3 05/31/00 -0.06527890
4 06/30/00 -0.04999873
5 07/31/00 -0.01447902
6 08/31/00  0.22265729

  Now I convert it to zoo object :
   
   data11 = zoo(data1[,2], as.Date(data1[,1], format=%m/%d/%y))
   head(data11)
 2000-03-31  2000-04-28  2000-05-31  2000-06-30  2000-07-31  2000-08-31 
 0.14230650 -0.03276228 -0.06527890 -0.04999873 -0.01447902  0.22265729 
   
  Clearly those are monthly data. Therefore I want to convert it to mm-yy 
format. I used following code :
  data111 = zoo(coredata(data11), format(index(data11), %m/%y))
   
  However what I got is that :
   head(data111)
   01/0101/0201/0301/0401/0501/06 
-0.00139 -0.016274826 -0.047707664  0.001104362 -0.077961541  0.017637141 
 tail(data111)
   12/0212/0312/0412/0512/0612/07 
 0.058660676 -0.018067833 -0.055569851  0.007142888  0.051162052  0.052643733 

  It is evident that month order has been changed. Can anyone here tell me how 
to get correct order like :
   
  01/01, 02/01, 03/01..
   
  Your help is highly appreciated
   
  Regards,

   
-

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


  1   2   >