Re: [R] Error producing density curve

2008-08-27 Thread Nicky Chorley
2008/8/27 Nicky Chorley [EMAIL PROTECTED]:
 2008/8/27 rr400 [EMAIL PROTECTED]:

 Hi, i have never really used R before and i need to produce a density curve
 for use in an assignment. Following the instructions in the manual provided
 with my course i keep getting this error message:
 Error in plot.xy(xy, type, ...) : invalid plot type '1'

 The commands i have entered are:
x=seq(0, 1800, 10)
x
f=dnorm(x, 1454.190, 162.6301)
f
plot(x,f,type='1')

 It's probably a lowercase L, not a 1 (to plot lines rather than points).


For more information about plot, see the man page: ? plot

 Regards,

 Nicky Chorley


__
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] Converting 1-D array to vector

2008-08-27 Thread N. Lapidus
You were very close to an answer :
as.vector(unlist(df[1,]))

Nael

On Wed, Aug 27, 2008 at 7:53 AM, Ronnen Levinson [EMAIL PROTECTED] wrote:


   Hi.
   How  do I convert a one-dimensional array of characters to a character
   vector? In the example below I am trying to get the result c(a,d).
 The
   function as.vector() returns the same one-dimensional array, and unlist()
   returns something more complicated than I seek.
   Yours truly,
   Ronnen.
   P.S. E-mailed CCs of posted replies appreciated.
df=data.frame(x=letters[1:3],y=letters[4:6])
df
 x y
   1 a d
   2 b e
   3 c f
df[1,]
 x y
   1 a d
as.vector(df[1,])
 x y
   1 a d
unlist(df[1,])
   x y
   a d
   Levels: a b c d e f
c(a,d) # desired result
   [1] a d
version
  _
   platform   i386-pc-mingw32
   arch   i386
   os mingw32
   system i386, mingw32
   status
   major  2
   minor  7.0
   year   2008
   month  04
   day22
   svn rev45424
   language   R
   version.string R version 2.7.0 (2008-04-22)

   --
   Ronnen Levinson, Ph.D.
   scientist, Lawrence Berkeley National Lab
   The  Onion  horoscope: Libra September 23 - October 23 Your tactics of
   overwhelming your opposition with spectacular shows of force and choking
 the
   roads with fleeing refugees will be seen as inappropriate by the other
   electronics wholesalers.
 __
 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.


[[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] loop with splitted data -solved

2008-08-27 Thread Knut Krueger

Thank you for the hints,
finally I was looking for the substitution of
splitted$2
to
splitted[[as.character(counter)]]

I did not know that I can substitute f.e the  $2 with [[2]]  or/and
$y (second column) with [[2]]

Knut

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

2008-08-27 Thread Laura Bonnett
Hi all,

Sorry to ask again but I'm still not sure how to get the full
variance-covariance matrix.  Peter suggested a three-level treatment
factor.  However, I thought that the censoring variable could only take
values 0 or 1 so how do you programme such a factor.

Alternatively, is there another way to produce the required covariance?

Thank you,

Laura

On Tue, Aug 26, 2008 at 11:37 AM, Laura Bonnett
[EMAIL PROTECTED]wrote:

 The standard treatment is the same in both comparison.

 How do you do a three-level treatment factor?
 I thought you had to have a censoring indicator which took values 0 or 1
 not 1, 2 or 3?

 Thanks,

 Laura

 On Tue, Aug 26, 2008 at 11:05 AM, Peter Dalgaard [EMAIL PROTECTED]
  wrote:

 Laura Bonnett wrote:
  Dear R help forum,
 
  I am using the function 'coxph' to obtain hazard ratios for the
 comparison
  of a standard treatment to new treatments.  This is easily obtained by
  fitting the relevant model and then calling exp(coef(fit1)) say.
 
  I now want to obtain the hazard ratio for the comparison of two
 non-standard
  treatments.
  From a statistical point of view, this can be achieved by dividing the
  exponentiated coefficients of 2 comparisions. E.g. to compared new
 treatment
  1 (nt1) to new treatment 2 (nt2) we can fit 2 models:
  fit1 = standard treatment vs nt1
  fit2 = standard treatment vs nt2.
  The required hazard ratio is therefore exp(coef(fit1))/exp(coef(fit2))
 
  In order to obtain an associated confidence interval for this I require
 the
  covariance of this comparison.  I know that R gives the
 variance-covariance
  matrix by the command 'fit$var'.  However, this only gives the
 covariance
  matrix for non standard drugs and not the full covariance matrix.
 
  Can anyone tell me how to obtain the full covariance matrix?
 
 
 What kind of data do you have? Is the standard treatment group the
 same in both comparisons?  If so, why not just have a three-level
 treatment factor and compare nt1 to nt2 directly. If the control groups
 are completely separate, then the covariance between fits made on
 independent data is of course zero.

  Thank you,
 
  Laura
 
[[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.
 


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





[[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] Error producing density curve

2008-08-27 Thread rr400


This was exactly the problem. It has worked a treat this time around. 

Thank you so much!


-- 
View this message in context: 
http://www.nabble.com/Error-producing-density-curve-tp19173403p19176280.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] three character vi commands to edit R commands

2008-08-27 Thread Wolfram Fischer
As ``vi'' user I remarked a while ago,
that - after calling ``R'' -
three character commands like ``ctX'' will beep and do not work
whereas two character commands like ``fX'' work as expected.

Is there some help?

Best regards - Wolfram

__
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] Finding a probability

2008-08-27 Thread rr400

Thank you so much, at least i got that part right. But what is the meaning of
the e-11 at the end??

Thanks again


You commands are correct and the interpretation is that the probability that
a normal random variable with mean 1454.190 and
standard deviation 162.6301 achieves a value of 417 or less is 8.99413e-11



-- 
View this message in context: 
http://www.nabble.com/Finding-a-probability-tp19173491p19176249.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] Converting 1-D array to vector

2008-08-27 Thread Peter Dalgaard
N. Lapidus wrote:
 You were very close to an answer :
 as.vector(unlist(df[1,]))

   
I'd use as.character() there, for clarity. It's not easy to remember
what as.vector on a factor variable does.

Also notice that the original post has serious confusion about what the
data structures are:

df is data frame, not a matrix
df[1,] is a one-row data frame, not a 1-d vector
the components of df are factors, not character vectors

A data frame is a kind of list, and lists are a kind of vector, hence
as.vector does nothing to df[,1]. The unlist() function applied to
factors will take the union of their level sets and concatenate the values.

An alternative way is to make sure that you have a character matrix to
begin with:

 as.matrix(df)
 x   y
[1,] a d
[2,] b e
[3,] c f
 as.matrix(df)[1,]
  x   y
a d

(but beware the rather surprising

 as.character(df)
[1] 1:3 1:3

!!!)

 Nael

 On Wed, Aug 27, 2008 at 7:53 AM, Ronnen Levinson [EMAIL PROTECTED] wrote:

   
   Hi.
   How  do I convert a one-dimensional array of characters to a character
   vector? In the example below I am trying to get the result c(a,d).
 The
   function as.vector() returns the same one-dimensional array, and unlist()
   returns something more complicated than I seek.
   Yours truly,
   Ronnen.
   P.S. E-mailed CCs of posted replies appreciated.
df=data.frame(x=letters[1:3],y=letters[4:6])
df
 x y
   1 a d
   2 b e
   3 c f
df[1,]
 x y
   1 a d
as.vector(df[1,])
 x y
   1 a d
unlist(df[1,])
   x y
   a d
   Levels: a b c d e f
c(a,d) # desired result
   [1] a d
 


-- 
   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] Finding a probability

2008-08-27 Thread Nicky Chorley
2008/8/27 rr400 [EMAIL PROTECTED]:

 Thank you so much, at least i got that part right. But what is the meaning of
 the e-11 at the end??

Exponential notation. It means 10^-11.

Regards,

Nicky Chorley

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

2008-08-27 Thread Peter Dalgaard
Laura Bonnett wrote:
 Hi all,

 Sorry to ask again but I'm still not sure how to get the full
 variance-covariance matrix.  Peter suggested a three-level treatment
 factor.  However, I thought that the censoring variable could only take
 values 0 or 1 so how do you programme such a factor.
   
Well, not to put it too diplomatically: If you can confuse the treatment
factor and the censoring indicator, there might be more wrong with your
analysis than we originally assumed, so how about showing us a bit more
of what you actually did?

 Alternatively, is there another way to produce the required covariance?

 Thank you,

 Laura

 On Tue, Aug 26, 2008 at 11:37 AM, Laura Bonnett
 [EMAIL PROTECTED]wrote:

   
 The standard treatment is the same in both comparison.

 How do you do a three-level treatment factor?
 I thought you had to have a censoring indicator which took values 0 or 1
 not 1, 2 or 3?

 Thanks,

 Laura

 On Tue, Aug 26, 2008 at 11:05 AM, Peter Dalgaard [EMAIL PROTECTED]
 
 wrote:
   
 Laura Bonnett wrote:
   
 Dear R help forum,

 I am using the function 'coxph' to obtain hazard ratios for the
 
 comparison
   
 of a standard treatment to new treatments.  This is easily obtained by
 fitting the relevant model and then calling exp(coef(fit1)) say.

 I now want to obtain the hazard ratio for the comparison of two
 
 non-standard
   
 treatments.
 From a statistical point of view, this can be achieved by dividing the
 exponentiated coefficients of 2 comparisions. E.g. to compared new
 
 treatment
   
 1 (nt1) to new treatment 2 (nt2) we can fit 2 models:
 fit1 = standard treatment vs nt1
 fit2 = standard treatment vs nt2.
 The required hazard ratio is therefore exp(coef(fit1))/exp(coef(fit2))

 In order to obtain an associated confidence interval for this I require
 
 the
   
 covariance of this comparison.  I know that R gives the
 
 variance-covariance
   
 matrix by the command 'fit$var'.  However, this only gives the
 
 covariance
   
 matrix for non standard drugs and not the full covariance matrix.

 Can anyone tell me how to obtain the full covariance matrix?


 
 What kind of data do you have? Is the standard treatment group the
 same in both comparisons?  If so, why not just have a three-level
 treatment factor and compare nt1 to nt2 directly. If the control groups
 are completely separate, then the covariance between fits made on
 independent data is of course zero.

   
 Thank you,

 Laura

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

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



   

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


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


[R] juxtaposed and stacked bars in one barplot?

2008-08-27 Thread Stefan Uhmann

Hi,

anybody any hints how to get a barplot with both juxtaposed and stacked
bars?

/Stefan

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

2008-08-27 Thread Laura Bonnett
Here is the exact code I have written which does the standard vs nt1 and
standard vs nt2 and also gives me the hazard ratio for nt1 vs nt2.

with - read.table(allwiths.txt,header=TRUE)
fix(arm)
function (data)
{
dummy - rep(0,2437)
for(i in 1:2437){
if(data$Arm[i]==CBZ)
dummy[i] - i
}
return(data[-dummy,])
}
fix(x1)
function (data)
{
x1 - rep(0,716)
for(i in 1:716){
if(data$Treat[i]==TPM)
x1[i] - 0
if(data$Treat[i]==VPS)
x1[i] - 0
if(data$Treat[i]==LTG)
x1[i] - 1
}
return(x1)
}
fix(x2)
function (data)
{
x2 - rep(0,716)
for(i in 1:716){
if(data$Treat[i]==TPM)
x2[i] - 1
if(data$Treat[i]==VPS)
x2[i] - 0
if(data$Treat[i]==LTG)
x2[i] - 0
}
return(x2)
}
fit1 = coxph(Surv(Withtime,Wcens)~x1(armb),data=armb,method=breslow)
exp(fit1$coefficients)
exp(confint(fit1))
fit2 = coxph(Surv(Withtime,Wcens)~x2(armb),data=armb,method=breslow)
exp(fit2$coefficients)
exp(confint(fit2))
exp(fit2$coefficients)/exp(fit1$coefficients)

From that, how do I get the necessary variance-covaraince matrix.

Sorry if I appear dense.  It really isn't my intention.

Laura


On Wed, Aug 27, 2008 at 10:36 AM, Peter Dalgaard
[EMAIL PROTECTED]wrote:

 Laura Bonnett wrote:
  Hi all,
 
  Sorry to ask again but I'm still not sure how to get the full
  variance-covariance matrix.  Peter suggested a three-level treatment
  factor.  However, I thought that the censoring variable could only take
  values 0 or 1 so how do you programme such a factor.
 
 Well, not to put it too diplomatically: If you can confuse the treatment
 factor and the censoring indicator, there might be more wrong with your
 analysis than we originally assumed, so how about showing us a bit more
 of what you actually did?

  Alternatively, is there another way to produce the required covariance?
 
  Thank you,
 
  Laura
 
  On Tue, Aug 26, 2008 at 11:37 AM, Laura Bonnett
  [EMAIL PROTECTED]wrote:
 
 
  The standard treatment is the same in both comparison.
 
  How do you do a three-level treatment factor?
  I thought you had to have a censoring indicator which took values 0 or 1
  not 1, 2 or 3?
 
  Thanks,
 
  Laura
 
  On Tue, Aug 26, 2008 at 11:05 AM, Peter Dalgaard 
 [EMAIL PROTECTED]
 
  wrote:
 
  Laura Bonnett wrote:
 
  Dear R help forum,
 
  I am using the function 'coxph' to obtain hazard ratios for the
 
  comparison
 
  of a standard treatment to new treatments.  This is easily obtained by
  fitting the relevant model and then calling exp(coef(fit1)) say.
 
  I now want to obtain the hazard ratio for the comparison of two
 
  non-standard
 
  treatments.
  From a statistical point of view, this can be achieved by dividing
 the
  exponentiated coefficients of 2 comparisions. E.g. to compared new
 
  treatment
 
  1 (nt1) to new treatment 2 (nt2) we can fit 2 models:
  fit1 = standard treatment vs nt1
  fit2 = standard treatment vs nt2.
  The required hazard ratio is therefore exp(coef(fit1))/exp(coef(fit2))
 
  In order to obtain an associated confidence interval for this I
 require
 
  the
 
  covariance of this comparison.  I know that R gives the
 
  variance-covariance
 
  matrix by the command 'fit$var'.  However, this only gives the
 
  covariance
 
  matrix for non standard drugs and not the full covariance matrix.
 
  Can anyone tell me how to obtain the full covariance matrix?
 
 
 
  What kind of data do you have? Is the standard treatment group the
  same in both comparisons?  If so, why not just have a three-level
  treatment factor and compare nt1 to nt2 directly. If the control groups
  are completely separate, then the covariance between fits made on
  independent data is of course zero.
 
 
  Thank you,
 
  Laura
 
[[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.
 
 
  --
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
 
 
 
 
 
[[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.
 


 --
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of 

[R] Odp: more dot plots on 1 page

2008-08-27 Thread Petr PIKAL
Hi


[EMAIL PROTECTED] napsal dne 26.08.2008 17:06:27:

 Hi,
 
 
 
 I would like to have six dot plots on one page. I make the plots in a
 'for loop' because it is six times the same graph but for different
 subjects (species).
 
 I tried it with par(mfrow=c(3,2), oma=c(3,3,2,0), mar=c(2,2,2,2)); but
 this does not work for dot plots apparently.

You mix standard and grid graphics which I would not recommend without 
detailed knowledge of both. From what you write I presume that you want 6 
panels on one page. Maybe you could try to put discriminating variable to 
dotplot directly?
Something like

dotplot(XX7$BG_dry~XX7$stress|inputdot$sp)

Regards
Petr



 
 Then I tried with print(). But then I had to give the dot plots names.
 This also does not work.
 
 Any one who has some more ideas? What do I do wrong?
 
 
 
 species.vector-c(Lp,Pp,Pl,Ra,Lc,Ml)
 
 
 
 for(i in 1:6){
 
 - inputdot[inputdot$sp_==species.vector[i],]
 
 str()
 
 XX7-subset(,chamber==7)
 
 XX8-subset(,chamber==8)
 
 XX9-subset(,chamber==9)
 
 XX10-subset(,chamber==10)
 
 
 
 species.vector[i] - 
 
 dotplot(XX7$BG_dry~XX7$stress,ylim=c(0,20),ylab=biomass,scales=list(ti
 ck.number=10),
 
 panel = function (x, y) {
 
 panel.abline(v=c(1:8),lty=2,col=gray)
 
 panel.xyplot(x, y, pch = 1, col = blue, cex = .75)
 
 panel.xyplot(XX8$stress,XX8$BG_dry, pch = 16, col = red, cex = .6)
 
 panel.xyplot(XX9$stress,XX9$BG_dry, pch = 2, col = blue, cex = .6)
 
 panel.xyplot(XX10$stress,XX10$BG_dry, pch = 17, col = red, cex = .6)
 
 }, 
 
 key = list(text = list(c(ch7, ch8,ch9,ch10), cex = .75),
 
 points = list(pch = c(1, 16,2,17), col = c(blue,red,blue,red),
 cex = .75),
 
 space = bottom, border = T),main=species.vector[i])   )
 
 }
 
 
 
 print(Lp, split=c(1,1,2,3), more=TRUE)
 
 print(Pp, split=c(2,1,2,3), more=TRUE)
 
 print(Pl, split=c(1,2,2,3), more=TRUE)
 
 print(Ra, split=c(2,2,2,3), more=TRUE)
 
 print(Lc, split=c(1,3,2,3), more=TRUE)
 
 print(Ml, split=c(2,3,2,3))
 
 
 
 Thanks a lot!
 
 Joke
 
 
 
 Joke Van den Berge, PhDs
 
 University of Antwerp, Campus Drie Eiken
 
 Department of Biology
 
 Research Group of Plant and Vegetation Ecology
 
 Universiteitsplein 1
 
 B-2610 Wilrijk, Belgium
 
 
 
 email: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
 
 tel: +32 3 820 22 72 fax: +32 3 820 22 71
 
 
 
 
 
 
[[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] A Tip: lm, glm, and retained cases

2008-08-27 Thread Peter Dalgaard
Marc Schwartz wrote:
 on 08/26/2008 07:31 PM (Ted Harding) wrote:
   
 On 26-Aug-08 23:49:37, hadley wickham wrote:
 
 On Tue, Aug 26, 2008 at 6:45 PM, Ted Harding
 [EMAIL PROTECTED] wrote:
   
 Hi Folks,
 This tip is probably lurking somewhere already, but I've just
 discovered it the hard way, so it is probably worth passing
 on for the benefit of those who might otherwise hack their
 way along the same path.

 Say (for example) you want to do a logistic regression of a
 binary response Y on variables X1, X2, X3, X4:

  GLM - glm(Y ~ X1 + X2 + X3 + X4)

 Say there are 1000 cases in the data. Because of missing values
 (NAs) in the variables, the number of complete cases retained
 for the regression is, say, 600. glm() does this automatically.

 QUESTION: Which cases are they?

 You can of course find out by hand on the lines of

  ix - which( (!is.na(Y))(!is.na(X1))...(!is.na(X4)) )

 but one feels that GLM already knows -- so how to get it to talk?

 ANSWER: (e.g.)

  ix - as.integer(names(GLM$fit))
 
 Alternatively, you can use:

 attr(GLM$model, na.action)

 Hadley
   
 Thanks! I can see that it works -- though understanding how
 requires a deeper knowledge of R internals. However, since
 you've approached it from that direction, simply

   GLM$model

 is a dataframe of the retained cases (with corresponding
 row-names), all variables at once, and that is possibly an
 even simpler approach!
 

 Or just use:

model.frame(ModelObject)

 as the extractor function...  :-)

 Another 'a priori' approach would be to use na.omit() or one of its
 brethren on the data frame before creating the model. Which function is
 used depends upon how 'na.action' is set.

 The returned value, or more specifically the 'na.action' attribute as
 appropriate, would yield information similar to Hadley's approach
 relative to which records were excluded.

 For example, using the simple data frame in ?na.omit:

 DF - data.frame(x = c(1, 2, 3), y = c(0, 10, NA))

   
 DF
 
   x  y
 1 1  0
 2 2 10
 3 3 NA

 DF.na - na.omit(DF)

   
 DF.na
 
   x  y
 1 1  0
 2 2 10

   
 attr(DF.na, na.action)
 
 3
 3
 attr(,class)
 [1] omit


 So you can see that record 3 was removed from the original data frame
 due to the NA for 'y'.
   
Also notice the possibility of

(g)lm(., na.action=na.exclude)

as in

library(ISwR); attach(thuesen)
fit - lm(short.velocity ~ blood.glucose, na.action=na.exclude)
which(is.na(fitted(fit))) # 16

This is often recommendable anyway, e.g. in case you want to plot
residuals against original predictors.

-- 
   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] Variance-covariance matrix

2008-08-27 Thread Peter Dalgaard
Laura Bonnett wrote:
 Here is the exact code I have written which does the standard vs nt1
 and standard vs nt2 and also gives me the hazard ratio for nt1 vs nt2.

 with - read.table(allwiths.txt,
 header=TRUE)
 fix(arm)
 function (data)
 {
 dummy - rep(0,2437)
 for(i in 1:2437){
 if(data$Arm[i]==CBZ)
 dummy[i] - i
 }
 return(data[-dummy,])
 }
 fix(x1)
 function (data)
 {
 x1 - rep(0,716)
 for(i in 1:716){
 if(data$Treat[i]==TPM)
 x1[i] - 0
 if(data$Treat[i]==VPS)
 x1[i] - 0
 if(data$Treat[i]==LTG)
 x1[i] - 1
 }
 return(x1)
 }
 fix(x2)
 function (data)
 {
 x2 - rep(0,716)
 for(i in 1:716){
 if(data$Treat[i]==TPM)
 x2[i] - 1
 if(data$Treat[i]==VPS)
 x2[i] - 0
 if(data$Treat[i]==LTG)
 x2[i] - 0
 }
 return(x2)
 }
 fit1 = coxph(Surv(Withtime,Wcens)~x1(armb),data=armb,method=breslow)
 exp(fit1$coefficients)
 exp(confint(fit1))
 fit2 = coxph(Surv(Withtime,Wcens)~x2(armb),data=armb,method=breslow)
 exp(fit2$coefficients)
 exp(confint(fit2))
 exp(fit2$coefficients)/exp(fit1$coefficients)

 From that, how do I get the necessary variance-covaraince matrix.

 Sorry if I appear dense.  It really isn't my intention.

You need to read up on vectorized arithmetic, (and don't use fix() to
define functions, x1 - function() {} will do, and what's with
the unused arm() function??).

However, if I get your data structure correctly, what I meant was that
you could just look at

fit3 - coxph(Surv(Withtime,Wcens)~Treat, data=armb,method=breslow)

(possibly factor(Treat) instead). If VPS is your control, I think you'll
even get the desired coefficient directly from the output because the
group comparisons will be against LTG.

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


[R] random error with lme for repeated measures anova

2008-08-27 Thread Jean-Pierre Bresciani

Hi,

what is the appropriate syntax to get the random error correct when
performing repeated measures anova with 'lme'.

let's say i have 3 independent variables, with 'aov', i would write
something like: aov(dep_var~(indep_var1*indep_var2*indep_var3) +
Error(subject/(indep_var1*indep_var2*indep_var3)).

With 'lme' however, i can't find the right formula. i tried things like:
lme(dep_var~(indep_var1*indep_var2*indep_var3), random = ~1|subject) or
nesting my independent variables in 'subject', but those are obviously wrong
with my design.

i'm quite clueless (and i haven't found any convincing piece of information
about how to correctly use 'lme' or 'lmer'). So, any advice along that line
is more than welcome.

JP 
-- 
View this message in context: 
http://www.nabble.com/random-error-with-lme-for-repeated-measures-anova-tp19178239p19178239.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] random error with lme for repeated measures anova

2008-08-27 Thread Andrew Robinson
Hi JP,

I suggest that you read the literature cited in the help file, most
particularly 

 Pinheiro, J.C., and Bates, D.M. (2000) Mixed-Effects Models in S
 and S-PLUS, Springer.  

MASS (Modern Applied Statistics in S) also has some useful things in
it.

Cheers

Andrew


On Wed, Aug 27, 2008 at 03:23:58AM -0700, Jean-Pierre Bresciani wrote:
 
 Hi,
 
 what is the appropriate syntax to get the random error correct when
 performing repeated measures anova with 'lme'.
 
 let's say i have 3 independent variables, with 'aov', i would write
 something like: aov(dep_var~(indep_var1*indep_var2*indep_var3) +
 Error(subject/(indep_var1*indep_var2*indep_var3)).
 
 With 'lme' however, i can't find the right formula. i tried things like:
 lme(dep_var~(indep_var1*indep_var2*indep_var3), random = ~1|subject) or
 nesting my independent variables in 'subject', but those are obviously wrong
 with my design.
 
 i'm quite clueless (and i haven't found any convincing piece of information
 about how to correctly use 'lme' or 'lmer'). So, any advice along that line
 is more than welcome.
 
 JP 
 -- 
 View this message in context: 
 http://www.nabble.com/random-error-with-lme-for-repeated-measures-anova-tp19178239p19178239.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.

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


[R] SparseM

2008-08-27 Thread Heike Pospisil
Hello,

I am trying to load the package SparseM. It seems that I have successfully 
installed SparseM (version 0.78), but I did not succeed in loading the 
SparseM package into R 2.7. Does anybody know a trick for loading 
SparseM?

Thanks in advance,
Heike


 library(SparseM,lib.loc=my.lib.loc)
Error in packageDescription(pkg)$Version :
  $ operator is invalid for atomic vectors
In addition: Warning message:
In packageDescription(pkg) : no package 'SparseM' was found
Error : .onLoad failed in 'loadNamespace' for 'SparseM'
Error: package/namespace load failed for 'SparseM'


 sessionInfo()
R version 2.7.0 (2008-04-22)
x86_64-unknown-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] tools stats graphics  grDevices utils datasets  methods
[8] base

other attached packages:
[1] AnnotationDbi_1.2.2 RSQLite_0.7-0   DBI_0.2-4
[4] GO_2.0.1Biobase_2.0.1   graph_1.18.1

loaded via a namespace (and not attached):
[1] cluster_1.11.10 tcltk_2.7.0

-- 
Dr. Heike Pospisil  | [EMAIL PROTECTED]
University of Hamburg   | Center for Bioinformatics 
Bundesstrasse 43| 20146 Hamburg, Germany 
phone:+49-40-42838-7303 | fax: +49-40-42838-7312

__
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] Using interactive plots to get information about data points

2008-08-27 Thread Antony Unwin
 I have been experimenting with interactive packages such iplots and  
 playwith. Consider the following sample dataset:
 A B C D
 1 5 5 9
 3 2 8 4
 1 7 3 0
 7 2 2 6
 Let's say I make a plot of variable A. I would like to be able to  
 click on a data point (e.g. 3) and have a pop-up window tell me the  
 corresponding value for variable D (e.g. 4).


You're right that iplots can't do that (it's on the wishlist), but it  
offers alternatives.  As a multiwindowing package, it is natural to  
have graphics displays open for all variables of current interest.   
This means that selecting a point highlights it in all displays and  
you can see or query the corresponding values.


Antony Unwin
Professor of Computer-Oriented Statistics and Data Analysis,
Mathematics Institute,
University of Augsburg,
86135 Augsburg, Germany
Tel: + 49 821 5982218

[EMAIL PROTECTED]

http://stats.math.uni-augsburg.de/




[[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] Fw: How to learn R language?

2008-08-27 Thread saggak


--- On Wed, 27/8/08, saggak [EMAIL PROTECTED] wrote:

From: saggak [EMAIL PROTECTED]
Subject: How to learn R language?
To: r-help@r-project.org
Date: Wednesday, 27 August, 2008, 3:37 PM






Hi!

I am a post graduate in Statistics. I want to learn R language, but am very 
confused as to how to begin systematically. I need to learn R language from 
Statistics point of view e.g. I need to fit distributions to data or run 
regression analysis etc. No doubt there are so many articles available on 
internet. But can someone guide me as to how do I begin and go on improving 
myself SYSTEMATICALLY?

Hence, please guide me as to how should I start learning R language? What 
should I read first etc.

Thanks in advance,

Sagga K



Unlimited freedom, unlimited storage. Get it now


  Unlimited freedom, unlimited storage. Get it now, on 
http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/
[[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] Two envelopes problem

2008-08-27 Thread Jim Lemon

Duncan Murdoch wrote:

On 26/08/2008 7:54 AM, Jim Lemon wrote:

Hi again,
Oops, I meant the expected value of the swap is:

5*0.5 + 20*0.5 = 12.5

Too late, must get to bed.


But that is still wrong.  You want a conditional expectation, 
conditional on the observed value (10 in this case).  The answer 
depends on the distribution of the amount X, where the envelopes 
contain X and 2X.  For example, if you knew that X was at most 5, you 
would know you had just observed 2X, and switching would be  a bad idea.

Yes, I used the example values. If you want an algebraic expression:

0.5x*0.5 + 2x*0.5 = 1.25x

where x is the value of the opened envelope.


The paradox arises because people want to put a nonsensical Unif(0, 
infinity) distribution on X.  The Wikipedia article points out that it 
can also arise in cases where the distribution on X has infinite mean: 
a mathematically valid but still nonsensical possibility.
Okay, I read the Wikipedia article, and now realize that the envelope 
isn't opened in the first version _and_ that it looks like a one trial 
problem. If the envelope isn't opened, let's call the two envelopes on 
offer A and B as in the explanation given. If we simultaneously perform 
the calculation on the two envelopes without knowledge of their 
contents, we find that the swaps for both have the same expected value:


0.5xB*0.5 + 2xB*0.5 = 1.25xA (if A is chosen)

BUT

0.5xA*0.5 + 2xA*0.5 = 1.25xB (if B is chosen)

By reductio ad absurdum (two things cannot both be larger than the 
other) we can say that it makes no sense to swap. It is only when the 
operations are applied to each envelope in sequence that the apparent 
paradox arises in this case. In the single trial, no data case, it 
doesn't make sense to swap in the first place. In a multiple trial 
situation, if A and B are constant, the optimal solution is known after 
the first trial. If A and B can vary on each trial, applying the above 
reasoning, it still doesn't make sense to swap.


In the second version of the problem, the value of A is known. The twin 
isn't really necessary, for if the person making the choice performs the 
above operation with constants rather than unknowns, the same outcome 
emerges.


I think (but I don't really have the time right now to follow it 
through) that the third version can be shown to have the same solution.


This seems logically equivalent to the solution at the bottom proposed 
by James Chase, except that I have used the rather pedestrian method of 
formal logic.


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] Fw: How to learn R language?

2008-08-27 Thread stephen sefick
I am sure that there are as many ways as people, but this is what I
did.  MASS 4, Simple R (internet), and this list.  I taught myself and
it may have been easier to have a guide as this would have cut the
learning curve down, but this is not essential.  Find out what you
need to do, do the examples or vigenettes that come along with the
function you would like to use, cuss a lot, and repeat.  I am a
biologist and never thought I would be programing, but I am now
literate enough to solve the problems that present themselves.
good luck and welcome

Stephen

On Wed, Aug 27, 2008 at 7:27 AM, saggak [EMAIL PROTECTED] wrote:


 --- On Wed, 27/8/08, saggak [EMAIL PROTECTED] wrote:

 From: saggak [EMAIL PROTECTED]
 Subject: How to learn R language?
 To: r-help@r-project.org
 Date: Wednesday, 27 August, 2008, 3:37 PM






 Hi!

 I am a post graduate in Statistics. I want to learn R language, but am very 
 confused as to how to begin systematically. I need to learn R language from 
 Statistics point of view e.g. I need to fit distributions to data or run 
 regression analysis etc. No doubt there are so many articles available on 
 internet. But can someone guide me as to how do I begin and go on improving 
 myself SYSTEMATICALLY?

 Hence, please guide me as to how should I start learning R language? What 
 should I read first etc.

 Thanks in advance,

 Sagga K



 Unlimited freedom, unlimited storage. Get it now


  Unlimited freedom, unlimited storage. Get it now, on 
 http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/
[[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.




-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
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] How to print out console output

2008-08-27 Thread K. Elo

Dear R-helpers,

I am desperately looking for a solution for how to print out the console 
output to a standard printer. For example, I would like to print out the 
summary.lm() output, the output of different ftable-functions etc. I use 
R on a linux machine.


The only ways so far have been to copy-paste the output into an external 
editor or to use sink() to redirect the output into a text file and then 
use shell commands to print out the file. Both ways work but are a bit 
laborious :)


Many thanks in advance for Your help!

Kind regards,
Kimmo

__
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] How to print out console output

2008-08-27 Thread jim holtman
?capture.output
?sink

 x - capture.output(runif(20))

 x
[1]  [1] 0.2730090246 0.4462614490 0.2382041477 0.9826505063
0.1556554718 0.3746872961
[2]  [7] 0.6108254879 0.6617410595 0.6694177436 0.4650380281
0.0414420397 0.2307212995
[3] [13] 0.5338913775 0.9186298891 0.0006410333 0.8046684864
0.6205502201 0.5352788521
[4] [19] 0.4255279053 0.7711444888
 cat(x, sep=\n)
 [1] 0.2730090246 0.4462614490 0.2382041477 0.9826505063 0.1556554718
0.3746872961
 [7] 0.6108254879 0.6617410595 0.6694177436 0.4650380281 0.0414420397
0.2307212995
[13] 0.5338913775 0.9186298891 0.0006410333 0.8046684864 0.6205502201
0.5352788521
[19] 0.4255279053 0.7711444888



On Wed, Aug 27, 2008 at 7:44 AM, K. Elo [EMAIL PROTECTED] wrote:
 Dear R-helpers,

 I am desperately looking for a solution for how to print out the console
 output to a standard printer. For example, I would like to print out the
 summary.lm() output, the output of different ftable-functions etc. I use R
 on a linux machine.

 The only ways so far have been to copy-paste the output into an external
 editor or to use sink() to redirect the output into a text file and then use
 shell commands to print out the file. Both ways work but are a bit laborious
 :)

 Many thanks in advance for Your help!

 Kind regards,
 Kimmo

 __
 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 that 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] How to print out console output

2008-08-27 Thread K. Elo

Hi!

Thanks, Jim, for Your quick answer. But my question was how to 
(re)direct the output to a printer.


Kind regards,
Kimmo


jim holtman wrote:

?capture.output
?sink


x - capture.output(runif(20))



x

[1]  [1] 0.2730090246 0.4462614490 0.2382041477 0.9826505063
0.1556554718 0.3746872961
[2]  [7] 0.6108254879 0.6617410595 0.6694177436 0.4650380281
0.0414420397 0.2307212995
[3] [13] 0.5338913775 0.9186298891 0.0006410333 0.8046684864
0.6205502201 0.5352788521
[4] [19] 0.4255279053 0.7711444888

cat(x, sep=\n)

 [1] 0.2730090246 0.4462614490 0.2382041477 0.9826505063 0.1556554718
0.3746872961
 [7] 0.6108254879 0.6617410595 0.6694177436 0.4650380281 0.0414420397
0.2307212995
[13] 0.5338913775 0.9186298891 0.0006410333 0.8046684864 0.6205502201
0.5352788521
[19] 0.4255279053 0.7711444888


On Wed, Aug 27, 2008 at 7:44 AM, K. Elo [EMAIL PROTECTED] wrote:

Dear R-helpers,

I am desperately looking for a solution for how to print out the console
output to a standard printer. For example, I would like to print out the
summary.lm() output, the output of different ftable-functions etc. I use R
on a linux machine.

The only ways so far have been to copy-paste the output into an external
editor or to use sink() to redirect the output into a text file and then use
shell commands to print out the file. Both ways work but are a bit laborious
:)

Many thanks in advance for Your help!

Kind regards,
Kimmo

__
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] warning message while using mice Multivariate Imputation by Chained Equations

2008-08-27 Thread [EMAIL PROTECTED]
 Hi there,

I am a beginner with R. Anyone could help to explain me what the following
warning msg means?

Warning messages:
1: In any(predictorMatrix[j, ]) :
  coercing argument of type 'double' to logical

Got 6 of it...although further calculations were done. Because of this
warning I am not sure if they are reliable since have no idea what exactly
the warning is about. Could anyone please help with the explanation?

I used mice Multivariate Imputation by Chained Equations (belonging to
mice package) - the default version - predictive mean matching

imp-mice(file)

By using the command mice it is instead of using default version (which I
was using in this case and got the warning msg) possible to create your own
function which tells how the imputation data should be created. I would like
to create that function saying that Bayes bootstrap of the known data should
be imputed for those missing data. Any idea how that could be done??

Ana

[[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] Fw: How to learn R language?

2008-08-27 Thread Peter Dalgaard
saggak wrote:
 Hi!

 I am a post graduate in Statistics. I want to learn R language, but am very 
 confused as to how to begin systematically. I need to learn R language from 
 Statistics point of view e.g. I need to fit distributions to data or run 
 regression analysis etc. No doubt there are so many articles available on 
 internet. But can someone guide me as to how do I begin and go on improving 
 myself SYSTEMATICALLY?

 Hence, please guide me as to how should I start learning R language? What 
 should I read first etc.

 Thanks in advance,

 Sagga K
   

It depends on your starting point, of course. Whether you have a
background with other statistical packages and/or with programming
languages like C, etc.

Quite a few people have started from the intro manual that ships with R
(and its predecessor for S-PLUS). There are quite a few books out, see
for instance http://www.r-project.org/doc/bib/R-books.html (thanks for
reminding me that the info for my own book needs to be updated for the
2nd ed., by the way...), and freely available documents in
http://cran.r-project.org/other-docs.html.

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

__
R-help@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] How to learn R language?

2008-08-27 Thread saggak
Hi!

I am a post graduate in Statistics. I want to learn R language, but am very 
confused as to how to begin systematically. I need to learn R language from 
Statistics point of view e.g. I need to fit distributions to data or run 
regression analysis etc. No doubt there are so many articles available on 
internet. But can someone guide me as to how do I begin and go on improving 
myself SYSTEMATICALLY?

Hence, please guide me as to how should I start learning R language? What 
should I read first etc.

Thanks in advance,

Sagga K



  Did you know? You can CHAT without downloading messenger. Go to 
http://in.webmessenger.yahoo.com/
[[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] Odd behavior in histogram breaks?

2008-08-27 Thread Glenn Lawyer
I am looking at histogram breaks, and notice something odd:
 foo - hist(runif(1),breaks=20)
 length(foo$breaks)
[1] 21
This makes sense to me.

 foo - hist(runif(1),breaks=200)
 length(foo$breaks)
[1] 201
This also makes sense.

BUT
 foo - hist(runif(1),breaks=250)
 length(foo$breaks)
[1] 201
 foo - hist(runif(10),breaks=250)
 length(foo$breaks)
[1] 201

Why only 201 breaks? Where did the other 50 go?

-- 

Here miracles become marvels, and
marvels recurring wonders.
-- William Beebe

Dr. Glenn Lawyer
+352 661 967 244
Instituttgruppe for psykiatri
Seksjon Vinderen
PB 85 Vinderen
0319 Oslo
http://folk.uio.no/davidgl

[[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] coding rules

2008-08-27 Thread Thomas LOUBRIEU

Dear all,

I am organizing a set of specific R code as package (to ease the 
documentation and deployment of it to users).
Before doing so, I would like to know if there are written coding rules 
for R (with functions, objects naming convention for example).


Thanks a lot,

Thomas

--


-
Thomas LOUBRIEU
IFREMER IDM/ISI
BP70
29280 Plouzane
FRANCE
 
email: [EMAIL PROTECTED]

WWW  : http://www.coriolis.eu.org/cdc
Tel.:  (+33) (0)2 98 22 48 53
Fax:   (+33) (0)2 98 22 46 44

__
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] coding rules

2008-08-27 Thread Henrique Dallazuanna
See

http://www1.maths.lth.se/help/R/RCC/

On Wed, Aug 27, 2008 at 9:36 AM, Thomas LOUBRIEU
[EMAIL PROTECTED] wrote:
 Dear all,

 I am organizing a set of specific R code as package (to ease the
 documentation and deployment of it to users).
 Before doing so, I would like to know if there are written coding rules for
 R (with functions, objects naming convention for example).

 Thanks a lot,

 Thomas

 --


 -
 Thomas LOUBRIEU
 IFREMER IDM/ISI
 BP70
 29280 Plouzane
 FRANCE
  email: [EMAIL PROTECTED]
 WWW  : http://www.coriolis.eu.org/cdc
 Tel.:  (+33) (0)2 98 22 48 53
 Fax:   (+33) (0)2 98 22 46 44

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


[R] speeding up multiple kriging predictions using fields package

2008-08-27 Thread Felix Bonowski
Sorry for the double post - I accidentially hit my the send button...

We want to build a global optimizer for extremely expensive noisy objective 
functions based 
on physical measurements.
Our approach is based on optimizing kriging response surfaces surface models.
(as seen in www.cs.ubc.ca/~hutter/earg/stack/taxonomy-global_optimization.pdf)

In each iteration, we
- model the response surface based on the measurements done so far 
using Krig 
from fields.
- find a parameter set that maximizes the probability of improvement on 
this model 
using constrOptim from multiple starting points.
- measure the parameter set that maximizes the probability of 
improvement

My problem:
Unfortunately, the optimizations are extremely slow (~30s per iteration of the 
algorithm) 
despite not making excessive numbers of objective function evaluations (~1000 
per 
iteration).
I suspect this is because the many calls of predict.Krig and predict.se.Krig 
made by optim 
are slow, compared to a single call with many x values:

##example code:
library(fields)
fun-function(x){return(sin(x*9)*1/((x)^2+0.02))}

#make some kriging model of a nasty objective function
x=matrix(seq(-1,1,0.5),ncol=1)
y=apply(x,2,fun)
kfit=Krig(x,y,cov.function=Exp.cov,p=2,theta=0.2)

#this is fast:
xp=matrix(seq(-1,1,0.001),ncol=1)
yp=predict.se(kfit,xp)
#this is _very_ slow:
for(i in 1:nrow(xp)){
  yp[i]=predict.se(kfit,xp[i,])
}
##end example code

My question:

how can I speed up the many single predictions so they can be used efficiently 
in an 
objective-function in an optimization?

thanks!

Felix Bonowski

__
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] How to learn R language?

2008-08-27 Thread milton ruser
Dear Sagga,

How give a look at the introduction material on
Help / Manual (in pdf) / An introduction to R

HTH

miltinho astronauta
brazil

On 8/27/08, saggak [EMAIL PROTECTED] wrote:

 Hi!

 I am a post graduate in Statistics. I want to learn R language, but am very
 confused as to how to begin systematically. I need to learn R language from
 Statistics point of view e.g. I need to fit distributions to data or run
 regression analysis etc. No doubt there are so many articles available on
 internet. But can someone guide me as to how do I begin and go on improving
 myself SYSTEMATICALLY?

 Hence, please guide me as to how should I start learning R language? What
 should I read first etc.

 Thanks in advance,

 Sagga K



  Did you know? You can CHAT without downloading messenger. Go to
 http://in.webmessenger.yahoo.com/
[[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.


[[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] random error with lme for repeated measures anova

2008-08-27 Thread Mark Difford

Hi Jean-Pierre,

A general comment is that I think you need to think more carefully about
what you are trying to get out of your analysis. The random effects
structure you are aiming for could be stretching your data a little thin.

It might be a good idea to read through the archives of the
R-sig-mixed-models mailing list

https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

This should give you a better idea of some of the issues involved.

If you can't source the source (PB) then there are other documents that
might help. You could begin by locationing the directory where nlme package
is installed and looking at the scripts in the scripts subdirectory. These
are from PB.

Baayen has the following draft document on his website. Though DRAFT'ed all
over the place, it is well worth a read, even if you are not interested in
linguistic analysis. I think it has now been published by Cambridge UP.

http://www.ualberta.ca/~baayen/publications/baayenCUPstats.pdf

Paul Bliese's document (Multilevel Modeling in R) also has some useful
sections (find it under the contributed documents section on CRAN).

HTH, Mark.


Jean-Pierre Bresciani wrote:
 
 Hi,
 
 what is the appropriate syntax to get the random error correct when
 performing repeated measures anova with 'lme'.
 
 let's say i have 3 independent variables, with 'aov', i would write
 something like: aov(dep_var~(indep_var1*indep_var2*indep_var3) +
 Error(subject/(indep_var1*indep_var2*indep_var3)).
 
 With 'lme' however, i can't find the right formula. i tried things like:
 lme(dep_var~(indep_var1*indep_var2*indep_var3), random = ~1|subject) or
 nesting my independent variables in 'subject', but those are obviously
 wrong with my design.
 
 i'm quite clueless (and i haven't found any convincing piece of
 information about how to correctly use 'lme' or 'lmer'). So, any advice
 along that line is more than welcome.
 
 JP 
 

-- 
View this message in context: 
http://www.nabble.com/random-error-with-lme-for-repeated-measures-anova-tp19178239p19180027.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] Com Object mystake

2008-08-27 Thread popsmelove

Hi, 

I've some problem to close a com Object that I've open. 

example :

I create the Com Object Excel :

fxl = comCreateObject(Excel.Application)

To close I normally used 

gc(verbose = FALSE) - silent


This is ok with my first Pc, the Com Object Excel is kill, but for my second
computer this do nothing ... ?

I've you an idea of the reason why the gc(verbose = FALSE) - silent don't
close my com object ?

Thanks
-- 
View this message in context: 
http://www.nabble.com/Com-Object-mystake-tp19180043p19180043.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] Basic question about X11()

2008-08-27 Thread Groeneweg M (GEN)
Hello,
 
I have a basic question about the display() function, but I can't find the 
answer easily.
 
I am running R 2.7.16.0 on Suse linux 11.0
 with KDE 4.0
 
I have several desktops, that I use at the same time, called Desktop 1, Desktop 
2, etc. 
I want to open a X11() window in another desktop than the one I'm working from. 
I tried to do this by using:
 
X11(display=Desktop 1);
 
However, this results in an error:

Error in X11(d$display, d$width, d$height, d$pointsize, d$gamma, d$colortype,  :
  unable to start device X11cairo
In addition: Warning message:
In X11(display = Desktop 1) :
  unable to open connection to X11 display 'Desktop 1'

If I make a window with just x11() and than move the window manually to another 
desktop, It works fine, i.e. I can draw a plot in that window.

I am probably just missing some basic syntax rules here. What should I do to 
get my X11 window to be generated on another desktop than the one i was working 
from?

Thanks in advance,
Mathijs Groeneweg

[[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] Closest value

2008-08-27 Thread Dani Valverde

Hello,
I have this command:
x.axis - seq(from=0.5, to=4.5, length.out=13112)
How can I which of the x.axis components is the closest to a given 
value, for example 3.2?

Best,

Dani

--
Daniel Valverde Saubí

Grup de Biologia Molecular de Llevats
Facultat de Veterinària de la Universitat Autònoma de Barcelona
Edifici V, Campus UAB
08193 Cerdanyola del Vallès- SPAIN

Centro de Investigación Biomédica en Red
en Bioingeniería, Biomateriales y
Nanomedicina (CIBER-BBN)

Grup d'Aplicacions Biomèdiques de la RMN
Facultat de Biociències
Universitat Autònoma de Barcelona
Edifici Cs, Campus UAB
08193 Cerdanyola del Vallès- SPAIN
+34 93 5814126

__
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] Odd behavior in histogram breaks?

2008-08-27 Thread Rory.WINSTON
I think the answer is in this line in hist.default():

  breaks - pretty(range(x), n = breaks, min.n = 1)


 length(pretty(c(1:1000), 100))
[1] 101
 length(pretty(c(1:1000), 200))
[1] 201
 length(pretty(c(1:1000), 250))
[1] 201
 length(pretty(c(1:1000), 300))
[1] 201
 length(pretty(c(1:1000), 500))
[1] 501

Rory Winston
RBS Global Banking  Markets
Office: +44 20 7085 4476

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Glenn Lawyer
Sent: 27 August 2008 13:27
To: r-help@r-project.org
Subject: [R] Odd behavior in histogram breaks?

I am looking at histogram breaks, and notice something odd:
 foo - hist(runif(1),breaks=20)
 length(foo$breaks)
[1] 21
This makes sense to me.

 foo - hist(runif(1),breaks=200)
 length(foo$breaks)
[1] 201
This also makes sense.

BUT
 foo - hist(runif(1),breaks=250)
 length(foo$breaks)
[1] 201
 foo - hist(runif(10),breaks=250)
 length(foo$breaks)
[1] 201

Why only 201 breaks? Where did the other 50 go?

--

Here miracles become marvels, and
marvels recurring wonders.
-- William Beebe

Dr. Glenn Lawyer
+352 661 967 244
Instituttgruppe for psykiatri
Seksjon Vinderen
PB 85 Vinderen
0319 Oslo
http://folk.uio.no/davidgl

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

***
The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered 
Office: 36 St Andrew Square, Edinburgh EH2 2YB. 
Authorised and regulated by the Financial Services Authority 

This e-mail message is confidential and for use by the=2...{{dropped:22}}

__
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] Closest value

2008-08-27 Thread Henrique Dallazuanna
Try this:

x.axis[which.min(abs(x.axis - 3.2))]

On Wed, Aug 27, 2008 at 10:12 AM, Dani Valverde [EMAIL PROTECTED] wrote:
 Hello,
 I have this command:
 x.axis - seq(from=0.5, to=4.5, length.out=13112)
 How can I which of the x.axis components is the closest to a given value,
 for example 3.2?
 Best,

 Dani

 --
 Daniel Valverde Saubí

 Grup de Biologia Molecular de Llevats
 Facultat de Veterinària de la Universitat Autònoma de Barcelona
 Edifici V, Campus UAB
 08193 Cerdanyola del Vallès- SPAIN

 Centro de Investigación Biomédica en Red
 en Bioingeniería, Biomateriales y
 Nanomedicina (CIBER-BBN)

 Grup d'Aplicacions Biomèdiques de la RMN
 Facultat de Biociències
 Universitat Autònoma de Barcelona
 Edifici Cs, Campus UAB
 08193 Cerdanyola del Vallès- SPAIN
 +34 93 5814126

 __
 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] Closest value

2008-08-27 Thread Doran, Harold
Maybe this
which.min(abs(x.axis-3.2)) 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Dani Valverde
 Sent: Wednesday, August 27, 2008 9:13 AM
 To: R Help
 Subject: [R] Closest value
 
 Hello,
 I have this command:
 x.axis - seq(from=0.5, to=4.5, length.out=13112) How can I 
 which of the x.axis components is the closest to a given 
 value, for example 3.2?
 Best,
 
 Dani
 
 --
 Daniel Valverde Saubí
 
 Grup de Biologia Molecular de Llevats
 Facultat de Veterinària de la Universitat Autònoma de 
 Barcelona Edifici V, Campus UAB
 08193 Cerdanyola del Vallès- SPAIN
 
 Centro de Investigación Biomédica en Red en Bioingeniería, 
 Biomateriales y Nanomedicina (CIBER-BBN)
 
 Grup d'Aplicacions Biomèdiques de la RMN Facultat de 
 Biociències Universitat Autònoma de Barcelona Edifici Cs, Campus UAB
 08193 Cerdanyola del Vallès- SPAIN
 +34 93 5814126
 
 __
 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] Odp: Closest value

2008-08-27 Thread Petr PIKAL
Hi

[EMAIL PROTECTED] napsal dne 27.08.2008 15:12:58:

 Hello,
 I have this command:
 x.axis - seq(from=0.5, to=4.5, length.out=13112)
 How can I which of the x.axis components is the closest to a given 
 value, for example 3.2

E.g.
which.min((x.axis-3.2)^2)

Regards
Petr

 Best,
 
 Dani
 
 -- 
 Daniel Valverde Saubí
 
 Grup de Biologia Molecular de Llevats
 Facultat de Veterinària de la Universitat Autònoma de Barcelona
 Edifici V, Campus UAB
 08193 Cerdanyola del Vallès- SPAIN
 
 Centro de Investigación Biomédica en Red
 en Bioingeniería, Biomateriales y
 Nanomedicina (CIBER-BBN)
 
 Grup d'Aplicacions Biomèdiques de la RMN
 Facultat de Biociències
 Universitat Autònoma de Barcelona
 Edifici Cs, Campus UAB
 08193 Cerdanyola del Vallès- SPAIN
 +34 93 5814126
 
 __
 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] Seeking Code for Chaid or Similar

2008-08-27 Thread David Cobey
Quick disclaimer: I'm new to the list and I'm not sure if I'm sending this
to the correct forum.  If there is a better place for this questions, please
let me know!

Dear R List,
I'm interested in modifying a regression tree algorithm to use the
difference between a control and a dosed sample as its dependent variable.
I was wondering if anyone knew where I could find code to implement a basic
chaid algorithm.  Is it possible to access the code inside of R?  Is there
another place I can find the basic algorithm already coded.
I'd prefer a chaid-like algorithm over a crt like algorithm, as my
sample is small.  I'm  a reasonably good programmer, a background in C++ and
experience in many different languages.
I'd very much appreciate any thoughts.
Thank you!
David Cobey

PS. Of course, if this has been done before, I'd be very grateful for the
opportunity to save myself the trouble of reprogramming it myself!

[[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] How to print out console output

2008-08-27 Thread jim holtman
What type of system are you running on?  You can create a
textConnection and maybe 'pipe' the output to 'lpr' if you are running
on UNIX.  On Windows there is probably a way of connecting to a
printer; you can save the file and then execute the PRINT command.

On Wed, Aug 27, 2008 at 7:51 AM, K. Elo [EMAIL PROTECTED] wrote:
 Hi!

 Thanks, Jim, for Your quick answer. But my question was how to (re)direct
 the output to a printer.

 Kind regards,
 Kimmo


 jim holtman wrote:

 ?capture.output
 ?sink

 x - capture.output(runif(20))

 x

 [1]  [1] 0.2730090246 0.4462614490 0.2382041477 0.9826505063
 0.1556554718 0.3746872961
 [2]  [7] 0.6108254879 0.6617410595 0.6694177436 0.4650380281
 0.0414420397 0.2307212995
 [3] [13] 0.5338913775 0.9186298891 0.0006410333 0.8046684864
 0.6205502201 0.5352788521
 [4] [19] 0.4255279053 0.7711444888

 cat(x, sep=\n)

  [1] 0.2730090246 0.4462614490 0.2382041477 0.9826505063 0.1556554718
 0.3746872961
  [7] 0.6108254879 0.6617410595 0.6694177436 0.4650380281 0.0414420397
 0.2307212995
 [13] 0.5338913775 0.9186298891 0.0006410333 0.8046684864 0.6205502201
 0.5352788521
 [19] 0.4255279053 0.7711444888


 On Wed, Aug 27, 2008 at 7:44 AM, K. Elo [EMAIL PROTECTED] wrote:

 Dear R-helpers,

 I am desperately looking for a solution for how to print out the console
 output to a standard printer. For example, I would like to print out the
 summary.lm() output, the output of different ftable-functions etc. I use
 R
 on a linux machine.

 The only ways so far have been to copy-paste the output into an external
 editor or to use sink() to redirect the output into a text file and then
 use
 shell commands to print out the file. Both ways work but are a bit
 laborious
 :)

 Many thanks in advance for Your help!

 Kind regards,
 Kimmo

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




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

What is the problem that 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] R for reliability engineering?

2008-08-27 Thread Wolfgang Keller
Hello,

I was wondering whether anyone's using R for reliability
(RAMS/LCC) engineering?

Sincerely,

Wolfgang Keller

__
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] juxtaposed and stacked bars in one barplot?

2008-08-27 Thread hadley wickham
Hi Stefan,

Could you be a bit more explicit?  Do you have an example dataset that
you are trying to visualise?

Hadley

On Wed, Aug 27, 2008 at 4:38 AM, Stefan Uhmann
[EMAIL PROTECTED] wrote:
 Hi,

 anybody any hints how to get a barplot with both juxtaposed and stacked
 bars?

 /Stefan

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




-- 
http://had.co.nz/

__
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] Fw: How to learn R language?

2008-08-27 Thread John Kane
I'm not a statistician so my approach may not make sense for you but I'd 
suggests having a look at Bob Muenchen's R for SAS and SPSS users in  pdf form 
(very useful) or his new book with the same title (which I have not seen yet) 
for a start. http://rforsasandspssusers.com/

If you want some very, very basic things I'd suggest having a look at the 
tutorial at http://www.math.ilstu.edu/dhkim/Rstuff/Rtutor.html

After that there are any number of useful references and on-line materials 
available through the R site.  Have a look at Books and Other on the left hand 
side of the page.  

If you can get them, I'd suggest having a look at Peter Dalgaard's  
Introductory Statistics with R or John Verzani's Simple R.  The stats may be 
simple for you but the organized treatment of how to use these stats in R is 
very valuable.

The Introduction to R is very good but, at the risk of being accused of heresy, 
I'd suggest that it is much better if you read it after you get a feeling for 
the language. It also should be downloaded and read in the PDF format.  

Read the FAQ carefully, especially Section 7.  Section 7 highlights a lot of 
little things that can confuse a new user and reading it can save you hours of 
pounding your head against the wall. 


 
 From: saggak [EMAIL PROTECTED]
 Subject: How to learn R language?
 To: r-help@r-project.org
 Date: Wednesday, 27 August, 2008, 3:37 PM
 
 Hi!
 
 I am a post graduate in Statistics. I want to learn R
 language, but am very confused as to how to begin
 systematically. I need to learn R language from Statistics
 point of view e.g. I need to fit distributions to data or
 run regression analysis etc. No doubt there are so many
 articles available on internet. But can someone guide me as
 to how do I begin and go on improving myself SYSTEMATICALLY?
 
 Hence, please guide me as to how should I start learning R
 language? What should I read first etc.
 
 Thanks in advance,
 
 Sagga K



  __
[[elided Yahoo spam]]

__
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] How to learn R language?

2008-08-27 Thread Charles Annis, P.E.
There are many books, but if I had to choose one that teaches R and teaches
statistics at the same time (Yes, you already know stats, so it will be that
much easier) I'd choose Peter Dalgaard's book, Introductory Statistics with
R.  It's exceptionally well written, easy to follow, and will systematically
teach you R.  It's paperback, not too expensive and available at Amazon.
Start at the front, work all the way through it and you will be delighted
with the results.

Charles Annis, P.E.

[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of saggak
Sent: Wednesday, August 27, 2008 6:07 AM
To: r-help@r-project.org
Subject: [R] How to learn R language?

Hi!

I am a post graduate in Statistics. I want to learn R language, but am very
confused as to how to begin systematically. I need to learn R language from
Statistics point of view e.g. I need to fit distributions to data or run
regression analysis etc. No doubt there are so many articles available on
internet. But can someone guide me as to how do I begin and go on improving
myself SYSTEMATICALLY?

Hence, please guide me as to how should I start learning R language? What
should I read first etc.

Thanks in advance,

Sagga K



  Did you know? You can CHAT without downloading messenger. Go to
http://in.webmessenger.yahoo.com/
[[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] Integrate a 1-variable function with 1 parameter (Jose L. Romero)

2008-08-27 Thread jose romero
Hey fellas:

I would like to integrate the following function:

integrand - function (x,t) {
exp(-2*t)*(2*t)^x/(10*factorial(x))
}

with respect to the t variable, from 0 to 10.
The variable x here works as a parameter: I would like to integrate the said 
function for each value of x in 0,1,..,44.

I have tried Vectorize to no avail.

Thanks in advance,
jose romero

__
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] Seeking Code for Chaid or Similar

2008-08-27 Thread Achim Zeileis

On Wed, 27 Aug 2008, David Cobey wrote:


Quick disclaimer: I'm new to the list and I'm not sure if I'm sending this
to the correct forum.  If there is a better place for this questions, please
let me know!

Dear R List,
   I'm interested in modifying a regression tree algorithm to use the
difference between a control and a dosed sample as its dependent variable.
I was wondering if anyone knew where I could find code to implement a basic
chaid algorithm.  Is it possible to access the code inside of R?  Is there
another place I can find the basic algorithm already coded.
   I'd prefer a chaid-like algorithm over a crt like algorithm, as my
sample is small.  I'm  a reasonably good programmer, a background in C++ and
experience in many different languages.
   I'd very much appreciate any thoughts.


ctree() in package party implements in inference-based tree algorithm. 
It's based on conditional inference, but not unsimilar to CHAID in the 
case of categorical variables. See its references and vignette for more 
details.


Torsten and I are also working on some basic tree infrastructure which 
could/should eventually also be used for implementing classical CHAID but 
that will take some more time.


hth,
Z


Thank you!
David Cobey

PS. Of course, if this has been done before, I'd be very grateful for the
opportunity to save myself the trouble of reprogramming it myself!

[[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] Integrate a 1-variable function with 1 parameter (Jose L. Romero)

2008-08-27 Thread Peter Dalgaard
jose romero wrote:
 Hey fellas:

 I would like to integrate the following function:

 integrand - function (x,t) {
   exp(-2*t)*(2*t)^x/(10*factorial(x))
 }

 with respect to the t variable, from 0 to 10.
 The variable x here works as a parameter: I would like to integrate the said 
 function for each value of x in 0,1,..,44.

 I have tried Vectorize to no avail.

   
Will this do?

sapply(0:44,function(x)integrate(integrand,x=x, lower=0, upper=10)$value

-- 
   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] Integrate a 1-variable function with 1 parameter (Jose L. Romero)

2008-08-27 Thread Ravi Varadhan

Here is one way:

integrand - function (t, x) {
exp(-2*t)*(2*t)^x/(10*factorial(x))
}

x - 0:44
ans - sapply(x, function(x) integrate(integrand, lower=0, upper=10, x=x))
cbind(x=x, integral=unlist(ans[1,]), abs.error=unlist(ans[2,]))
 

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 





-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of jose romero
Sent: Wednesday, August 27, 2008 10:24 AM
To: r-help@r-project.org
Subject: [R] Integrate a 1-variable function with 1 parameter (Jose L.
Romero)

Hey fellas:

I would like to integrate the following function:

integrand - function (x,t) {
exp(-2*t)*(2*t)^x/(10*factorial(x))
}

with respect to the t variable, from 0 to 10.
The variable x here works as a parameter: I would like to integrate the said
function for each value of x in 0,1,..,44.

I have tried Vectorize to no avail.

Thanks in advance,
jose romero

__
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] Integrate a 1-variable function with 1 parameter (Jose L. Romero)

2008-08-27 Thread Peter Dalgaard
Peter Dalgaard wrote:
 jose romero wrote:
   
 Hey fellas:

 I would like to integrate the following function:

 integrand - function (x,t) {
  exp(-2*t)*(2*t)^x/(10*factorial(x))
 }

 with respect to the t variable, from 0 to 10.
 The variable x here works as a parameter: I would like to integrate the said 
 function for each value of x in 0,1,..,44.

 I have tried Vectorize to no avail.

   
 
 Will this do?

 sapply(0:44,function(x)integrate(integrand,x=x, lower=0, upper=10)$value

   
Oops. Forgot this:

)

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


[R] convert princomp output to equation for plane?

2008-08-27 Thread William Simpson
I want to fit something like:
z = b0 + b1*x + b2*y

Since x, y,and z all have measurement errors attached, the proper way
to do the fit is with principal components analysis, and to use the
first component (called loadings in princomp output).

My dumb question is: how do I convert the princomp output to equation
coefficients in the format above?

I guess another dumb question would be: how about getting the standard
deviations of b0, b1, b2?

Thanks very much for any help.

Bill

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

2008-08-27 Thread Samuel Bächler

Hi Heike

library(SparseM,lib.loc=my.lib.loc)
  
Error in packageDescription(pkg)$Version :

  $ operator is invalid for atomic vectors
In addition: Warning message:
In packageDescription(pkg) : no package 'SparseM' was found
Error : .onLoad failed in 'loadNamespace' for 'SparseM'
Error: package/namespace load failed for 'SparseM'

Maybe omitting 'lib.loc=my.lib.loc' will do the job.

Regards,

Sam

__
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] Seeking Code for Chaid or Similar

2008-08-27 Thread David Cobey
Quick disclaimer: I'm new to the list and I'm not sure if I'm sending this
to the correct forum.  If there is a better place for questions like these,
please let me know!

Dear R List,
I'm interested in modifying a regression tree algorithm to use the
difference between a control and a dosed sample as its dependent variable.
I was wondering if anyone knew where I could find code to implement a basic
chaid algorithm.  Is it possible to access the code inside of R?  Is there
another place I can find the basic algorithm already coded.
I'd prefer a chaid-like algorithm over a crt like algorithm, as my
sample is small.  I'm  a reasonably good programmer, a background in C++ and
experience in many different languages.
I'd very much appreciate any thoughts.
Thank you!
David Cobey

PS. Of course, if this has been done before, I'd be very grateful for the
opportunity to save myself the trouble of reprogramming it myself!

[[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] averaging pairs of columns in a dataframe

2008-08-27 Thread JonD

Dear all,

I have a dataframe with 132 columns and 100 rows.  Every 2nd column is a
repeat measurement so that the columns could be titled, a a b b c c d d etc. 
I would like to average the repeats such that I am left with a data frame of
66 columns (of means) and 100 rows.  

I have been trying to use rowMeans but have not been able to average the
pairs of columns, only the whole dataframe.

Any help would be appreciated, I am new to R.

Thanks in advance,

Jon.
-- 
View this message in context: 
http://www.nabble.com/averaging-pairs-of-columns-in-a-dataframe-tp19181319p19181319.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] Ratio of gammas

2008-08-27 Thread Erwann.Rogard
hello,

gamma(a) works fine for a173, but gamma(173) returns
[1] Inf
Warning message:
value out of range in 'gammafn' 

What I really need is the ratio

gamma(nu/2) / gamma((nu+1)/2)

is anyone aware of a way to re-express this in a form that pushes the
threshold past which a warning message is generated?

thanks!

__
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] Fw: How to learn R language?

2008-08-27 Thread Ajay ohri
   - go with Bob and Peter's book. Too many sources can be confusing.
   - Join the list, create filters for keywords of your specialty (like from
   R -Help ) contains regression.
   - Try use it for a live project .


Let the R begin

Ajay

On Wed, Aug 27, 2008 at 7:46 PM, John Kane [EMAIL PROTECTED] wrote:

 I'm not a statistician so my approach may not make sense for you but I'd
 suggests having a look at Bob Muenchen's R for SAS and SPSS users in  pdf
 form (very useful) or his new book with the same title (which I have not
 seen yet) for a start. http://rforsasandspssusers.com/

 If you want some very, very basic things I'd suggest having a look at the
 tutorial at http://www.math.ilstu.edu/dhkim/Rstuff/Rtutor.html

 After that there are any number of useful references and on-line materials
 available through the R site.  Have a look at Books and Other on the left
 hand side of the page.

 If you can get them, I'd suggest having a look at Peter Dalgaard's
  Introductory Statistics with R or John Verzani's Simple R.  The stats may
 be simple for you but the organized treatment of how to use these stats in R
 is very valuable.

 The Introduction to R is very good but, at the risk of being accused of
 heresy, I'd suggest that it is much better if you read it after you get a
 feeling for the language. It also should be downloaded and read in the PDF
 format.

 Read the FAQ carefully, especially Section 7.  Section 7 highlights a lot
 of little things that can confuse a new user and reading it can save you
 hours of pounding your head against the wall.



  From: saggak [EMAIL PROTECTED]
  Subject: How to learn R language?
  To: r-help@r-project.org
  Date: Wednesday, 27 August, 2008, 3:37 PM
 
  Hi!
 
  I am a post graduate in Statistics. I want to learn R
  language, but am very confused as to how to begin
  systematically. I need to learn R language from Statistics
  point of view e.g. I need to fit distributions to data or
  run regression analysis etc. No doubt there are so many
  articles available on internet. But can someone guide me as
  to how do I begin and go on improving myself SYSTEMATICALLY?
 
  Hence, please guide me as to how should I start learning R
  language? What should I read first etc.
 
  Thanks in advance,
 
  Sagga K



   __
 [[elided Yahoo spam]]

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




-- 
Regards,

Ajay Ohri
http://tinyurl.com/liajayohri

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

2008-08-27 Thread Heike Pospisil
Hi Sam,

thank your for your reply. The lib location statement is correct. I have 
installed SparseM locally because I do not have su rights. 

Best, Heike

(BTW: An installation by our systems administrator into the R directory did 
not work, too.)

On Wednesday 27 August 2008 19:00, Samuel Bächler wrote:
 Hi Heike

  library(SparseM,lib.loc=my.lib.loc)
 
  Error in packageDescription(pkg)$Version :
$ operator is invalid for atomic vectors
  In addition: Warning message:
  In packageDescription(pkg) : no package 'SparseM' was found
  Error : .onLoad failed in 'loadNamespace' for 'SparseM'
  Error: package/namespace load failed for 'SparseM'

 Maybe omitting 'lib.loc=my.lib.loc' will do the job.

 Regards,

 Sam

 __
 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. Heike Pospisil  | [EMAIL PROTECTED]
University of Hamburg   | Center for Bioinformatics 
Bundesstrasse 43| 20146 Hamburg, Germany 
phone:+49-40-42838-7303 | fax: +49-40-42838-7312
=

__
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] Converting 1-D array to vector

2008-08-27 Thread Gasper Cankar
 
 c(as.matrix(df[1,]))

will also work in your case.

Gasper Cankar

-Original Message-
From: N. Lapidus [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 27, 2008 9:06 AM
To: r-help@r-project.org
Subject: Re: [R] Converting 1-D array to vector

You were very close to an answer :
as.vector(unlist(df[1,]))

Nael

On Wed, Aug 27, 2008 at 7:53 AM, Ronnen Levinson [EMAIL PROTECTED]
wrote:


   Hi.
   How  do I convert a one-dimensional array of characters to a
character
   vector? In the example below I am trying to get the result
c(a,d).
 The
   function as.vector() returns the same one-dimensional array, and
unlist()
   returns something more complicated than I seek.
   Yours truly,
   Ronnen.
   P.S. E-mailed CCs of posted replies appreciated.
df=data.frame(x=letters[1:3],y=letters[4:6])
df
 x y
   1 a d
   2 b e
   3 c f
df[1,]
 x y
   1 a d
as.vector(df[1,])
 x y
   1 a d
unlist(df[1,])
   x y
   a d
   Levels: a b c d e f
c(a,d) # desired result
   [1] a d
version
  _
   platform   i386-pc-mingw32
   arch   i386
   os mingw32
   system i386, mingw32
   status
   major  2
   minor  7.0
   year   2008
   month  04
   day22
   svn rev45424
   language   R
   version.string R version 2.7.0 (2008-04-22)

   --
   Ronnen Levinson, Ph.D.
   scientist, Lawrence Berkeley National Lab
   The  Onion  horoscope: Libra September 23 - October 23 Your tactics
of
   overwhelming your opposition with spectacular shows of force and 
 choking the
   roads with fleeing refugees will be seen as inappropriate by the
other
   electronics wholesalers.
 __
 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.


[[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] juxtaposed and stacked bars in one barplot?

2008-08-27 Thread Gasper Cankar
You can simply do

 a - c(2,4,3,4,5)
 b - c(4,3,4,5,2)

 barplot(cbind(a,b))

or you can put a and b in matrix as help suggests.

Gasper Cankar

-Original Message-
From: Stefan Uhmann [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 27, 2008 11:39 AM
To: r-help@r-project.org
Subject: [R] juxtaposed and stacked bars in one barplot?

Hi,

anybody any hints how to get a barplot with both juxtaposed and stacked
bars?

/Stefan

__
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] How to learn R language?

2008-08-27 Thread Ted Harding
On 27-Aug-08 14:24:31, Charles Annis, P.E. wrote:
 There are many books, but if I had to choose one that teaches R
 and teaches statistics at the same time (Yes, you already know
 stats, so it will be that much easier) I'd choose Peter Dalgaard's
 book, Introductory Statistics with R.  It's exceptionally well
 written, easy to follow, and will systematically teach you R.
 It's paperback, not too expensive and available at Amazon.
 Start at the front, work all the way through it and you will be
 delighted with the results.
 
 Charles Annis, P.E.

I have to agree with that (especially the well written part).
Especially, Sagga, already knowing statistics, you will be
familiar with what Peter Dalgaard is doing, tatistically, at
any point and will therefore be able to follow him easily as
he works out how to do it in R; and then you will appreciate
the result.

The book has a clear divide between the two viewpoints: the
view of a person applying statistical procedures (for which
brief basic outline descriptions are given), and the point of
view of someone who wants to implement these in a programming
language. The explanations of how the latter is achieved in R
are clear and thorough (for a basic example, see the dicussion
of Factors in the first Chapter).

Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 27-Aug-08   Time: 16:31:03
-- 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] Ratio of gammas

2008-08-27 Thread Duncan Murdoch

On 8/27/2008 11:14 AM, [EMAIL PROTECTED] wrote:

hello,

gamma(a) works fine for a173, but gamma(173) returns
[1] Inf
Warning message:
value out of range in 'gammafn' 


What I really need is the ratio

gamma(nu/2) / gamma((nu+1)/2)

is anyone aware of a way to re-express this in a form that pushes the
threshold past which a warning message is generated?


Use logs:

exp( lgamma(nu/2) - lgamma((nu+1)/2) )

Duncan Murdoch

__
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] averaging pairs of columns in a dataframe

2008-08-27 Thread Gabor Grothendieck
Try this:

# test data
DF - data.frame(a = 1:9, a = 21:29, b = 31:39, b = 41:49, check.names = FALSE)

t(apply(DF, 1, tapply, names(DF), mean))

It gives a matrix so use as.data.frame on that if you need a data frame

On Wed, Aug 27, 2008 at 9:47 AM, JonD [EMAIL PROTECTED] wrote:

 Dear all,

 I have a dataframe with 132 columns and 100 rows.  Every 2nd column is a
 repeat measurement so that the columns could be titled, a a b b c c d d etc.
 I would like to average the repeats such that I am left with a data frame of
 66 columns (of means) and 100 rows.

 I have been trying to use rowMeans but have not been able to average the
 pairs of columns, only the whole dataframe.

 Any help would be appreciated, I am new to R.

 Thanks in advance,

 Jon.
 --
 View this message in context: 
 http://www.nabble.com/averaging-pairs-of-columns-in-a-dataframe-tp19181319p19181319.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.


[R] Significant digits for checking values of variable?

2008-08-27 Thread David Afshartous

All,

I'm witnessing some strange behavior when checking the values of one of my
variables.  My guess is that it has something to do with the number of
significant digits being represented, but perhaps not as my variable was
created from other variables that only had one decimal place.  See below.
I'm sure this is something basic, any suggestions much appreciated.

Cheers,
David


 visit.2.SEK.delta.baseline
 [1]  0.1 -0.7  0.8 -0.1 -0.5  0.8  0.7  0.2  0.4  0.3  0.6  0.6  0.3  0.8
0.8  0.3  0.4  0.8
 visit.2.SEK.delta.baseline  0
 [1]  TRUE FALSE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 visit.2.SEK.delta.baseline ==  .8
 [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
FALSE FALSE FALSE FALSE FALSE FALSE
### but some of the values are equal to .8

## here it is okay when I try to reproduce
  junk = c(0.1, -0.7,0.8, -0.1, -0.5,  0.8,  0.7,  0.2,  0.4,  0.3,  0.6,  0.6,
0.3,  0.8,  0.8,  0.3,  0.4,  0.8 )
 junk == .8
 [1] FALSE FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE
FALSE  TRUE  TRUE FALSE FALSE  TRUE

__
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] Ratio of gammas

2008-08-27 Thread Ravi Varadhan
This will work:

exp( lgamma(nu/2) - lgamma((nu+1)/2) ) 

Ravi.



---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 





-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of [EMAIL PROTECTED]
Sent: Wednesday, August 27, 2008 11:14 AM
To: r-help@r-project.org
Subject: [R] Ratio of gammas

hello,

gamma(a) works fine for a173, but gamma(173) returns [1] Inf Warning
message:
value out of range in 'gammafn' 

What I really need is the ratio

gamma(nu/2) / gamma((nu+1)/2)

is anyone aware of a way to re-express this in a form that pushes the
threshold past which a warning message is generated?

thanks!

__
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] A manipulation problem for a large data set in R

2008-08-27 Thread Giuseppe Paleologo
I have two questions for the group. One is very concrete, and is dangerously
close to a please do my homework posting. The second follows from the
first one but is more general. I would welcome the advice of experienced R
users.

As for the first one: I have a data frame with two variables

X  Y
A,   chris
D,   chris
B,   chris
B,   chris
C,   andrew
E,   andrew
C,   andrew
B,   beth
D,  chris
D,   beth
C,   beth
D,   beth
D,   beth
A,   andrew
A,   andrew
A,   andrew
C,   chris
B,   beth
D,   chris
E,   andrew
D,   chris
D,   beth
D,   chris
A,   andrew
A,   chris
Cchris
Achris
Bchris
Cbeth
Achris

I would like to produce a table, with one row for every level of the factor
X, and multiple columns, filled with the observed levels of the factor Y
that are observed jointly with X. Hence:

X   Z1  Z2  Z3
A,  andrew,  chris
B,  chris beth,  chris
C,  andrew,  beth,  chris
D,  chris,  beth
E,  andrew

A solution would be to something like

temp = tapply(Y, X, function(a) levels(a[,drop=TRUE])))

and then putting the output in an appropriately sized data frame. The issue
I have with this is that it is inelegant and rather slow for my typical data
set (~200K rows). So I was wondering if a more efficient, nicer solution
exists.

This leads me to a second question. Maybe out of laziness, maybe because R
is good enough, I tend to do all my local data manipulations in R. This
includes de-duping records, joining tables, and grouping observations. I do
this also for larger data sets (say, dense tables with 100M+ elements). Is
this current practice among R users? If so, is there a tutorial, or an R
view on it?  If not, what do you use?

Thanks in advance,

-gappy

[[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] Significant digits for checking values of variable?

2008-08-27 Thread jim holtman
FAQ 7.31

On Wed, Aug 27, 2008 at 11:51 AM, David Afshartous
[EMAIL PROTECTED] wrote:

 All,

 I'm witnessing some strange behavior when checking the values of one of my
 variables.  My guess is that it has something to do with the number of
 significant digits being represented, but perhaps not as my variable was
 created from other variables that only had one decimal place.  See below.
 I'm sure this is something basic, any suggestions much appreciated.

 Cheers,
 David


 visit.2.SEK.delta.baseline
  [1]  0.1 -0.7  0.8 -0.1 -0.5  0.8  0.7  0.2  0.4  0.3  0.6  0.6  0.3  0.8
 0.8  0.3  0.4  0.8
 visit.2.SEK.delta.baseline  0
  [1]  TRUE FALSE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 visit.2.SEK.delta.baseline ==  .8
  [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
 FALSE FALSE FALSE FALSE FALSE FALSE
 ### but some of the values are equal to .8

 ## here it is okay when I try to reproduce
  junk = c(0.1, -0.7,0.8, -0.1, -0.5,  0.8,  0.7,  0.2,  0.4,  0.3,  0.6,  
 0.6,
 0.3,  0.8,  0.8,  0.3,  0.4,  0.8 )
 junk == .8
  [1] FALSE FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE
 FALSE  TRUE  TRUE FALSE FALSE  TRUE

 __
 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 that 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] A manipulation problem for a large data set in R

2008-08-27 Thread Charles C. Berry

On Wed, 27 Aug 2008, Giuseppe Paleologo wrote:


I have two questions for the group. One is very concrete, and is dangerously
close to a please do my homework posting. The second follows from the
first one but is more general. I would welcome the advice of experienced R
users.

As for the first one: I have a data frame with two variables

X  Y
A,   chris
D,   chris
B,   chris
B,   chris
C,   andrew
E,   andrew
C,   andrew
B,   beth
D,  chris
D,   beth
C,   beth
D,   beth
D,   beth
A,   andrew
A,   andrew
A,   andrew
C,   chris
B,   beth
D,   chris
E,   andrew
D,   chris
D,   beth
D,   chris
A,   andrew
A,   chris
Cchris
Achris
Bchris
Cbeth
Achris

I would like to produce a table, with one row for every level of the factor
X, and multiple columns, filled with the observed levels of the factor Y
that are observed jointly with X. Hence:

X   Z1  Z2  Z3
A,  andrew,  chris
B,  chris beth,  chris
C,  andrew,  beth,  chris
D,  chris,  beth
E,  andrew

A solution would be to something like

temp = tapply(Y, X, function(a) levels(a[,drop=TRUE])))


lapply( split(Y,X), unique )

or

lapply( split(Y,X), function(x) as.character(unique(x)))

HTH,

Chuck




and then putting the output in an appropriately sized data frame. The issue
I have with this is that it is inelegant and rather slow for my typical data
set (~200K rows). So I was wondering if a more efficient, nicer solution
exists.

This leads me to a second question. Maybe out of laziness, maybe because R
is good enough, I tend to do all my local data manipulations in R. This
includes de-duping records, joining tables, and grouping observations. I do
this also for larger data sets (say, dense tables with 100M+ elements). Is
this current practice among R users? If so, is there a tutorial, or an R
view on it?  If not, what do you use?

Thanks in advance,

-gappy

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



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
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] ggplot2: problem with large fonts and overlapping labels

2008-08-27 Thread Paul Emberson

Hi,

I am using ggplot2 to generate graphs for a paper I am writing in two 
column format.  When I shrink the graphs to fit in a single column, the 
graph is clear but the axis and tick labels are way too small.


I have increased the font sizes by manipulating the grid.  However, when 
I do this the tick labels and axis labels get very close or even 
overlap, especially on the y-axis.  Is there a way to increase the 
margin between tick labels and axis labels with ggplot or by 
manipulating the grid?


Regards,

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] How to calculate cumulative values for a simple Bernoulli's distribution?

2008-08-27 Thread Ana Kolar
Hi there,

I have two questions and believe that there is an extremely easy solution.
Being a beginner with R makes thinks a bit more complicated.

This is the code:

rpois(15,3)
n-15
DATA-cbind(D,rpois(15,3))

data-as.data.frame(DATA)

colnames(data)-c(D,X)

*# 1. question: is it possible to put the following creation of x in a nicer
form?*

x-c(sum(D0),sum(D0),sum(D0),sum(D0),sum(D0),sum(D0),sum(D0),sum(D0),sum(D0),sum(D0))

p1-seq(0, 1, 0.1)

# Posterior Bernoulli distribution
Bn1-(p1^x*(1-p1)^(n-x))*choose(n,x)
bn1-as.data.frame(Bn1)

# Normalized posterior Bernoulli distribution
f1-1/sum(bn1)
nbn1-bn1*f1
nbn1

# Control check that sum is equal to 1
sum(nbn1)

*# 2. question: how can I calculate cumulative values for nbn1 distribution?
Was looking for the answer on-line but couldn't find anything.*

Your help will be greatly appreciated!!

Good day to all of you

Ana

[[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] Seeking Code for Chaid or Similar

2008-08-27 Thread Daniel Folkinshteyn

on 08/27/2008 09:26 AM David Cobey said the following:

I'm interested in modifying a regression tree algorithm to use the
difference between a control and a dosed sample as its dependent variable.
I was wondering if anyone knew where I could find code to implement a basic
chaid algorithm.  Is it possible to access the code inside of R?  Is there
another place I can find the basic algorithm already coded.


don't know about your specific target, but as a general question of 
seeing the code: to see a function's code in R, just type its name at 
the prompt without parentheses - that will show the code, rather than 
invoke the function.


__
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] Significant digits for checking values of variable?

2008-08-27 Thread David Afshartous

Thanks.  Is there simple way around this for simple checking of single
values?  The all.equal() mentioned in the FAQ doesn't seem appropriate.

 X = c(1.2, 2)
 X.new = X -1
 X == 1.2
[1]  TRUE FALSE
 X.new == .2
[1] FALSE FALSE



On 8/27/08 11:47 AM, jim holtman [EMAIL PROTECTED] wrote:

 FAQ 7.31
 
 On Wed, Aug 27, 2008 at 11:51 AM, David Afshartous
 [EMAIL PROTECTED] wrote:
 
 All,
 
 I'm witnessing some strange behavior when checking the values of one of my
 variables.  My guess is that it has something to do with the number of
 significant digits being represented, but perhaps not as my variable was
 created from other variables that only had one decimal place.  See below.
 I'm sure this is something basic, any suggestions much appreciated.
 
 Cheers,
 David
 
 
 visit.2.SEK.delta.baseline
  [1]  0.1 -0.7  0.8 -0.1 -0.5  0.8  0.7  0.2  0.4  0.3  0.6  0.6  0.3  0.8
 0.8  0.3  0.4  0.8
 visit.2.SEK.delta.baseline  0
  [1]  TRUE FALSE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 visit.2.SEK.delta.baseline ==  .8
  [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
 FALSE FALSE FALSE FALSE FALSE FALSE
 ### but some of the values are equal to .8
 
 ## here it is okay when I try to reproduce
  junk = c(0.1, -0.7,0.8, -0.1, -0.5,  0.8,  0.7,  0.2,  0.4,  0.3,  0.6,
 0.6,
 0.3,  0.8,  0.8,  0.3,  0.4,  0.8 )
 junk == .8
  [1] FALSE FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE
 FALSE  TRUE  TRUE FALSE FALSE  TRUE
 
 __
 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] averaging pairs of columns in a dataframe

2008-08-27 Thread JonD

That's great, thanks!

Jon



Gabor Grothendieck wrote:
 
 Try this:
 
 # test data
 DF - data.frame(a = 1:9, a = 21:29, b = 31:39, b = 41:49, check.names =
 FALSE)
 
 t(apply(DF, 1, tapply, names(DF), mean))
 
 It gives a matrix so use as.data.frame on that if you need a data frame
 
 
 

-- 
View this message in context: 
http://www.nabble.com/averaging-pairs-of-columns-in-a-dataframe-tp19181319p19184350.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] Significant digits for checking values of variable?

2008-08-27 Thread jim holtman
Try this using 'sapply'

 sapply(X.new, all.equal, .2) == TRUE
[1]  TRUE FALSE


On Wed, Aug 27, 2008 at 12:13 PM, David Afshartous
[EMAIL PROTECTED] wrote:

 Thanks.  Is there simple way around this for simple checking of single
 values?  The all.equal() mentioned in the FAQ doesn't seem appropriate.

  X = c(1.2, 2)
 X.new = X -1
 X == 1.2
 [1]  TRUE FALSE
 X.new == .2
 [1] FALSE FALSE



 On 8/27/08 11:47 AM, jim holtman [EMAIL PROTECTED] wrote:

 FAQ 7.31

 On Wed, Aug 27, 2008 at 11:51 AM, David Afshartous
 [EMAIL PROTECTED] wrote:

 All,

 I'm witnessing some strange behavior when checking the values of one of my
 variables.  My guess is that it has something to do with the number of
 significant digits being represented, but perhaps not as my variable was
 created from other variables that only had one decimal place.  See below.
 I'm sure this is something basic, any suggestions much appreciated.

 Cheers,
 David


 visit.2.SEK.delta.baseline
  [1]  0.1 -0.7  0.8 -0.1 -0.5  0.8  0.7  0.2  0.4  0.3  0.6  0.6  0.3  0.8
 0.8  0.3  0.4  0.8
 visit.2.SEK.delta.baseline  0
  [1]  TRUE FALSE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 visit.2.SEK.delta.baseline ==  .8
  [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
 FALSE FALSE FALSE FALSE FALSE FALSE
 ### but some of the values are equal to .8

 ## here it is okay when I try to reproduce
  junk = c(0.1, -0.7,0.8, -0.1, -0.5,  0.8,  0.7,  0.2,  0.4,  0.3,  0.6,
 0.6,
 0.3,  0.8,  0.8,  0.3,  0.4,  0.8 )
 junk == .8
  [1] FALSE FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE
 FALSE  TRUE  TRUE FALSE FALSE  TRUE

 __
 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 that 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] Fw: How to learn R language?

2008-08-27 Thread Roland Rau

Ajay ohri wrote:

   - go with Bob and Peter's book. Too many sources can be confusing.
   - Join the list, create filters for keywords of your specialty (like from
   R -Help ) contains regression.
   - Try use it for a live project .


I think this is really very good advice:
- 2 books (I would recommend Peter Dalgaard's and Modern Applied 
Statistics by Venables/Ripley)

- the R-help list is very, very valuable
- most importantly: use it for some real project

Please let me add two more things:
- the road is long. Even after years using it exclusively as your 
statistical language/package of choice, there are still surprises around 
the corner (at least it happens to me, just discovered '.bquote' a few 
weeks ago)
- have an open mind. For example, if you have a background in SPSS, 
Excel, ... but not in general purpose programming languages, you might 
be surprised that your data don't have to be in rectangular shape. In my 
experience this is one of the first obstacles for students with a social 
science background.
- You get often world-class help and advice *for free* on the r-help 
list. So please read the posting guide before posting questions to the 
r-help list. This will save you some answer which might appear to be 
rude (but usually answer your question anyway).


I hope this helps you further,
Roland

__
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] Quantitative risk analysis with R

2008-08-27 Thread Graham Smith
Recently a course with this title, from Vose consulting, was announced
on the list. Does anyone know of  any books/websites/downloadable
tutorials etc that cover the same ground.

ie not just quantitative risk analysis, but specifically on using R
for risk analysis and as an alternative to @Risk/Crystal Ball.

Many thanks,

Graham

__
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] RCurl: using netrc with curlPerform

2008-08-27 Thread Valerie Obenchain

Thanks Martin!
Valerie


Martin Morgan wrote:

Hi Valerie --

curlPerform is expecting the url to be an option that is named, i.e.,

  

myopts -curlOptions(netrc=1)
url - http://www.omegahat.org/RCurl/testPassword/index.html;
cat(curlPerform(url=url, .opts=myopts))



!DOCTYPE HTML PUBLIC -//IETF//DTD HTML//EN
html head
titleBasic Password Test/title
/head

body
h1Basic Password Test/h1
This is a test page.
If you can read it, you have correctly supplied
the password.


hr
addressa href=http://stat.ucdavis.edu/~duncan;Duncan Temple Lang/a
a href=mailto:[EMAIL PROTECTED]lt;[EMAIL PROTECTED]gt;/a/address
!-- hhmts start --
Last modified: Sun Aug  1 13:57:44 PDT 2004
!-- hhmts end --
/body /html

(also curlPerform(url=url, netrc=1))

Martin


Valerie Obenchain [EMAIL PROTECTED] writes:

  

Hello,

I am having trouble getting the curlPerform function to authenticate
using the .netrc file. From the documentation I've read it
certainly seems as though this function should be able to authenticate
via the .netrc file. 


The example I am using here comes from the R as a Web Client- the
RCurl package paper and demonstrates using the .netrc file to access
the www.omegahat.org page. Authentication takes place by RCurl (curl)
reading the username and password out of the .netrc file in the user's
home directory. For this example the username is bob and password is
welcome. The .netrc file in the user's home directory contains the
following information:
machine www.omegahat.org
login bob
password welcome


I can successfully use the .netrc file with the getURL function:
  getURL(http://www.omegahat.org/RCurl/testPassword/index.html;, netrc=1)

[1] !DOCTYPE HTML PUBLIC \-//IETF//DTD HTML//EN\\nhtml head\ntitleBasic Password Test/title\n/head\n\nbody\nh1Basic Password Test/h1\nThis is a test page.\nIf you can read it, you have correctly supplied\nthe password.\n\n\nhr\naddressa href=\http://stat.ucdavis.edu/~duncan\;Duncan Temple Lang/a\na href=mailto:[EMAIL PROTECTED]lt;[EMAIL PROTECTED]gt;/a/address\n!-- 
hhmts start --\nLast modified: Sun Aug  1 13:57:44 PDT 2004\n!--

hhmts end --\n/body /html\n


When I try to do the same with the curlPerform function I get an error
saying that the curl option is not recognized. I have tried 3
different
ways of instructing the curlPerform function to use the .netrc file
(in the .opts, curl handle and the ... argument) but got the same
error message each time.

# Failed attempt using .opts construct
myopts -curlOptions(netrc=1)
curlPerform(http://www.omegahat.org/RCurl/testPassword/index.html;,
.opts=myopts)

# Failed attempt using curl handle
handle - getCurlHandle(netrc=1)
curlPerform(http://www.omegahat.org/RCurl/testPassword/index.html;,
curl=handle)

# Failed attempt using ... construct
curlPerform(http://www.omegahat.org/RCurl/testPassword/index.html;,
netrc=1)

Common error message for all failed attempts:
Error in mapCurlOptNames(names(.els), asNames = TRUE) :
  Unrecognized CURL options:


Valid curl option names are listed by typing listCurlOptions() and
netrc is one of the options. The mapCurlOptNames code is not available
for the user to view so I'm not able to deduce anything more from the
error message.


Thanks,
Valerie

__
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] accessing sd and var functions in embedded app

2008-08-27 Thread EBo
I am able to call R functions like min, mean, and mad from from a C/C++
embedded application, but when I try to get the standard deviation or variance
(sd, var) R segfaults.  Can someone suggest how to resolve this?

Thanks and best regards,

  EBo --

__
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] Simple programming problem with 'with' or 'data ='

2008-08-27 Thread Peter Flom
Hello

I wrote a simple program to modify a boxplot:



gdsbox - function(indvar){
boxplot(indvar~gds3lev, 
   main = paste('Boxplot of', substitute(indvar), for GDS groups),
   names = c('1', '3', '4, 5, 6'))
}



If I attach the dataframe gdsgraph, this works fine. However, I've been warned 
against attach.  When I tried to run this program using 'with', it did not work.

e.g. 

   with(gdsgraph, gdsbox(BReT3T5T))

produced an error that gds3level was not found

but if I try

  with(gdsgraph, boxplot(BReT3T5T~gds3lev))

it works fine.

Similar problems occurred when I tried to use data =

What am I missing?

Thanks

Peter




Peter L. Flom, PhD
Brainscope, Inc.
212 263 7863 (MTW)
917 488 7176 (ThF)



[[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] Calculating total observations based on combinations of variable values

2008-08-27 Thread Dylan Beaudette
On Wednesday 27 August 2008, Josip Dasovic wrote:
 Hello:

 As someone making the move from STATA to R, I'm finding it difficult at
 times to perform basic tasks in R, so forgive me if I've missed an obvious
 and easily obtained solution to my problem.   I've searched the help guides
 and the archives and have not been able to find a solution that works.

 I have a data frame with thousands of observations that looks something
 like this:

 YEAR MONTH DAY   COUNTRY REGION  PROVINCE  
CITY 1994 1  22 Sri Lanka South Asia   Northern (Province)  
 Pungudutivu 1994 1  25 Sri Lanka South AsiaCentral
 (Province) Kandy 1994 2  26 Sri Lanka South Asia   
 Central (Province) Kandy 1994 2  28 Sri Lanka South
 AsiaEastern (Province) Wakianeri 1994 6  28 Sri Lanka  
   South AsiaEastern (Province)Valachenai 1994 6  31 Sri
 Lanka South AsiaCentral (Province) Kandy 1995 3
   1 Sri Lanka South Asia  North (Province)   Kilinochchi
 1995 3   6 Sri Lanka South AsiaWestern (Province)  
 Colombo 1995 7  15 Sri Lanka South Asia   Northern (Province)  
Mankulam 1995 7  23 Sri Lanka South Asia   Northern
 (Province)   Point Pedro 1995 9  25 Sri Lanka South Asia  
 Northern (Province)Kilali ...

 What I would like to do is to calculate the total number of observations by
 unique combinations of the values of (some of the) variables above.

 For example, I would like to know how many observations (i.e. rows) have
 the values YEAR==1994 and MONTH==1.

 In the end, I'd like a table that looks like this:

 YEAR MONTH #OBS
 1994 1  2
 1994 2  2
 1994 3  0
 1994 4  0
 1994 5  0
 1994 6  2
 1994 7  0
 1994 8  0
 1994 9  0
 1994 10  0
 1994 11  0
 1994 12  0
 1995 1  0
 1995 2  0
 1995 3  2
 1995 4  0
 ...

 I do need to fill out the table with all the possible combinations, even
 where there are no observations with that combination in the data set. At
 first, it seemed like this would not be  think that aggregate is probably
 the way to go, but there doesn't seem to be an appropriate summary function
 (FUN) available.  Thanks in advance for any help in this matter,

 Josip


?table
?xtabs

-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

__
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] Calculating total observations based on combinations of variable values

2008-08-27 Thread Henrique Dallazuanna
Try this:

merge(aggregate(x$DAY, x[, c(YEAR, MONTH)], length),
  data.frame(YEAR = unique(x$YEAR), MONTH = 1:12), all = T)

On Wed, Aug 27, 2008 at 2:11 PM, Josip Dasovic [EMAIL PROTECTED] wrote:

 Hello:

 As someone making the move from STATA to R, I'm finding it difficult at
 times to perform basic tasks in R, so forgive me if I've missed an obvious
 and easily obtained solution to my problem.   I've searched the help guides
 and the archives and have not been able to find a solution that works.

 I have a data frame with thousands of observations that looks something
 like this:

 YEAR MONTH DAY   COUNTRY REGION  PROVINCE
CITY
 1994 1  22 Sri Lanka South Asia   Northern (Province)
 Pungudutivu
 1994 1  25 Sri Lanka South AsiaCentral (Province)
   Kandy
 1994 2  26 Sri Lanka South AsiaCentral (Province)
   Kandy
 1994 2  28 Sri Lanka South AsiaEastern (Province)
 Wakianeri
 1994 6  28 Sri Lanka South AsiaEastern (Province)
  Valachenai
 1994 6  31 Sri Lanka South AsiaCentral (Province)
   Kandy
 1995 3   1 Sri Lanka South Asia  North (Province)
 Kilinochchi
 1995 3   6 Sri Lanka South AsiaWestern (Province)
 Colombo
 1995 7  15 Sri Lanka South Asia   Northern (Province)
  Mankulam
 1995 7  23 Sri Lanka South Asia   Northern (Province)
 Point Pedro
 1995 9  25 Sri Lanka South Asia   Northern (Province)
  Kilali
 ...

 What I would like to do is to calculate the total number of observations by
 unique combinations of the values of (some of the) variables above.

 For example, I would like to know how many observations (i.e. rows) have
 the values YEAR==1994 and MONTH==1.

 In the end, I'd like a table that looks like this:

 YEAR MONTH #OBS
 1994 1  2
 1994 2  2
 1994 3  0
 1994 4  0
 1994 5  0
 1994 6  2
 1994 7  0
 1994 8  0
 1994 9  0
 1994 10  0
 1994 11  0
 1994 12  0
 1995 1  0
 1995 2  0
 1995 3  2
 1995 4  0
 ...

 I do need to fill out the table with all the possible combinations, even
 where there are no observations with that combination in the data set.
 At first, it seemed like this would not be  think that aggregate is
 probably the way to go, but there doesn't seem to be an appropriate summary
 function (FUN) available.  Thanks in advance for any help in this matter,

 Josip

 __
 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

[[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] Two envelopes problem

2008-08-27 Thread Greg Snow
The reason that taking the log fixes things is because log( 2 ) = -log( 1/2 ), 
so log takes us to an additive difference.

I think the use of log(utility) is actually based on experiments where people 
were asked what they were willing to risk for various potential gains and the 
results were more similar to the log than any other simple function (plus it 
makes sense based on the above).

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Mark Leeds
 Sent: Tuesday, August 26, 2008 9:44 AM
 To: 'Duncan Murdoch'
 Cc: r-help@r-project.org
 Subject: Re: [R] Two envelopes problem

 Hi Duncan: I think I get you. Once one takes expectations,
 there is an underlying assumption about the distribution of X
 and , in this problem, we don't have one so taking
 expectations has no meaning.

 If the log utility fixing the problem is purely just a
 coincidence, then it's surely an odd one because log(utility)
 is often used in economics for expressing how investors view
 the notion of accumulating capital versus the risk of losing
 it. I'm not a economist but it's common for them  to use log
 utility to prove theorems about optimal consumption etc.

 Thanks because I think I see it now by your example below.

Mark





 -Original Message-
 From: Duncan Murdoch [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, August 26, 2008 11:26 AM
 To: Mark Leeds
 Cc: r-help@r-project.org
 Subject: Re: [R] Two envelopes problem

 On 8/26/2008 9:51 AM, Mark Leeds wrote:
  Duncan: I think I see what you're saying but the strange
 thing is that
  if you use the utility function log(x) rather than x, then the
  expected
 values
  are equal.


 I think that's more or less a coincidence.  If I tell you
 that the two envelopes contain X and 2X, and I also tell you
 that X is 1,2,3,4, or 5, and you open one and observe 10,
 then you know that X=5 is the content of the other envelope.
 The expected utility of switching is negative using any
 increasing utility function.

 On the other hand, if we know X is one of 6,7,8,9,10, and you
 observe a 10, then you know that you got X, so the other
 envelope contains 2X = 20, and the expected utility is positive.

 As Heinz says, the problem does not give enough information
 to come to a decision.  The decision *must* depend on the
 assumed distribution of X, and the problem statement gives no
 basis for choosing one.  There are probably some subjective
 Bayesians who would assume a particular default prior in a
 situation like that, but I wouldn't.

 Duncan Murdoch

 Somehow, if you are correct and I think you are, then taking the
  log , fixes the distribution of x which is kind of odd to me. I'm
  sorry
 to
  belabor this non R related discussion and I won't say anything more
  about
 it
  but I worked/talked  on this with someone for about a month a few
  years
 ago
  and we gave up so it's interesting for me to see this again.
 
 Mark
 
  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED]
 On
  Behalf Of Duncan Murdoch
  Sent: Tuesday, August 26, 2008 8:15 AM
  To: Jim Lemon
  Cc: r-help@r-project.org; Mario
  Subject: Re: [R] Two envelopes problem
 
  On 26/08/2008 7:54 AM, Jim Lemon wrote:
  Hi again,
  Oops, I meant the expected value of the swap is:
 
  5*0.5 + 20*0.5 = 12.5
 
  Too late, must get to bed.
 
  But that is still wrong.  You want a conditional expectation,
  conditional on the observed value (10 in this case).  The answer
  depends on the distribution of the amount X, where the envelopes
  contain X and 2X.  For example, if you knew that X was at
 most 5, you
  would know you had just observed 2X, and switching would be
  a bad idea.
 
  The paradox arises because people want to put a nonsensical Unif(0,
  infinity) distribution on X.  The Wikipedia article points
 out that it
  can also arise in cases where the distribution on X has
 infinite mean:
  a mathematically valid but still nonsensical possibility.
 
  Duncan Murdoch
 
  __
  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-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, 

Re: [R] Integrate a 1-variable function with 1 parameter (Jose L. Romero)

2008-08-27 Thread jose romero
To Ravi Varadhan and Peter Dalgaard:

Infinite thanks for your help and suggestions- they were very instructive, as i 
have still to learn on the appropriate use of the apply family of functions.

jlrp


--- On Wed, 8/27/08, Ravi Varadhan [EMAIL PROTECTED] wrote:

 From: Ravi Varadhan [EMAIL PROTECTED]
 Subject: RE: [R] Integrate a 1-variable function with 1 parameter (Jose L. 
 Romero)
 To: [EMAIL PROTECTED], r-help@r-project.org
 Date: Wednesday, August 27, 2008, 2:42 PM
 Here is one way:
 
 integrand - function (t, x) {
   exp(-2*t)*(2*t)^x/(10*factorial(x))
 }
 
 x - 0:44
 ans - sapply(x, function(x) integrate(integrand,
 lower=0, upper=10, x=x))
 cbind(x=x, integral=unlist(ans[1,]),
 abs.error=unlist(ans[2,]))
  
 
 Ravi.
 
 
 ---
 
 Ravi Varadhan, Ph.D.
 
 Assistant Professor, The Center on Aging and Health
 
 Division of Geriatric Medicine and Gerontology 
 
 Johns Hopkins University
 
 Ph: (410) 502-2619
 
 Fax: (410) 614-9625
 
 Email: [EMAIL PROTECTED]
 
 Webpage: 
 http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html
 
  
 
 
 
 
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On
 Behalf Of jose romero
 Sent: Wednesday, August 27, 2008 10:24 AM
 To: r-help@r-project.org
 Subject: [R] Integrate a 1-variable function with 1
 parameter (Jose L.
 Romero)
 
 Hey fellas:
 
 I would like to integrate the following function:
 
 integrand - function (x,t) {
   exp(-2*t)*(2*t)^x/(10*factorial(x))
 }
 
 with respect to the t variable, from 0 to 10.
 The variable x here works as a parameter: I would like to
 integrate the said
 function for each value of x in 0,1,..,44.
 
 I have tried Vectorize to no avail.
 
 Thanks in advance,
 jose romero
 
 __
 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] Combine x-axis labels size

2008-08-27 Thread Dani Valverde

Hello,
I would like to combine different label sizes in the same x-axis, for 
example

1 2 3 4 5 6 7 8 9
How can I do it?
Best,

Dani

--
Daniel Valverde Saubí

Grup de Biologia Molecular de Llevats
Facultat de Veterinària de la Universitat Autònoma de Barcelona
Edifici V, Campus UAB
08193 Cerdanyola del Vallès- SPAIN

Centro de Investigación Biomédica en Red
en Bioingeniería, Biomateriales y
Nanomedicina (CIBER-BBN)

Grup d'Aplicacions Biomèdiques de la RMN
Facultat de Biociències
Universitat Autònoma de Barcelona
Edifici Cs, Campus UAB
08193 Cerdanyola del Vallès- SPAIN
+34 93 5814126

__
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] Simple programming problem with 'with' or 'data ='

2008-08-27 Thread Duncan Murdoch

On 8/27/2008 1:15 PM, Peter Flom wrote:

Hello

I wrote a simple program to modify a boxplot:



gdsbox - function(indvar){
boxplot(indvar~gds3lev, 
   main = paste('Boxplot of', substitute(indvar), for GDS groups),

   names = c('1', '3', '4, 5, 6'))
}





If I attach the dataframe gdsgraph, this works fine. However, I've been warned 
against attach.  When I tried to run this program using 'with', it did not work.

e.g. 


   with(gdsgraph, gdsbox(BReT3T5T))

produced an error that gds3level was not found

but if I try

  with(gdsgraph, boxplot(BReT3T5T~gds3lev))

it works fine.

Similar problems occurred when I tried to use data =

What am I missing?


You defined your gdsbox function in the global environment, which means 
it will go looking for non-local variables there.  It doesn't matter 
where you call it from, R uses lexical scoping.


To get what you want, you could define your function within the with, i.e.

with(gdsgraph, {

 gdsbox - function(indvar){
 boxplot(indvar~gds3lev,
main = paste('Boxplot of', substitute(indvar), for GDS groups),
names = c('1', '3', '4, 5, 6'))
 }

 gdsbox(BReT3T5T)
})

but this misses the point of defining gdsbox once, and using it in many 
places.  So I'd say the best thing to do is to change the definition of 
it to use the data argument, i.e.


gdsbox - function(indvar, data) {
boxplot(indvar~gds3lev,
main = paste('Boxplot of', substitute(indvar), for GDS groups),
names = c('1', '3', '4, 5, 6'), data=data)
 }

and call it as

gdsbox(BReT3T5T, gdsgraph)

There are ways to make your function act as though it doesn't use 
lexical scoping (parent.env, etc.), but they are ugly, and I don't think 
they're necessary here.


Duncan Murdoch

__
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] Combine x-axis labels size

2008-08-27 Thread baptiste auguie

Hi,

I'm not sure I understand what you want, but perhaps:



x - 1:9
y - x
plot(x, y, ann=F, xaxt=n)
axis(1, lab=F) - positions
mtext(paste(positions), side = 1, line = 1, outer = F, at = test,  
cex=1:length(positions))



HTH,

baptiste

On 27 Aug 2008, at 18:36, Dani Valverde wrote:


Hello,
I would like to combine different label sizes in the same x-axis,  
for example

1 2 3 4 5 6 7 8 9
How can I do it?
Best,

Dani

--
Daniel Valverde Saubí

Grup de Biologia Molecular de Llevats
Facultat de Veterinària de la Universitat Autònoma de Barcelona
Edifici V, Campus UAB
08193 Cerdanyola del Vallès- SPAIN

Centro de Investigación Biomédica en Red
en Bioingeniería, Biomateriales y
Nanomedicina (CIBER-BBN)

Grup d'Aplicacions Biomèdiques de la RMN
Facultat de Biociències
Universitat Autònoma de Barcelona
Edifici Cs, Campus UAB
08193 Cerdanyola del Vallès- SPAIN
+34 93 5814126

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


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

__
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] Combine x-axis labels size

2008-08-27 Thread baptiste auguie

Whoops, typo in my previous post:


x - 1:10
y - x
plot(x, y, ann=F, xaxt=n)
axis(1, lab=F) - positions
mtext(paste(positions), side = 1, line = 1, outer = F, at = positions,  
cex=seq(1, 9, length=length(positions)))


Is this what you mean by label sizes?

On 27 Aug 2008, at 18:51, baptiste auguie wrote:


Hi,

I'm not sure I understand what you want, but perhaps:



x - 1:9
y - x
plot(x, y, ann=F, xaxt=n)
axis(1, lab=F) - positions
mtext(paste(positions), side = 1, line = 1, outer = F, at = test,  
cex=1:length(positions))



HTH,

baptiste

On 27 Aug 2008, at 18:36, Dani Valverde wrote:


Hello,
I would like to combine different label sizes in the same x-axis,  
for example

1 2 3 4 5 6 7 8 9
How can I do it?
Best,

Dani

--
Daniel Valverde Saubí

Grup de Biologia Molecular de Llevats
Facultat de Veterinària de la Universitat Autònoma de Barcelona
Edifici V, Campus UAB
08193 Cerdanyola del Vallès- SPAIN

Centro de Investigación Biomédica en Red
en Bioingeniería, Biomateriales y
Nanomedicina (CIBER-BBN)

Grup d'Aplicacions Biomèdiques de la RMN
Facultat de Biociències
Universitat Autònoma de Barcelona
Edifici Cs, Campus UAB
08193 Cerdanyola del Vallès- SPAIN
+34 93 5814126

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


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

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


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

__
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] Two envelopes problem

2008-08-27 Thread Greg Snow
 -Original Message-
 From: Mario [mailto:[EMAIL PROTECTED]
 Sent: Monday, August 25, 2008 5:41 PM
 To: Greg Snow
 Cc: r-help@r-project.org
 Subject: Re: [R] Two envelopes problem

 Dear Greg,

   The problem is that in your code you are creating a
 distribution where there are only 5-10 and 10-20 pairs. Yes,
 if I knew that there are only those two types of pairs, and
 if I new that the probability of each pair was .50, .50, then
 it is advantageous to switch, but that is because I have a
 priori information on the distribution of the pairs. Now lets
 assume, I opened the envelope, and I see £20, should I
 switch? Well, now it depends. Are you going to rewrite the
 simulation so that line 1 within tmpfun reads x  -
 sample(c(10,20), 1)? otherwise is not going to work. The
 question is, if I see £20, according to my friend's argument,
 I should switch, since there is a 50% chance of seeing 40 and
 a 50% chance of seeing 10. However, in your simulation, £40's
 are never seen, so under your simulator, switching every time
 you see a £20 is a sure loss. You see, that's the problem.
 You don't know the distribution of pairs, the fact that
 you've got a tenner note, does not give you any additional
 information. By the way, you could run your example with my
 own code (which is faster as I'm not using sample for the
 creation of the env pairs), just define the function

 r5.10 - function(n) return (sample(c(5,10), n, rep=T))

 and now:

 env - generateenv(r=2, r5.10, n=1e6)
 i10 - which(env[,1]==10)
 mean(env[i10,1]) # Exactly 10
 mean(env[i10,2]) # ~ 12.50 you do get a definite advantage
 when switching

 But this is an example that was tailored to work with the
 actual value of £10.

Yes, conditional on you seeing 10, the only posibilities for x is 5 or 10.  If 
you want a more general approach, try this:

 generateenv - function (r, rdist, n, ...) {
+   env - matrix(0, ncol=2, nrow=n)
+   env[,1] - rdist(n, ...)  # first envelope has `x'
+   env[,2] - r*env[,1]  # second envelope has `r*x'
+
+   # randomize de envelopes, so we don't know which one from
+   # the pair has `x' or `r*x'
+   i - as.logical(rbinom(n, 1, 0.5))
+   renv - env
+   renv[i,1] - env[i,2]
+   renv[i,2] - env[i,1]
+
+   return(renv)  # return the randomized envelopes
+ }

 TeachingDemos::char2seed('envelope')
 # same as
 # set.seed(5190728)

 env - generateenv(r=2, rpois, n=1e6, lambda=10)
 # keep envelope # 1 strategy (no conditioning)
 mean(env[,1])
[1] 15.00811

 # given envelope #1 == 10, expected value of switching
 mean( env[ env[,1]==10, 2] )
[1] 16.54452


I generate data using your function and low and behold, given that the 1st 
envelope is 10, the switching strategy is the winner.  However this is 
dependent on the distribution of x, change the distribution and the expected 
gain can either increase or decrease.

But the original puzzle does not say anything about the distribution of x (or 
implies uniform on 0,Infinity like Duncan mentions).

If you want this to work for any possible value of the 1st envelope, then the 
distribution of x needs to be the improper infinite uniform, but once you give 
a specific value to condition on, then the distribution of x only needs to be 
relatively flat in the region of the value of the 1st envelope and half that 
value (10 and 5 in this case):

 env - generateenv(r=2, function(n,...) sample(3:52,n,replace=TRUE), n=1e6)
 mean( env[ env[,1]==10, 2] )
[1] 12.55169

(expected value still greater than 10)

Your original post says that you told your friend that he was talking nonsense, 
the real case is that you are working from a different set of assumptions than 
your friend, and answering a different question.  So in a sense you were both 
correct, just working from different sets of assumptions of what was beyond the 
stated question.  My intent (beyond continuing the discussion/contriversy) was 
to show that you were answering a different question than your friend and that 
your answer to the different question does not make your friend's answer to his 
question wrong.


One correction, in my prior post I talked about the n-envelope problem.  The 
strategy that I mentioned maximizes the probability of getting the envelope 
with the highest value, not the expected value, any strategy for expected value 
would depend on the distribution of the values which is not known in that 
problem.  Similar but different.

Is the idea that whichever envelope you choose, the strategy should be to 
switch is really that unbelievable?  Just ask anyone with at least 2 children, 
more often than not when you give them something, they will all be convinced 
that someone else received more/better.  My daughters once even counted the 
number of beans I put on their plate (their utility was the less was better), 
then the one with fewer pointed out that her beans were longer (I put a stop to 
it before they got out a ruler).


 system.time(env - generateenv(r=2, r5.10, n=1e6))   # 0.500   0.020
 

[R] problems formating scientific collaboration data

2008-08-27 Thread Grant Gillis
Hello all and thanks in advance for any help or direction.  I have
co-authorship data that looks like:


PaperAuthor  Year
1   SmithKK  JonesSD   2008
2   WallaceAR  DarwinCA  1999
3   HawkingS2003


I would like:
Paper  Author  Year
1 SmithKK   2008
1 JonesSD   2008
2 WallaceAR   1999
2  DarwinCA1999
3  HawkingS2003



Thanks for your patience with what is likely an easy question
 r-help@r-project.org

[[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] problems formating scientific collaboration data

2008-08-27 Thread Dong-hyun Oh

Hi,

name of the data.frame is assumed to be dt.

cnt.tmp - strsplit(dt$Author,  )
cnt - sapply(cnt.tmp, length)
paper.cnt - dt$Paper[cnt]
author - unlist(cnt.tmp)
year - dt$Year[cnt]

dt.new - data.frame(Paper = paper.cnt, Author = author, Year = year)

HTH,
Dong-hyun Oh

On Aug 27, 2008, at 9:27 PM, Grant Gillis wrote:


Hello all and thanks in advance for any help or direction.  I have
co-authorship data that looks like:


PaperAuthor  Year
1   SmithKK  JonesSD   2008
2   WallaceAR  DarwinCA  1999
3   HawkingS2003


I would like:
Paper  Author  Year
1 SmithKK   2008
1 JonesSD   2008
2 WallaceAR   1999
2  DarwinCA1999
3  HawkingS2003



Thanks for your patience with what is likely an easy question
r-help@r-project.org

[[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] lattice: plotting an arbitrary number of panels, defining arbitrary groups

2008-08-27 Thread Deepayan Sarkar
On Tue, Aug 26, 2008 at 6:56 PM, Alex Karner [EMAIL PROTECTED] wrote:
 Thanks Deepayan, works like a charm.

 A followup question though--I'd like to produce the same data on four
 panels with the final two zoomed in, i.e. plotted with shorter x and
 y axes. Since I can't access panel.number in the prepanel function,
 and since updating the plot with lists of the new x and y axis ranges
 via xlim and ylim doesn't work (I think since I only actually have one
 repeated panel),

There is no simple way to do this. The lattice model associates axis
limits with packets (data subsets that go in panels) and not panels
(i.e., if two or more panels display the same packet, they will also
have the same limits). One way to work around this is to override the
default axis annotation. The easier solution is to make a second copy
of your data. E.g.,

dataSet2 -
make.groups(full = dataSet,
sub = subset(dataSet, Value  y1  Value  y2 
Detector  x1  Detector  x2))


p - xyplot(Value ~ Detector | which, dataSet2, scales = free)

and then proceed as before.

-Deepayan

__
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] problems formating scientific collaboration data

2008-08-27 Thread Jorge Ivan Velez
Dear Grant,

Try this:

x=Paper,Author, Year
1,SmithKK JonesSD,   2008
2,WallaceAR DarwinCA,  1999
3,HawkingS, 2003

X=read.delim2(textConnection(x),sep=,,header=TRUE)
closeAllConnections()

author= strsplit(as.character(X$Author), )
l=lapply(author,length)
P=rep(X$Paper,l)
Y=P=rep(X$Year,l)

X.new=data.frame(Paper=P,Authore=unlist(author),Year=Y)
X.new


HTH,

Jorge


On Wed, Aug 27, 2008 at 3:27 PM, Grant Gillis [EMAIL PROTECTED]wrote:

 Hello all and thanks in advance for any help or direction.  I have
 co-authorship data that looks like:


 PaperAuthor  Year
 1   SmithKK  JonesSD   2008
 2   WallaceAR  DarwinCA  1999
 3   HawkingS2003


 I would like:
 Paper  Author  Year
 1 SmithKK   2008
 1 JonesSD   2008
 2 WallaceAR   1999
 2  DarwinCA1999
 3  HawkingS2003



 Thanks for your patience with what is likely an easy question
  r-help@r-project.org

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


[[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] problems formating scientific collaboration data

2008-08-27 Thread Jorge Ivan Velez
I'm sorry Grant, my bad. To reproduce what you'd like to do, my previous
code should be:


x=Paper,Author, Year
1,SmithKK JonesSD,   2008
2,WallaceAR DarwinCA,  1999
3,HawkingS, 2003

X=read.delim2(textConnection(x),sep=,,header=TRUE)
closeAllConnections()

author= strsplit(as.character(X$Author), )
l=lapply(author,length)
P=rep(X$Paper,l)
Y=rep(X$Year,l)

 X.new=data.frame(Paper=P,Author=unlist(author),Year=Y)
 X.new

HTH,

Jorge



On Wed, Aug 27, 2008 at 3:59 PM, Jorge Ivan Velez
[EMAIL PROTECTED]wrote:


 Dear Grant,

 Try this:

 x=Paper,Author, Year
 1,SmithKK JonesSD,   2008
 2,WallaceAR DarwinCA,  1999
 3,HawkingS, 2003

 X=read.delim2(textConnection(x),sep=,,header=TRUE)
 closeAllConnections()

 author= strsplit(as.character(X$Author), )
 l=lapply(author,length)
 P=rep(X$Paper,l)
 Y=P=rep(X$Year,l)

 X.new=data.frame(Paper=P,Authore=unlist(author),Year=Y)
 X.new


 HTH,

 Jorge



 On Wed, Aug 27, 2008 at 3:27 PM, Grant Gillis [EMAIL PROTECTED]wrote:

 Hello all and thanks in advance for any help or direction.  I have
 co-authorship data that looks like:


 PaperAuthor  Year
 1   SmithKK  JonesSD   2008
 2   WallaceAR  DarwinCA  1999
 3   HawkingS2003


 I would like:
 Paper  Author  Year
 1 SmithKK   2008
 1 JonesSD   2008
 2 WallaceAR   1999
 2  DarwinCA1999
 3  HawkingS2003



 Thanks for your patience with what is likely an easy question
  r-help@r-project.org

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





[[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] r function for calculating extreme spread in group

2008-08-27 Thread Steven Matthew Anderson
I'm trying to figure out how to write a r function that will calculate  
the extreme spread of a group of points given their (x,y)  
coordinates.  Extreme Spread is the maximal Euclidean distance between  
two points in a group


ex.spread = max{ sqrt [ (xi-xj)^2 - (yi-yj)^2 ] } for i not equal to j

I have 60 levels to apply this to.

There is the combination function in the dprep package but I wasn't  
sure how to use this or apply an index the points in each group.


Any ideas?



Steve





Steven Matthew Anderson
[EMAIL PROTECTED]

Ad Astra per Aspera

__
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] Basic question about X11()

2008-08-27 Thread Patrick Connolly
On Wed, 27-Aug-2008 at 02:42PM +0200, Groeneweg M (GEN) wrote:

| Hello,
|  
| I have a basic question about the display() function, but I can't find the 
answer easily.
|  
| I am running R 2.7.16.0 on Suse linux 11.0

Are you sure of that? R-2.7.2 is the most recent.


|  with KDE 4.0


Your question is one relating to your window manager.  The display
parameter for x11() does not relate to desktops.  All the desktops are
part of the same display.  Some very clever R-devel people might be
able to think of a way of making a specific X call to achieve what you
want, but it seems unlikely to me that it could be make to work with
more than one window manager.

It's very simple in KDE to set up keyboard shortcuts to move a window
to a specific desktop.

HTH

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~} Great minds discuss ideas
 _( Y )_Middle minds discuss events 
(:_~*~_:)Small minds discuss people  
 (_)-(_)   . Anon
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
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] conversion of data structure between R and Perl

2008-08-27 Thread kevinchang

Dear R users,

I am trying to call a Perl subroutine from R . The subroutine returns an
arrray contaning three elements wihch are all strings. But the calling in R 
return an integer which is 0. I have no idea how this could happen. Maybe
becasue I shouldn't use system() in R or I should load a particular package
for my R in windows. Please help 

---
the perl subroutine in presentPerformance.pl

sub findAccuracy{
while(defined($filename=glob(*.log))){

open(WORDLIST , $filename)||die(can't open the file!);
while($line=WORDLIST){

if ($line=~m/accuracy/){
  $line=~s/-accuracy://;
   
@temp=split( ,$line);
$temp[0]=~s/\%//; 
$temp[2]=~s/\%//;  
@accInfoList=($temp[0],$temp[2],$filename);

}
   
}   


}
return(@accInfoList)

}


findAccuracy();

The R code 

 class(system(perl presentPerformance.pl))
[1] integer




regard,
Shu-Kai Chang
-- 
View this message in context: 
http://www.nabble.com/conversion-of-data-structure-between-R-and-Perl-tp19189221p19189221.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] conversion of data structure between R and Perl

2008-08-27 Thread Rolf Turner


You need to do:

system(perl presentPerformance.pl,intern=TRUE)

It does pay to read the help, you know.

cheers,

Rolf Turner

On 28/08/2008, at 8:36 AM, kevinchang wrote:



Dear R users,

I am trying to call a Perl subroutine from R . The subroutine  
returns an
arrray contaning three elements wihch are all strings. But the  
calling in R
return an integer which is 0. I have no idea how this could happen.  
Maybe
becasue I shouldn't use system() in R or I should load a particular  
package

for my R in windows. Please help 

---
the perl subroutine in presentPerformance.pl

sub findAccuracy{
while(defined($filename=glob(*.log))){

open(WORDLIST , $filename)||die(can't open the file!);
while($line=WORDLIST){

if ($line=~m/accuracy/){
  $line=~s/-accuracy://;

@temp=split( ,$line);
$temp[0]=~s/\%//;
$temp[2]=~s/\%//;
@accInfoList=($temp[0],$temp[2],$filename);

}

}   


}
return(@accInfoList)

}


findAccuracy();
-- 
--

The R code


class(system(perl presentPerformance.pl))

[1] integer


##
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] Basic question about X11()

2008-08-27 Thread Barry Rowlingson
2008/8/27 Patrick Connolly [EMAIL PROTECTED]:

 Your question is one relating to your window manager.  The display
 parameter for x11() does not relate to desktops.  All the desktops are
 part of the same display.  Some very clever R-devel people might be
 able to think of a way of making a specific X call to achieve what you
 want, but it seems unlikely to me that it could be make to work with
 more than one window manager.

 It's very simple in KDE to set up keyboard shortcuts to move a window
 to a specific desktop.

 There's some X11 command utilities to muck with window placements:

 devilspie: this runs in the background and watches for windows being
created. If any match the rules given in a file then a function is
applied, so for example any window with 'R' in the title can be moved
to Workspace 2. You can set the title on an X11 window with
X11(title=WS2). (The config files (.ds files) are written in a
lisp-like language but there's plenty of help on the web)

 wmctrl: this is a shell command that moves (and otherwise plays with)
existing windows. For example if you do:

wmctrl -r R Graphics -t 2

 it will move the window with title R Graphics to workspace 2. You
could run this in R after doing X11() with the R function call
system(wmctrl ...etc...)

Both these methods will cause the window to briefly flash in the
current workspace before moving. Some window managers have the
facility to place specific windows in specific workspaces by putting
them in config files if you don't want the window to flash up in front
of the user.

Good luck with that then...

Barry

__
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 function for calculating extreme spread in group

2008-08-27 Thread Ben Bolker
Steven Matthew Anderson adastra69 at mac.com writes:

 I'm trying to figure out how to write a r function that will calculate  
 the extreme spread of a group of points given their (x,y)  
 coordinates.  Extreme Spread is the maximal Euclidean distance between  
 two points in a group
 
 ex.spread = max{ sqrt [ (xi-xj)^2 - (yi-yj)^2 ] } for i not equal to j
 
 I have 60 levels to apply this to.
 

   how about something like

max(dist(cbind(x,y))   ... ???

(or to do this in a data frame d with columns x, y, and g (group),

sapply(split(d,d$g),function(Z)max(dist(Z[,c(x,y)])))

  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.


  1   2   >