Re: [R] R parser for If-else

2009-02-25 Thread Martin Maechler
 D == Dani  danicy...@gmail.com
 on Tue, 24 Feb 2009 14:09:36 -0800 writes:

D Hi list,
D I don't know if somebody has spent a lot of time debugging strange
D problems with if else positioning - the parser seems to recognize only
D the syntax bellow - this is the only way of making these pieces of
D code to work.

D As far as i'm concerned, no examples were available (it would be so
D awesome to have them in the introductory manual!)

D #Try to change the placement of the keywords and you are dead! 
[dead?] 

Oh dear... 
Note this has nothing to do with   if( ) .. else ..
but indeed with how things are parsed.

I think this is FAQ (or should become one):

?if [the help page you really should read before spending too
 much time or even post to R-help]  
has the following section

   Note that it is a common mistake to forget to put braces ('{ .. }')
   around your statements, e.g., after 'if(..)' or 'for()'.
   In particular, you should not have a newline between '}' and 
   'else' to avoid a syntax error in entering a 'if ... else'
   construct at the keyboard or via 'source'. For that reason, one
   (somewhat extreme) attitude of defensive programming is to always
   use braces, e.g., for 'if' clauses.

Regards,
Martin Maechler, ETH Zurich


D Ex1:
D if (1==1){
D  print('if')
D  print('if again')
D  }else
D  print('else')

D Ex2:
D if (2==2) print('if') else print('else')

D Ex3:
D if (2==2){
D  print('if')
D  print('if again')
D  }else
D  {
D  print('else')
D  print('else2')
D  }

D Ex4:
D if (2==2){
D  print('if')
D  print('if again')
D }else print('else')



D cheers,
D -
D Daniela

D __
D R-help@r-project.org mailing list
D https://stat.ethz.ch/mailman/listinfo/r-help
D PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
D 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] biplot.princomp - changing score labels

2009-02-25 Thread Prof Brian Ripley

On Tue, 24 Feb 2009, Axel Strauß wrote:


OK, the one thing I figured out:
Is should be like:
biplot(test.pca, cex=c(2,1), col=c(red,green)...
to change size, colours etc separately. But I still don't know how change 
lables of observations to symbols properly.


That's not part of the design of the function, so just make a copy and 
edit to meet your fancies.


The designer of biplot.princomp.



Tipps? Thanks again,
Axel

Dear R helpers,

When producing a PCA biplot, vectors of environmental variables (as red 
arrows with labels) and scores of the observations (black labels 
(observation names)) are plotted by default. How can I change the graphical 
output? Let's say I would like that the scores are plottet only as symbols 
and not text. The only solution I found was this post in the help archive

http://tolstoy.newcastle.edu.au/R/e2/help/06/12/7298.html
suggesting cheating like:
biplot(test.pca, xlabs=c(0,0,0,0,0,0...
and using letters instead of symbols.
This works somehow, but I am still not able the change e.g. the colour or 
size of only the scores. Whatever I try to do with col=..., cex=... and 
so on changes either all labels in the plot or none. Can someone tell me 
what is the trick to only modify either the environmental variables or the 
scores? Also e.g. the type of the arrow?


Thanks in advance,
Axel


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Using package ROCR

2009-02-25 Thread wiener30

I am trying to use package ROCR to analyze classification accuracy,
unfortunately there are some problems right at the beginning.

Question 1) 
When I try to run demo I am getting the following error message
 library(ROCR)
 demo(ROCR)
 if(dev.cur() = 1)  [TRUNCATED] 
Error in get(getOption(device)) : wrong first argument
When I issue the command
 dev.cur() 
it returns
null device 
  1
It seems something is wrong with my R-environment ?
Could somebody provide a hint, what is wrong.

Question 2)
When I run an example commands from the manual
library(ROCR)
data(ROCR.simple)
pred - prediction( ROCR.simple$predictions, ROCR.simple$labels )
perf - performance( pred, tpr, fpr )
plot( perf )

the plot command issues the following error message
Error in as.double(y) : 
  cannot coerce type 'S4' to vector of type 'double'

How this could be fixed ?

Thanks for the support

-- 
View this message in context: 
http://www.nabble.com/Using-package-ROCR-tp22198213p22198213.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] Statistic community?

2009-02-25 Thread Antje

Hi there,

I'm very glad to use the R-help mailing list for R-related question but more 
and more often I face general statistical problems. Does anyone know by chance 
a community (mailinglist, forum, ...) where I can ask these kind of questions?


I'm glad for any link or hint :-)

Antje

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 parser for If-else

2009-02-25 Thread Wacek Kusnierczyk
Martin Maechler wrote:

 I think this is FAQ (or should become one):

 ?if [the help page you really should read before spending too
  much time or even post to R-help]  
   

?if

won't parse completely, you need

?'if'

;)

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] learning R

2009-02-25 Thread markleeds
 David, Wacek: Just so everyone knows, I just looked and this is 
explained quite clearly in the R Language Reference manual, very 
similarly to what Wacek did below.


On Wed, Feb 25, 2009 at  3:42 AM, Wacek Kusnierczyk wrote:


David Winsemius wrote:


On Feb 24, 2009, at 11:36 PM, Fuchs Ira wrote:


I was wondering why the following doesn't work:


a=c(1,2)
names(a)=c(one,two)
a

one two
 1   2


names(a[2])

[1] two


names(a[2])=too
names(a)

[1] one two

a

one two
 1   2

I must not be understanding some basic concept here.
Why doesn't the 2nd name change to too?


I cannot tell you why, perhaps you are not actually working with the
names of a, but I can show you that:


names(a)[2] - too
a[2]

too
  2

a

one too
  1   2

And this is seen as well in the help page examples. The help page 
also

says the following, which I cannot understand:

It is possible to update just part of the names attribute via the
general rules: see the examples. This works because the expression
there is evaluated as z - names-(z, [-(names(z), 3, c2)).



the following:

names(a[2]) = 'foo'

has (partially) a functional flavour, in that you assign to the names 
of

a *copy* of a part of a, while

names(a)[2] = 'foo'

does not have the flavour, in that you assign to the names of a;  it
seems, according to the man page you quote, to be equivalent to:

a = 'names-'(a, '[-.'(names(a), 2, 'foo'))

which proceeds as follows:

tmp1 = names(a)
# get a copy of the names of a, no effect on a

tmp2 = '[-'(tmp1, 2, 'foo')
# get a copy of tmp1 with the second element replaced with 'foo'
# no effect on either a or tmp1

tmp3 = 'names-'(a, tmp2)
# get a copy of a with its names replaced with tmp2
# no effect on either a, tmp1, or tmp2

a = tmp3
# backassign the result to a

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] learning R

2009-02-25 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 25.02.2009 06:18:04:

 Hi Ira:
 
 For your first question, under the hood of R, names- is actually a 
 function so , when you do that, you need to say names(a)[2] rather
 than names(a[2]). why this is is tricky and I wouldn't do it justice if 
 i tried to explain it. it's best if you do ?names- at an R prompt and 

 read that.
 
 For the second one, you can rbind x with anything that of length one and 

 the recycling concept in R will add the extra now but maybe there's a 
 better way that someone else will hopefully send.
 
 
 
#==
 
 a=c(1,2)
 names(a)=c(one,two)
 names(a[2])
 names(a)[2]-too
 names(a)
 
 
 
#===
 
 x=c(1,2,3)
 y=c(3,4,5)
 
 x - matrix(x,nrow=1)
 print(x)
 x - rbind(x,NA)
 x[2,] - y
 print(x)

I can not resist to point out difference between matrices and data frames. 
For those who work with R are obvious but for newcomer using rbind or 
especially cbind with matrices or data frames can lead to nasty surprise 
when adding non numeric column to numeric matrix or values to data frame 
which have different type.

See appropriate help page for rbind.

Regards
Petr

 
 
 
 On Tue, Feb 24, 2009 at 11:36 PM, Fuchs Ira wrote:
 
  I was wondering why the following doesn't work:
 
  a=c(1,2)
  names(a)=c(one,two)
  a
  one two
1   2
 
  names(a[2])
  [1] two
 
  names(a[2])=too
  names(a)
  [1] one two
  a
  one two
1   2
 
  I must not be understanding some basic concept here.
  Why doesn't the 2nd name change to too?
 
  also unrelated:  if I have two vectors and I want to combine them to 
  form a matrix ,is cbind (or rbind) the most direct way to do this?
 
  e.g.
 
  x=c(1,2,3)
  y=c(3,4,5)
  z=rbind(x,y)
 
  alternatively: is there a way to make a matrix with dim=2,3 and then 
  to replace the 2nd row with y
 
  something like this (which doesn't work but perhaps there is another 
  way to do the equivalent?)
 
  attr(x,dim)=c(2,3)
  x[2,]=y
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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, minimal, self-contained, reproducible code.


Re: [R] biplot.princomp - changing score labels

2009-02-25 Thread Axel Strauß

Prof Brian Ripley schrieb:

On Tue, 24 Feb 2009, Axel Strauß wrote:


OK, the one thing I figured out:
Is should be like:
biplot(test.pca, cex=c(2,1), col=c(red,green)...
to change size, colours etc separately. But I still don't know how 
change lables of observations to symbols properly.


That's not part of the design of the function, so just make a copy and 
edit to meet your fancies.


The designer of biplot.princomp.

The idea behind my question was actually not a styling one but to 
provide additional information in the graph. My observations have 
different species richness and I wanted to adopt symbol size to the 
number of species to show the change of species richness along the PCs. 
Anyway, thanks for the comment - and for designing biplot.princomp.


Axel
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 interest group at Stellenbosch University formed: r...@sun

2009-02-25 Thread Rainer M Krug
Hi

I know this only affects a small number of subscribers, so I apologize
to the Non Stellenbosch University subscribers for the noise.

Two weeks ago, four R users met and discussed the possibility of forming
an interest group of R users at SUN. The interest group (r...@sun) has the
aim of:

• Promote the use of R at SUN (Stellenbosch University);
• Organize Hons stats courses using R;
• Lobby for local R mirror;
• Request R books for library;
• Regular (monthly?) meetings to discuss R problems; aspects; new pack-
 ages; ...;
• Special interest Group (r...@sun) seminars / workshops discussing special
usages of R in more detail (genetics, GIS, SQL, ...); and
• Offer seminars on R for departmental seminars et al.

Our first official meeting will take place:
WHEN: Wednesday, 4th of March at 14:00
WHERE: Ex Forestry Library, Paul Sauer Gebou

Everybody is invited to attend.

Please distribute this information as widely as possible.

We have created a mailing list, r...@sympa.sun.ac.za

You can subscribe to the mailing list either via the web interface

https://sympa.sun.ac.za/wws/info/r

or sending an email to

sy...@sympa.sun.ac.za

with

subscribe r YourName

in the body of the email.

Please feel free to contact me if you have further questions

me (Rainer Krug)        rai...@krugs.de

or, the easier solution, subscribe to the mailing list and post your
question there.

Hope to see you there,

Rainer

-- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Cell:   +27 - (0)83 9479 042
Fax:+27 - (0)86 516 2782
Fax:+49 - (0)721 151 334 888
email:  rai...@krugs.de

Skype:  RMkrug
Google: r.m.k...@gmail.com
I attach the Agenda for the meeting.

Hope to see you all there,

Rainer


AgendaR@SUN_20090304.pdf
Description: Adobe PDF document
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] RE : multiple regressions on columns

2009-02-25 Thread GOUACHE David
Hello and thanks for your reply, but as you said, this is not really what I'm 
trying to do.
My purpose is not one of variable selection within a model with multiple 
predictors, but simply fitting a large number of models with only one predictor.
I was just hoping there would be a solution as simple as the one given in my 
example which gives the results of many regression models of the type Yi~x 
where i spans all the colums in a matrix and x is one predictor. My objective 
being the fitting of many regression models of the type y~Xi where i spans all 
the columns in a matrix and y is one dependent variable.

Best regards,

David Gouache
ARVALIS - Institut du végétal
Station de La Minière
78280 Guyancourt
Tel: 01.30.12.96.22 / Port: 06.86.08.94.32


-Message d'origine-
De : Greg Snow [mailto:greg.s...@imail.org] 
Envoyé : mardi 24 février 2009 18:22
À : GOUACHE David; r-h...@stat.math.ethz.ch
Objet : RE: multiple regressions on columns

The add1 function might be what you want, there is also addterm in the MASS 
package and the leaps package can do some things along this line (plus more).

But before doing this, you may want to ask yourself what question you are 
really trying to answer, then explore if this answers that question or not.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of GOUACHE David
 Sent: Tuesday, February 24, 2009 10:13 AM
 To: r-h...@stat.math.ethz.ch
 Subject: [R] multiple regressions on columns
 
 R-helpers,
 
 A quick question regarding my wanting to run multiple regressions
 without writing a loop.
 Looking at a previous discussion :
 http://tolstoy.newcastle.edu.au/R/e2/help/07/02/9740.html
 
 my objective is to do the opposite, i.e. instead of having the same
 independent variable and testing it against multiple dependent
 variables, my goal is to test multiple independent variables against
 the same dependent variable.
 
 Using the iris dataset:
 
 iris4 - as.matrix(iris[,-c(1,5)])
 summary(lm(iris4 ~ Sepal.Length, iris))
 
 what I would have liked is to do the following :
 
 summary(lm(Sepal.Length ~ iris4, iris))
 
 and obtain the results from 3 separate regressions, as above, instead
 of one multiple regression...
 
 Any clues ?
 
 Tanks in advance
 
 David Gouache
 ARVALIS - Institut du végétal
 Station de La Minière
 78280 Guyancourt
 Tel: 01.30.12.96.22 / Port: 06.86.08.94.32
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] learning R

2009-02-25 Thread Wacek Kusnierczyk
markle...@verizon.net wrote:
  David, Wacek: Just so everyone knows, I just looked and this is
 explained quite clearly in the R Language Reference manual, very
 similarly to what Wacek did below.

thanks, that's good, because i made it up following the page quoted by
david, and if i'm flamed for nonsense, the langref has to be flamed too.

vQ

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


Re: [R] An error in fitting a non linear regression

2009-02-25 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 24.02.2009 12:41:50:

 
 Hi Peter,
 
 You are totally right and it was a miscalculating and misunderstanding 
from
 me.
 Regarding the R-squared calculation of non linear model (question 2), is
 there any way to do that?

I am not an expert statistician, Douglas Bates is so see his answer to 
similar question few years ago

http://tolstoy.newcastle.edu.au/R/help/02b/0482.html

Regards
Petr

 
 Regards
 Saeed 
 
 Petr Pikal wrote:
  
  Hi
  
  r-help-boun...@r-project.org napsal dne 24.02.2009 11:31:22:
  
  
  Hi,
  
  Thank you for the reply and suggestions.
  
  I have two questions?
  1) If I want to use log, it seems that I have to take log from both 
  sides of
  the model which will lead to lm(log(q)~log(-depth)). What is 
  tehdifference
  between this syntax and lm(log(q) ~ I(-depth))?
  
  
  If you have 
  
  y = a*exp(-b*x) then log of this equation is
  
  log(y) = log(a) - b * x
  
  at least I was told that by my teacher back at school some decades ago 

  that log(exp(x)) = x.
  
  You can prove it by
  
  log(exp(whatever))
  
  interactively in R
  
  Regards
  Petr
  
  
  2) How can I calculate the R-squared of a fitted non linear model?
  
  Regards
  Saeed
  
  
  Christian Ritz-3 wrote:
   
   Hi Saeed,
   
   one approach is to try out several initial value combinations for a 

  and b.
   
   It often helps to find initial values of the same order of 
magnitude 
  and
   of the same sign
   as the final estimates.
   
   To get such initial values, you could linearize the model:
   
   lm(log(q) ~ I(-depth))
   
   
   and supply the estimated coefficients from the linear regression as
   starting values:
   
   nreg - nls(q ~ a*exp(-b*depth), start = list(a = 0.76168, b = 
  -0.08484))
   summary(nreg)
   
   
   Christian
   
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
   
   
  
  -- 
  View this message in context: 
  http://www.nabble.com/An-error-in-fitting-a-non-
  linear-regression-tp22118160p22179525.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.
  
  
 
 -- 
 View this message in context: 
http://www.nabble.com/An-error-in-fitting-a-non-
 linear-regression-tp22118160p22180225.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] Odp: RE : multiple regressions on columns

2009-02-25 Thread Petr PIKAL
Hi

If you do not insist on matrix and use data frame instead

lapply(iris4,function(x) lm(iris$Sepal.Length~x))

can do it

Regards
Petr

r-help-boun...@r-project.org napsal dne 25.02.2009 09:56:25:

 Hello and thanks for your reply, but as you said, this is not really 
what I'm 
 trying to do.
 My purpose is not one of variable selection within a model with multiple 

 predictors, but simply fitting a large number of models with only one 
predictor.
 I was just hoping there would be a solution as simple as the one given 
in my 
 example which gives the results of many regression models of the type 
Yi~x 
 where i spans all the colums in a matrix and x is one predictor. My 
objective 
 being the fitting of many regression models of the type y~Xi where i 
spans all
 the columns in a matrix and y is one dependent variable.
 
 Best regards,
 
 David Gouache
 ARVALIS - Institut du végétal
 Station de La Minière
 78280 Guyancourt
 Tel: 01.30.12.96.22 / Port: 06.86.08.94.32
 
 
 -Message d'origine-
 De : Greg Snow [mailto:greg.s...@imail.org] 
 Envoyé : mardi 24 février 2009 18:22
 À : GOUACHE David; r-h...@stat.math.ethz.ch
 Objet : RE: multiple regressions on columns
 
 The add1 function might be what you want, there is also addterm in the 
MASS 
 package and the leaps package can do some things along this line (plus 
more).
 
 But before doing this, you may want to ask yourself what question you 
are 
 really trying to answer, then explore if this answers that question or 
not.
 
 -- 
 Gregory (Greg) L. Snow Ph.D.
 Statistical Data Center
 Intermountain Healthcare
 greg.s...@imail.org
 801.408.8111
 
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
  project.org] On Behalf Of GOUACHE David
  Sent: Tuesday, February 24, 2009 10:13 AM
  To: r-h...@stat.math.ethz.ch
  Subject: [R] multiple regressions on columns
  
  R-helpers,
  
  A quick question regarding my wanting to run multiple regressions
  without writing a loop.
  Looking at a previous discussion :
  http://tolstoy.newcastle.edu.au/R/e2/help/07/02/9740.html
  
  my objective is to do the opposite, i.e. instead of having the same
  independent variable and testing it against multiple dependent
  variables, my goal is to test multiple independent variables against
  the same dependent variable.
  
  Using the iris dataset:
  
  iris4 - as.matrix(iris[,-c(1,5)])
  summary(lm(iris4 ~ Sepal.Length, iris))
  
  what I would have liked is to do the following :
  
  summary(lm(Sepal.Length ~ iris4, iris))
  
  and obtain the results from 3 separate regressions, as above, instead
  of one multiple regression...
  
  Any clues ?
  
  Tanks in advance
  
  David Gouache
  ARVALIS - Institut du végétal
  Station de La Minière
  78280 Guyancourt
  Tel: 01.30.12.96.22 / Port: 06.86.08.94.32
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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, minimal, self-contained, reproducible code.


Re: [R] R parser for If-else

2009-02-25 Thread Martin Maechler
 WK == Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no
 on Wed, 25 Feb 2009 09:46:19 +0100 writes:

WK Martin Maechler wrote:
 
 I think this is FAQ (or should become one):
 
 ?if [the help page you really should read before spending too
 much time or even post to R-help]  
 

WK ?if

WK won't parse completely, you need

WK ?'if'

this depends on your GUI for R :
In ESS (Emacs speaks statistics), 

  ?if   does work

[but other non-standard versions of calling '?' do not;
 so I'm not claiming superiority of ESS here (but in general, of
 course, I do :-) ]

Martin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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-pkgs] leaps and biglm

2009-02-25 Thread Thomas Lumley


New versions of leaps and biglm are percolating through CRAN.

The new version of biglm fixes a bug in sandwich standard errors with weights, 
and adds predict(), deviance() and AIC() methods [based on code from Christophe 
Dutang].

The new version of leaps adds a regsubsets() method for biglm objects, so that 
the subset selection algorithms can be run efficiently on large data sets.

 -thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] learning R

2009-02-25 Thread Wacek Kusnierczyk
a quick follow-up:

e = new.env()
e$a = 1
names(e)
# NULL
names(e) = 'a'
# error in names(e) = foo : names() applied to a non-vector

this is surprising.  names(e) 'works', there is no complaint, but when
names- is used, the error is about the use of names, not names-.

btw. ?names says:

Description:

 Functions to get or set the names of an object.

Usage:

 names(x)
 names(x) - value

Arguments:

   x: an R object.


and there is no clarification in the rest of the page that x cannot be
an environment, or that it has to be a vector.  furthermore:

p = pairlist(a=1)
names(p)
# a
names(p) = 'b'
# fine
is.vector(p)
# FALSE

which is incoherent with the above error message, in that p is *not* a
vector.

vQ



Wacek Kusnierczyk wrote:

 the following:

 names(a[2]) = 'foo'

 has (partially) a functional flavour, in that you assign to the names of
 a *copy* of a part of a, while

 names(a)[2] = 'foo'

 does not have the flavour, in that you assign to the names of a;  it
 seems, according to the man page you quote, to be equivalent to:

 a = 'names-'(a, '[-.'(names(a), 2, 'foo'))

 which proceeds as follows:

 tmp1 = names(a)
 # get a copy of the names of a, no effect on a

 tmp2 = '[-'(tmp1, 2, 'foo')
 # get a copy of tmp1 with the second element replaced with 'foo'
 # no effect on either a or tmp1

 tmp3 = 'names-'(a, tmp2)
 # get a copy of a with its names replaced with tmp2
 # no effect on either a, tmp1, or tmp2

 a = tmp3
 # backassign the result to a


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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: Error in var(x, na.rm = na.rm) : no complete element pairs

2009-02-25 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 22.02.2009 12:11:46:

 
 
 Hello all,
 
 I'm trying to calculate the standar desviation with sd(x,na.rm=TRUE) and 
I 
 don't know why I have this error Error in var(x, na.rm = na.rm) : no 
complete 
 element pairs when I try to calculate it, I have been looking for 
information 
 about this error but nothing. Why it happens?. What can I do to fix it?. 

 Thanks so much from Spain

AFAIK nobody answered your question yet. Nor do I as I was not able to 
reproduce your error message and without it it is rather difficult to 
reveal what caused it. 

I suspect that x is not a vector but only you have means for checking it.

Regards
Petr

 
 
 Carlos Morales Diego
 
 
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] learning R

2009-02-25 Thread Berwin A Turlach
On Wed, 25 Feb 2009 09:57:36 +0100
Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no wrote:

 markle...@verizon.net wrote:
   David, Wacek: Just so everyone knows, I just looked and this is
  explained quite clearly in the R Language Reference manual, very
  similarly to what Wacek did below.
 
 thanks, that's good, because i made it up following the page quoted by
 david, and if i'm flamed for nonsense, the langref has to be flamed
 too.

Actually, no.  :)

I do not remember the details, but I once tried to use the R Language
Definition (I presume this is what we are talking about) to support my
argument about some issue I had at that time.  It was pointed out to me
that the R Language Definition is a draft, hence not authoritative;
and it seems its status of being a draft has not changed since.

Cheers,

Berwin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] learning R

2009-02-25 Thread Wacek Kusnierczyk
Berwin A Turlach wrote:
 On Wed, 25 Feb 2009 09:57:36 +0100
 Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no wrote:

   
 markle...@verizon.net wrote:
 
  David, Wacek: Just so everyone knows, I just looked and this is
 explained quite clearly in the R Language Reference manual, very
 similarly to what Wacek did below.

   
 thanks, that's good, because i made it up following the page quoted by
 david, and if i'm flamed for nonsense, the langref has to be flamed
 too.
 

 Actually, no.  :)

 I do not remember the details, but I once tried to use the R Language
 Definition (I presume this is what we are talking about) to support my
 argument about some issue I had at that time.  It was pointed out to me
 that the R Language Definition is a draft, hence not authoritative;
 and it seems its status of being a draft has not changed since.
   

ok, thanks for the explanation.  i'll add the note 'draft version' to
all my messages, so that i can always fall back on the explanation that
they are not my final opinions.

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] learning R

2009-02-25 Thread markleeds
 Hi Wacek: Somewhere I remember reading that environments have 
functionality like lists EXCEPT for the names part. IIRC, I think that I 
read this in the R Language Reference manual also.




On Wed, Feb 25, 2009 at  4:32 AM, Wacek Kusnierczyk wrote:


a quick follow-up:

e = new.env()
e$a = 1
names(e)
# NULL
names(e) = 'a'
# error in names(e) = foo : names() applied to a non-vector

this is surprising.  names(e) 'works', there is no complaint, but when
names- is used, the error is about the use of names, not names-.

btw. ?names says:

Description:

 Functions to get or set the names of an object.

Usage:

 names(x)
 names(x) - value

Arguments:

   x: an R object.


and there is no clarification in the rest of the page that x cannot be
an environment, or that it has to be a vector.  furthermore:

p = pairlist(a=1)
names(p)
# a
names(p) = 'b'
# fine
is.vector(p)
# FALSE

which is incoherent with the above error message, in that p is *not* a
vector.

vQ



Wacek Kusnierczyk wrote:


the following:

names(a[2]) = 'foo'

has (partially) a functional flavour, in that you assign to the names 
of

a *copy* of a part of a, while

names(a)[2] = 'foo'

does not have the flavour, in that you assign to the names of a;  it
seems, according to the man page you quote, to be equivalent to:

a = 'names-'(a, '[-.'(names(a), 2, 'foo'))

which proceeds as follows:

tmp1 = names(a)
# get a copy of the names of a, no effect on a

tmp2 = '[-'(tmp1, 2, 'foo')
# get a copy of tmp1 with the second element replaced with 'foo'
# no effect on either a or tmp1

tmp3 = 'names-'(a, tmp2)
# get a copy of a with its names replaced with tmp2
# no effect on either a, tmp1, or tmp2

a = tmp3
# backassign the result to a



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] RE : RE : multiple regressions on columns

2009-02-25 Thread GOUACHE David
of course ! that was so obvious I didn't see it...
thanks very much and sorry for the bother

David Gouache
ARVALIS - Institut du végétal
Station de La Minière
78280 Guyancourt
Tel: 01.30.12.96.22 / Port: 06.86.08.94.32


-Message d'origine-
De : Petr PIKAL [mailto:petr.pi...@precheza.cz] 
Envoyé : mercredi 25 février 2009 10:09
À : GOUACHE David
Cc : r-h...@stat.math.ethz.ch
Objet : Odp: [R] RE : multiple regressions on columns

Hi

If you do not insist on matrix and use data frame instead

lapply(iris4,function(x) lm(iris$Sepal.Length~x))

can do it

Regards
Petr

r-help-boun...@r-project.org napsal dne 25.02.2009 09:56:25:

 Hello and thanks for your reply, but as you said, this is not really 
what I'm 
 trying to do.
 My purpose is not one of variable selection within a model with multiple 

 predictors, but simply fitting a large number of models with only one 
predictor.
 I was just hoping there would be a solution as simple as the one given 
in my 
 example which gives the results of many regression models of the type 
Yi~x 
 where i spans all the colums in a matrix and x is one predictor. My 
objective 
 being the fitting of many regression models of the type y~Xi where i 
spans all
 the columns in a matrix and y is one dependent variable.
 
 Best regards,
 
 David Gouache
 ARVALIS - Institut du végétal
 Station de La Minière
 78280 Guyancourt
 Tel: 01.30.12.96.22 / Port: 06.86.08.94.32
 
 
 -Message d'origine-
 De : Greg Snow [mailto:greg.s...@imail.org] 
 Envoyé : mardi 24 février 2009 18:22
 À : GOUACHE David; r-h...@stat.math.ethz.ch
 Objet : RE: multiple regressions on columns
 
 The add1 function might be what you want, there is also addterm in the 
MASS 
 package and the leaps package can do some things along this line (plus 
more).
 
 But before doing this, you may want to ask yourself what question you 
are 
 really trying to answer, then explore if this answers that question or 
not.
 
 -- 
 Gregory (Greg) L. Snow Ph.D.
 Statistical Data Center
 Intermountain Healthcare
 greg.s...@imail.org
 801.408.8111
 
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
  project.org] On Behalf Of GOUACHE David
  Sent: Tuesday, February 24, 2009 10:13 AM
  To: r-h...@stat.math.ethz.ch
  Subject: [R] multiple regressions on columns
  
  R-helpers,
  
  A quick question regarding my wanting to run multiple regressions
  without writing a loop.
  Looking at a previous discussion :
  http://tolstoy.newcastle.edu.au/R/e2/help/07/02/9740.html
  
  my objective is to do the opposite, i.e. instead of having the same
  independent variable and testing it against multiple dependent
  variables, my goal is to test multiple independent variables against
  the same dependent variable.
  
  Using the iris dataset:
  
  iris4 - as.matrix(iris[,-c(1,5)])
  summary(lm(iris4 ~ Sepal.Length, iris))
  
  what I would have liked is to do the following :
  
  summary(lm(Sepal.Length ~ iris4, iris))
  
  and obtain the results from 3 separate regressions, as above, instead
  of one multiple regression...
  
  Any clues ?
  
  Tanks in advance
  
  David Gouache
  ARVALIS - Institut du végétal
  Station de La Minière
  78280 Guyancourt
  Tel: 01.30.12.96.22 / Port: 06.86.08.94.32
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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, minimal, self-contained, reproducible code.


Re: [R] learning R

2009-02-25 Thread markleeds
 Thanks Berwin. You're correct in that I meant the R Language 
Definition. Well, it may be a draft but I read it for the first time a 
few months ago and
it was very enlightening so, whether it's a draft or not, I highly 
recommend it. (  but not for total beginners. The  R-intro is better for 
a more gentle introduction ).



On Wed, Feb 25, 2009 at  4:34 AM, Berwin A Turlach wrote:


On Wed, 25 Feb 2009 09:57:36 +0100
Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no wrote:


markle...@verizon.net wrote:

 David, Wacek: Just so everyone knows, I just looked and this is
explained quite clearly in the R Language Reference manual, very
similarly to what Wacek did below.

thanks, that's good, because i made it up following the page quoted 
by

david, and if i'm flamed for nonsense, the langref has to be flamed
too.


Actually, no.  :)

I do not remember the details, but I once tried to use the R Language
Definition (I presume this is what we are talking about) to support 
my
argument about some issue I had at that time.  It was pointed out to 
me

that the R Language Definition is a draft, hence not authoritative;
and it seems its status of being a draft has not changed since.

Cheers,

Berwin


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] leaps question

2009-02-25 Thread Thomas Lumley

On Wed, 25 Feb 2009, Evelina Naryvska wrote:


Colleagues,
please help me with the simple question.
How can I find R2 and p while doing best subsets regression? Also how
can I see B and p for coefficients?


You can't see coefficients or their p-values, because these are not computed. 
The subset selection algorithm does not actually fit all the models, it only 
works out what the residual sum of squares would be for the models.  That is 
why it is fast. You have to actually fit the best models separately to get the 
coefficients, residuals, tests, and everything else.

The summary() method for regsubsets objects returns an object that includes the 
other things you want.


names(summary(a))

[1] which  rsqrssadjr2  cp bicoutmat obj

rsq is the r^2, rss is the residual sum of squares, adjr2 is the adjusted r^2, 
cp is Mallows' Cp, bic is the Schwartz Information Criterion.

If you believed F-test p-values after subset selection you could compute them 
from the residual sum of squares. I wouldn't advise it.

You could complain to the author of the package about the documentation. He 
seems to have forgotten to document summary.regsubsets().


  -thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Statistic community?

2009-02-25 Thread Heather Turner
When discussions do burst out on the allstat list, people are usually
pointed to one of the following alternatives:

http://groups.google.com/group/MedStats
http://datashaping.ning.com/forum

HTH

Heather


Peters Gj (PSYCHOLOGY) wrote:
 Hey Antje  list,
 
 Antje wrote:
 I'm very glad to use the R-help mailing list for R-related question
 but
 more and more often I face general statistical problems. Does anyone
 know
 by chance a community (mailinglist, forum, ...) where I can ask these
 kind
 of questions?
 
 I myself have recently started lurking at the Allstat and Stat-L lists.
 Stat-L does not seem very active, and my impression of Allstat is that
 it's mostly used for distributing information about conferences and
 vacancies. In addition, Allstat does not encourage discussion on-list -
 their rules ask you to reply to people in person. I myself prefer
 on-list discussions, as I frequently learn from these (just by lurking).
 
 So you could also try out these two lists - and if you find anything
 else, I would love to hear about them :-)
 
 Kind regards,
 
 Gjalt-Jorn
 
 ---
 Gjalt-Jorn Peters
 Work  Social Psychology, faculty of Psychology  Neuroscience,
 Maastricht University
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Using very large matrix

2009-02-25 Thread Corrado
Dear friends,

I have to use a very large matrix. Something of the sort of 
matrix(8,8,n)  where n is something numeric of the sort 0.xx

I have not found a way of doing it. I keep getting the error

Error in matrix(nrow = 8, ncol = 8, 0.2) : too many elements specified

Any suggestions? I have searched the mailing list, but to no avail. 

Best,
-- 
Corrado Topi

Global Climate Change  Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


Re: [R] Inference for R Spam

2009-02-25 Thread Jim Lemon

Dieter Menne wrote:

And, since my son asked me and I am basketball ignorant: Why are 
basketball scores mostly much too close to equality? The arguments

(loose power when leading)


Characteristic of the game. Possession of the ball changes rapidly and 
the probability of scoring is much higher given possession than in a 
game like soccer. The difference between winning and losing is largely a 
matter of not missing the frequent opportunities to score, whereas in 
soccer the difference is the ability to penetrate a much more effective 
defense. To see a similar thing within a sport, compare a tennis match 
between two power servers with one between two volley experts.


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] Using very large matrix

2009-02-25 Thread Philipp Pagel
 I have to use a very large matrix. Something of the sort of 
 matrix(8,8,n)  where n is something numeric of the sort 0.xx
 
 I have not found a way of doing it. I keep getting the error
 
 Error in matrix(nrow = 8, ncol = 8, 0.2) : too many elements specified
 
 Any suggestions? I have searched the mailing list, but to no avail. 

A 8x8 matrix has 6.4 billion cells. If you assume 4 byte
(32bit) for a double precision floating point number that's an
impressive 25.6 Gb. Certainly does not fit into RAM on my machine.

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 very large matrix

2009-02-25 Thread Duncan Murdoch

Philipp Pagel wrote:
I have to use a very large matrix. Something of the sort of 
matrix(8,8,n)  where n is something numeric of the sort 0.xx


I have not found a way of doing it. I keep getting the error

Error in matrix(nrow = 8, ncol = 8, 0.2) : too many elements specified

Any suggestions? I have searched the mailing list, but to no avail. 



A 8x8 matrix has 6.4 billion cells. If you assume 4 byte
(32bit) for a double precision floating point number that's an
impressive 25.6 Gb. Certainly does not fit into RAM on my machine.
  


Doubles are 8 bytes, and R can't handle vectors that large, even if you 
have the memory.  (Indices are limited to 32 bit values even in 64 bit R.)


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] Using very large matrix

2009-02-25 Thread Philipp Pagel
On Wed, Feb 25, 2009 at 06:37:53AM -0500, Duncan Murdoch wrote:
 Philipp Pagel wrote:

 A 8x8 matrix has 6.4 billion cells. If you assume 4 byte
 (32bit) for a double precision floating point number that's an
 impressive 25.6 Gb. Certainly does not fit into RAM on my machine.
   

 Doubles are 8 bytes, 

Oops - of course. Even worse...

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Have a function like the _n_ in R ? (Automatic count function )

2009-02-25 Thread Nash

Have the counter function in R ?

if we use the software SAS

/*** SAS Code **/
data tmp(drop= i);
retain seed x 0;
do i = 1 to 5;
call ranuni(seed,x);
output;
end;
run;

data new;
counter=_n_;  * this keyword _n_ ;
set tmp;
run;

/*
_n_ (Automatic variables)
are created automatically by the DATA step or by DATA step statements.
*/

/*** Output 
counter  seed x
1   5840432880.27197
2   9359029630.43581
3   3018795230.14057
4   7532125980.35074
5   1607264573  0.74844

/

Have a function like the _n_ in R ?


--
Nash - morri...@ibms.sinica.edu.tw

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Have a function like the _n_ in R ? (Automatic count function)

2009-02-25 Thread Shubha Vishwanath Karanth
 temp=data.frame(a=c(4,3,2,6),b=c(7,4,2,4))
 temp
  a b
1 4 7
2 3 4
3 2 2
4 6 4
 temp$counter=1:nrow(temp)
 temp
  a b counter
1 4 7   1
2 3 4   2
3 2 2   3
4 6 4   4

Shubha Karanth | Amba Research
Ph +91 80 3980 8031 | Mob +91 94 4886 4510
Bangalore * Colombo * London * New York * San José * Singapore * 
www.ambaresearch.com
 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Nash
Sent: Wednesday, February 25, 2009 5:55 PM
To: r-help
Subject: [R] Have a function like the _n_ in R ? (Automatic count function)


Have the counter function in R ?

if we use the software SAS

/*** SAS Code **/
data tmp(drop= i);
retain seed x 0;
do i = 1 to 5;
call ranuni(seed,x);
output;
end;
run;

data new;
counter=_n_;  * this keyword _n_ ;
set tmp;
run;

/*
_n_ (Automatic variables)
are created automatically by the DATA step or by DATA step statements.
*/

/*** Output 
counter  seed x
1   5840432880.27197
2   9359029630.43581
3   3018795230.14057
4   7532125980.35074
5   1607264573  0.74844

/

Have a function like the _n_ in R ?


--
Nash - morri...@ibms.sinica.edu.tw

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
This e-mail may contain confidential and/or privileged i...{{dropped:10}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Have a function like the _n_ in R ? (Automatic count function )

2009-02-25 Thread Henrique Dallazuanna
I think you can use seq function:

seq(5)

On Wed, Feb 25, 2009 at 9:25 AM, Nash morri...@ibms.sinica.edu.tw wrote:


 Have the counter function in R ?

 if we use the software SAS

 /*** SAS Code **/
 data tmp(drop= i);
 retain seed x 0;
 do i = 1 to 5;
call ranuni(seed,x);
output;
 end;
 run;

 data new;
 counter=_n_;  * this keyword _n_ ;
 set tmp;
 run;

 /*
 _n_ (Automatic variables)
 are created automatically by the DATA step or by DATA step statements.
 */

 /*** Output 
 counter  seed x
 1   5840432880.27197
 2   9359029630.43581
 3   3018795230.14057
 4   7532125980.35074
 5   1607264573  0.74844

 /

 Have a function like the _n_ in R ?


 --
 Nash - morri...@ibms.sinica.edu.tw

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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.


[R] coxph: competing endpoints multiple time-dependent covariate

2009-02-25 Thread sdzhangping
Dear R users:
Analysis of the impact of a time-dependent covariate (GVHD or use of 
steroid after bone marrow transplantation) on two competing endpoints (invasive 
fungal infection and death) is frequently encountered in the setting of BMT 
data. Coxph package can be used as the following:
for the analysis of GVHD:
  gvhd - coxph(Surv(start,stop,status = =1) ~ GVHD, data=bmt.data)
and the data should be edited as the following:
  patient start stop status(IFI) GVHD
 1 0  15 0 0
 1 15 35 1 1
 2 0  12 0 0
 2 12 20 2 1
 3 0  30 2 0
 4 0  1000 0
 5 0  25 0 0
 5 25 1000 1
   similarly, for steroid:
  steroid - coxph(Surv(start,stop,status = =1) ~ steroid, data=bmt.data)
and the data was edited as the following:
  patient start stop status(IFI) steroid
 1 0  16 0 0
 1 16 35 1 1
 2 0  13 0 0
 2 13 20 2 1
 3 0  14 0 0
 3 14 30 2 1
 4 0  1000 0
 5 0  21 0 0
 5 21 1000 1
 
I wonder how can I analyze the two risk factors (GVHD and steroid) 
concurrently? And how to edit the data. 
How can I manage it if a third baseline risk factor(age for example) was 
included?
 
 Thanks 
 Yours sincerely Ping Zhang 
 Feb 24 2009



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

2009-02-25 Thread Wacek Kusnierczyk
Prof Brian Ripley wrote:
 On Mon, 16 Jun 2008, Wacek Kusnierczyk wrote:

 Paul Adams wrote:
 Hello everyone,
 I have the following code which keeps giving me an error.
 The code is:
 dat-read.table(file=C:\\Documents and Settings\\Owner\\My
 Documents\\eisen.txt,header=T,row.names=1,blank.lines.skip=F,na..strings=NA)

 dimnames(dat)((1)) -as.character(dat(,1))
 dat-dat(,-1)
 dat-as.data.frame(dat)
 file.show(file=C:\\Documents and Settings\\Owner\\My
 Documents\\eisen.txt)
 ann-read.table(file=C:\\Documents and Settings\\Owner\\My
 Documents\\eisenClasses.txt,header=T)
 file.show(file=C:\\Documents and Settings\\Owner\\My
 Documents\\eisenClasses.txt)
 cl-as.character(ann[,2])
 dat-dat[,cl]
 gc-cl(1:19)
 act-cl(20:39)
 x-as.numeric(dat(2000,gc))
 y-as.numeric(dat(2000,act))
 x-x(!is..na(x))
 y-y(!is.na(y))
 xy.list-list(x,y)
 boxplot(xy.list,col=c(red,blue),main=Gene 2000)
 The error is:   error in eval .with.vis(expr, envir, enclos)  :
 could not find function dat

 you misuse the syntax, check the docs.  with 'dat(...)' r tries to apply
 dat, but dat is a data frame, and is thus not applicable.  what you want
 is dat[...].

 you can argue that the error message is misleading;  unless you defined
 one, r cannot find a function named 'dat', but it does find your data
 frame, and it should complain about its non-applicability.

 It is this explanation which is misleading.  R (not r) looks for a
 function named 'dat': it does not find the data frame when looking for
 a function.  To be explicit, when R encounters foo() it looks in the
 current environment for a function named 'foo' and ignores all other
 objects named 'foo' even if they are higher on the search path.  This
 was not the behaviour of Blue-Book S, but it has been the behvaviour
 of S and R for many years.

are you sure it is not your explanation that is misleading?  as far as i
can see, bindings for function objects are made in environments in just
the same way as for other kinds of objects. 

when r looks for a function named 'foo', it checks, starting from the
current environment, for bindings for the name 'foo';  when it finds
one, it examines the corresponding value for its being a function
(roughly), and either successfully returns the value, or proceeds with
the enclosing environment.  this is what can be seen in the sources
(simplified):

   // starting at line 1223 in src/main/envir.c as of r48000
   while (rho != R_EmptyEnv) {
  ...
  vl = findVarInFrame3(rho, symbol, TRUE);
  if (vl != R_UnboundValue) {
 ...
 if (TYPEOF(vl) == CLOSXP || TYPEOF(vl) == BUILTINSXP ||
TYPEOF(vl) == SPECIALSXP)
return (vl);
 ...
  }
   ...
   }

clearly, appropriately named values *are* found and examined even if
they're not functions.  this is also acknowledged in the following comment:

   // starting at line 1208 in src/main/envir.c as of r48000
   findFun

   Search for a function in an environment This is a specially modified
   version of findVar which ignores values its finds if they are not
   functions.

note the 'finds'.

back to the original issue, your it does not find the data frame when
looking for a function. is *wrong*.  r *does* find the data frame; r
ignores it because it is not a function, but it ignores it only *after*
the data frame has been *found* and *examined*.  it searches further,
finds no function named 'dat', and complains.

to a naive user, the error message discussed above may be misleading. 
if it said, e.g., that none of the objects named 'dat' is a function, it
might be easier for the user to find out what's wrong.

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 NULL multiple variables of a df efficiently?

2009-02-25 Thread Peter Dalgaard
Wacek Kusnierczyk wrote:

 
 as above, this works as well:
 
 df[, vars] = list(NULL)
 
 and this, simplest of them all, works too:
 
 df[vars] = list(NULL)

That's actually a curious anomaly/design-flaw/whatever... The usual
rule is that you can treat data frames as lists, but


 aq - as.list(head(airquality))
 aq[2:4] - list(NULL)
 aq
$Ozone
[1] 41 36 12 18 NA 28

$Solar.R
NULL

$Wind
NULL

$Temp
NULL

$Month
[1] 5 5 5 5 5 5

$Day
[1] 1 2 3 4 5 6

 aq[2:4] - NULL
 aq
$Ozone
[1] 41 36 12 18 NA 28

$Month
[1] 5 5 5 5 5 5

$Day
[1] 1 2 3 4 5 6


#- whereas

 aq - head(airquality)
 aq[2:4] - NULL
Error in `[-.data.frame`(`*tmp*`, 2:4, value = NULL) :
  replacement has 0 items, need 18
 aq[2:4] - list(NULL)
 aq
  Ozone Month Day
141 5   1
236 5   2
312 5   3
418 5   4
5NA 5   5
628 5   6


It is not too strange that assigning list(NULL) differs since you can't
have NULL columns in a data frame. It's  more odd that assigning NULL to
a set of variables fails to delete them.  Not sure what the rationale
(if any) for that might be.

-- 
   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
~~ - (p.dalga...@biostat.ku.dk)  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] Statistic community?

2009-02-25 Thread Keith Jewell
You might also try...
http://groups.google.com/group/sci.stat.consult
http://groups.google.com/group/sci.stat.edu
http://groups.google.com/group/sci.stat.math
Although I can't swear these don't overlap with some already mentioned.

HTH

Keith J

Heather Turner heather.tur...@warwick.ac.uk wrote in message 
news:49a52167.10...@warwick.ac.uk...
 When discussions do burst out on the allstat list, people are usually
 pointed to one of the following alternatives:

 http://groups.google.com/group/MedStats
 http://datashaping.ning.com/forum

 HTH

 Heather


 Peters Gj (PSYCHOLOGY) wrote:
 Hey Antje  list,

 Antje wrote:
 I'm very glad to use the R-help mailing list for R-related question
 but
 more and more often I face general statistical problems. Does anyone
 know
 by chance a community (mailinglist, forum, ...) where I can ask these
 kind
 of questions?

 I myself have recently started lurking at the Allstat and Stat-L lists.
 Stat-L does not seem very active, and my impression of Allstat is that
 it's mostly used for distributing information about conferences and
 vacancies. In addition, Allstat does not encourage discussion on-list -
 their rules ask you to reply to people in person. I myself prefer
 on-list discussions, as I frequently learn from these (just by lurking).

 So you could also try out these two lists - and if you find anything
 else, I would love to hear about them :-)

 Kind regards,

 Gjalt-Jorn

 ---
 Gjalt-Jorn Peters
 Work  Social Psychology, faculty of Psychology  Neuroscience,
 Maastricht University

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


Re: [R] how to label the branches of a tree

2009-02-25 Thread David Winsemius
When I execute that code, I get labels both on the branching points  
and at the leaves of the tree. So I guess my reply is cannot  
reproduce or do not understand.  They are however not properly  
positioned and the edges and bottoms of some of the labels are cut  
off, but that did not sound like your question.


Using Mac OS X 10.5.6 and the ATT binary of R2.8.1. ‘rpart’ version  
3.1-42.


--
David Winsemius

Note:  your mailer is putting single quotes inside the enclosing angle  
brackets so my mailer does not recognize the r-help address as a valid  
address. Since this is the first time I have encountered this  
construction, I wonder if your mailer is adhering to standards in its  
reply-to functions.




On Feb 25, 2009, at 1:19 AM, Utkarsh Singhal wrote:


Hi,



I am using rpart package to fit classification trees.



library(rpart)

fit - rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)

plot(fit,uniform=T)

text(fit, use.n=TRUE)



But I am unable to label the branches (not the nodes) of the tree.  
Can somebody help me out in this?




Thank you,

Regards

Utkarsh Singhal | Amba Research

Ph +91 80 3980 8017 | Mob +91 99 0295 8815

Bangalore * Colombo * London * New York * San José * Singapore * www.ambaresearch.com 
  mailto:utkar...@ambaresearch.com






This e-mail may contain confidential and/or privileged i...{{dropped: 
13}}


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Leave one out Cross validation (LOO)

2009-02-25 Thread Frank E Harrell Jr

Alex Roy wrote:

Dear Frank,
   Thanks for your comments. But in my situation, I do 
not have any future data and I want to calculate Mean Square Error for 
prediction on future data. So, is it not it a good idea to go for LOO?
 
thanks
 
Alex


With resampling you should be able to estimate any parameter including 
sigma.  The Design package's validate.ols function can estimate sigma 
using the bootstrap or c-v, penalizing for backward stepdown variable 
selection, although I have found some counter-intuitive estimates of 
sigma using Efron's optimism bootstrap.


Frank



On Tue, Feb 24, 2009 at 7:15 PM, Frank E Harrell Jr 
f.harr...@vanderbilt.edu mailto:f.harr...@vanderbilt.edu wrote:


Alex Roy wrote:

Dear R user,
  I am working with LOO. Can any one who is
working
with leave one out cross validation (LOO) could send me the code?

Thanks in advance

Alex


I don't think that LOO adequately penalizes for model uncertainty.
 I recommend the bootstrap or 50 repeats of 10-fold
cross-validation.  See for example the validate and calibrate
functions in the R Design package.

Frank
--


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] statistical significance of accuracy increase in classification

2009-02-25 Thread Max Kuhn
Monica,

I have a few thoughts.

 - (I believe) it is usually better to put confidence in these metrics
instead of relying on p-values. The intervals will allow you to make
inferential statements and give you a way of characterizing the
uncertainty in the estimates. You've seen how to do this with
accuracy. For Kappa, there is probably an analytical formula for a CI,
but I don;t know that it is in R. I would use the bootstrap (bia the
boot or bootstrap package) to get intervals for kappa.

 - It sounds like some of the models were generated outside of R. I
think that the sampling uncertainty can be large. In other words, if
you were to do another training/test split, you would get different
results so the CI for accuracy or kappa on a single test set don't
really reflect this sampling noise. If you were doing models in R, I
would suggest that you do many training/test splits and look at the
distributions of those metrics.


Max

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Have a function like the _n_ in R ? (Automatic count function )

2009-02-25 Thread David Winsemius
The _n_ construct in SAS is most analogous to that of row names in R,  
accessible (and modifiable)  via the row.names() function:


DF - structure(list(Month = structure(c(2L, 2L, 2L, 2L, 1L, 1L, 1L,
1L, 3L, 3L, 3L, 3L, 3L), .Label = c(Aug, July, Sept), class =  
factor),

Week = 27:39, Estpassage = c(665L, 2232L, 9241L, 28464L,
41049L, 82216L, 230411L, 358541L, 747839L, 459682L, 609567L,
979475L, 837189L), MedFL = c(34L, 35L, 35L, 35L, 35L, 35L,
35L, 35L, 35L, 36L, 36L, 36L, 36L)), .Names = c(Month,
Week, Estpassage, MedFL), class = data.frame, row.names = c(NA,
-13L))

DF$counter - row.names(DF)

 DF
   Month Week Estpassage MedFL counter
1   July   2766534   1
2   July   28   223235   2
3   July   29   924135   3
4   July   30  2846435   4
5Aug   31  4104935   5
6Aug   32  8221635   6
7Aug   33 23041135   7
8Aug   34 35854135   8
9   Sept   35 74783935   9
10  Sept   36 45968236  10
11  Sept   37 60956736  11
12  Sept   38 97947536  12
13  Sept   39 83718936  13

Row names, however, not guaranteed to be integer, although if not  
specified at time of creation a dataframe will have its row names set  
to an ascending series of integer type. Another function that would  
provide similar utility for vectors might be seq_along().\, but in the  
case of dataframes, it may confuse the beginning R user because it  
will return a column oriented ascending sequence.


 seq_along(DF)
[1] 1 2 3 4 5

--
David Winsemius



On Feb 25, 2009, at 7:25 AM, Nash wrote:



Have the counter function in R ?

if we use the software SAS

/*** SAS Code **/
data tmp(drop= i);
retain seed x 0;
do i = 1 to 5;
call ranuni(seed,x);
output;
end;
run;

data new;
counter=_n_;  * this keyword _n_ ;
set tmp;
run;

/*
_n_ (Automatic variables)
are created automatically by the DATA step or by DATA step statements.
*/

/*** Output 
counter  seed x
1   5840432880.27197
2   9359029630.43581
3   3018795230.14057
4   7532125980.35074
5   1607264573  0.74844

/

Have a function like the _n_ in R ?


--
Nash - morri...@ibms.sinica.edu.tw

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 label the branches of a tree

2009-02-25 Thread Prof Brian Ripley

On Wed, 25 Feb 2009, David Winsemius wrote:

When I execute that code, I get labels both on the branching points and at 
the leaves of the tree. So I guess my reply is cannot reproduce or do not 
understand.  They are however not properly positioned and the edges and 
bottoms of some of the labels are cut off, but that did not sound like your 
question.


Try par(xpd), as mentioned in the help (?text.rpart): that also 
mentions a lot more ways to control the plot's appearance.



Using Mac OS X 10.5.6 and the ATT binary of R2.8.1. ‘rpart’ version 3.1-42.


The graphics device matters too.



--
David Winsemius

Note:  your mailer is putting single quotes inside the enclosing angle 
brackets so my mailer does not recognize the r-help address as a valid 
address. Since this is the first time I have encountered this construction, I 
wonder if your mailer is adhering to standards in its reply-to functions.




On Feb 25, 2009, at 1:19 AM, Utkarsh Singhal wrote:


Hi,



I am using rpart package to fit classification trees.



library(rpart)

fit - rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)

plot(fit,uniform=T)

text(fit, use.n=TRUE)


But I am unable to label the branches (not the nodes) of the tree. Can 
somebody help me out in this?




Thank you,

Regards

Utkarsh Singhal | Amba Research


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] read multiplan or sylk files in R

2009-02-25 Thread GOUACHE David
Hello,

This may sound crazy, but I have a large number of Multiplan data files I'm in 
the process of recuperating, and I'm hoping to avoid having to open them one by 
one to convert them into a modern, directly usable format. So I was wondering 
if someone somewhere had encountered this and maybe had a way to read Multiplan 
files in R, or, at least, a way to read SYLK files directly in R.

Any help appreciated.
Thanks.

David Gouache
ARVALIS - Institut du végétal
Station de La Minière
78280 Guyancourt
Tel: 01.30.12.96.22 / Port: 06.86.08.94.32

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Have a function like the _n_ in R ? (Automatic count function )

2009-02-25 Thread hadley wickham
And for completeness here's a function that returns the next integer
on each call.

n - (function(){
  i - 0
  function() {
i - i + 1
i
  }
})()

 n()
[1] 1
 n()
[1] 2
 n()
[1] 3
 n()
[1] 4
 n()
[1] 5
 n()
[1] 6


;)

Hadley

On Wed, Feb 25, 2009 at 8:27 AM, David Winsemius dwinsem...@comcast.net wrote:
 The _n_ construct in SAS is most analogous to that of row names in R,
 accessible (and modifiable)  via the row.names() function:

 DF - structure(list(Month = structure(c(2L, 2L, 2L, 2L, 1L, 1L, 1L,
 1L, 3L, 3L, 3L, 3L, 3L), .Label = c(Aug, July, Sept), class =
 factor),
    Week = 27:39, Estpassage = c(665L, 2232L, 9241L, 28464L,
    41049L, 82216L, 230411L, 358541L, 747839L, 459682L, 609567L,
    979475L, 837189L), MedFL = c(34L, 35L, 35L, 35L, 35L, 35L,
    35L, 35L, 35L, 36L, 36L, 36L, 36L)), .Names = c(Month,
 Week, Estpassage, MedFL), class = data.frame, row.names = c(NA,
 -13L))

 DF$counter - row.names(DF)

 DF
   Month Week Estpassage MedFL counter
 1   July   27        665    34       1
 2   July   28       2232    35       2
 3   July   29       9241    35       3
 4   July   30      28464    35       4
 5    Aug   31      41049    35       5
 6    Aug   32      82216    35       6
 7    Aug   33     230411    35       7
 8    Aug   34     358541    35       8
 9   Sept   35     747839    35       9
 10  Sept   36     459682    36      10
 11  Sept   37     609567    36      11
 12  Sept   38     979475    36      12
 13  Sept   39     837189    36      13

 Row names, however, not guaranteed to be integer, although if not specified
 at time of creation a dataframe will have its row names set to an ascending
 series of integer type. Another function that would provide similar utility
 for vectors might be seq_along().\, but in the case of dataframes, it may
 confuse the beginning R user because it will return a column oriented
 ascending sequence.

 seq_along(DF)
 [1] 1 2 3 4 5

 --
 David Winsemius



 On Feb 25, 2009, at 7:25 AM, Nash wrote:


 Have the counter function in R ?

 if we use the software SAS

 /*** SAS Code **/
 data tmp(drop= i);
 retain seed x 0;
 do i = 1 to 5;
        call ranuni(seed,x);
        output;
 end;
 run;

 data new;
 counter=_n_;  * this keyword _n_ ;
 set tmp;
 run;

 /*
 _n_ (Automatic variables)
 are created automatically by the DATA step or by DATA step statements.
 */

 /*** Output 
 counter      seed             x
 1       584043288                0.27197
 2       935902963                0.43581
 3       301879523                0.14057
 4       753212598                0.35074
 5       1607264573      0.74844

 /

 Have a function like the _n_ in R ?


 --
 Nash - morri...@ibms.sinica.edu.tw

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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.




-- 
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] odfWeave problem Error in xmlEventParse

2009-02-25 Thread Max Kuhn
 We should make this an FAQ (or find someone who knows how to correct the bug 
 in
 XML).

We've been working on that.

It's hard to say what the problem is without the output of
sessionInfo() and a reproducible example.

Fredrik - if you can send me this off-list, I'll take a look (but it
may take me a few days to get to it).

-- 

Max

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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-pkgs] ggplot2 0.8.2

2009-02-25 Thread hadley wickham
ggplot2 

ggplot2 is a plotting system for R, based on the grammar of graphics,
which tries to take the good parts of base and lattice graphics and
avoid bad parts. It takes care of many of the fiddly details
that make plotting a hassle (like drawing legends) as well as
providing a powerful model of graphics that makes it easy to produce
complex multi-layered graphics.

Find out more at http://had.co.nz/ggplot2, and check out the nearly 500
examples of ggplot in use.  If you're interested, you can also sign up to
the ggplot2 mailing list at http://groups.google.com/group/ggplot2, or track
development at http://github.com/hadley/ggplot2

ggplot2 0.8.2  (2008-02-23)


New features

* borders, fortify.map and map_data to make it easier to draw map
borders and choropleth maps

* cut_interval and cut_number utility functions to discretise
continuous variables

* stat_summary has reparameterised to make it easier to specify
different summary functions.  It now has four parameters: fun.y,
fun.ymin and fun.ymax; and fun.data.  See the documentation for
stat_summary for more details

Minor improvements

* ggfluctuation: default to aspect ratio that produces squares
* ggsave: filename now first parameter, not second
* qplot: if sample aesthetic is used, stat automatically set to qq
* scale_datetime: improved breaks calculation
* scale_gradient: better default colour scheme from red to blue
(thanks to Charlotte Wickham for providing the Munsell colours)
* scale_size and scale_area: increased default size range
* stats: all give useful error message if missing a required aesthetic
* theme_set warns if missing needed theme elements
* theme_text: now possible to right and left align text with hjust=0
and hjust=1 respectively

Bug fixes

* be explicit about plyr::is.discrete to avoid clash with Hmisc
* facet_wrap: work around R bug so no longer crashers when ncol = 1
* geom_errorbar now works correctly with dashed lines
* geom_path will now silently ignore lines with less than 2 points
(instead of throwing a mysterious error as before)
* geom_path now responds to the size aesthetic once more
* geom_polygon etc now correctly displays linetype on legends
* geom_step now works with multiple groups
* geom_vline and geom_hline: fix bug when mapping intercept to
variable in data frame
* ggsave: path parameter correctly sets path
* guides: fix broken legend from default stat aesthetics (e.g. for stat_sum)
* scale_manual now works better with missing values
* scale_manual: labels now correctly sets legend labels.
* stat_density_2d: no longer passes unnecessary parameters to kde2d
causing an error message (seen when setting aesthetics with qplot)
* stat_pointrange: better relationship between point and line widths
* stat_sum now correctly preserves other aesthetic columns (should be
a bit faster too)


Regards,

Hadley

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

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] statistical significance of accuracy increase in classification

2009-02-25 Thread Monica Pisica

Max,
 
thanks for the reply. Yes, the models are done outside R (i will see what i can 
do to run some of them inside R in the future ) and the sampling is 
extremely skewed. But we use as truth or reference results from a field 
exercise where people actually went and gave detailed description of the 
locations visited. This was very much depended on accessibility of the site, 
 which in majority is not. Unfortunately when results get reported to 
managers  they do care about accuracy for example, but less about CI  
and even less about the skewed sampling  unless i can prove that this gives 
unacceptable results. 
 
Do you know about any good reference that discusses kappa for classification 
and maybe CI for kappa???
 
Thanks again for your input,
 
Monica 

 Date: Wed, 25 Feb 2009 09:01:23 -0500
 Subject: Re: [R] statistical significance of accuracy increase in 
 classification
 From: mxk...@gmail.com
 To: pisican...@hotmail.com
 CC: r-help@r-project.org
 
 Monica,
 
 I have a few thoughts.
 
 - (I believe) it is usually better to put confidence in these metrics
 instead of relying on p-values. The intervals will allow you to make
 inferential statements and give you a way of characterizing the
 uncertainty in the estimates. You've seen how to do this with
 accuracy. For Kappa, there is probably an analytical formula for a CI,
 but I don;t know that it is in R. I would use the bootstrap (bia the
 boot or bootstrap package) to get intervals for kappa.
 
 - It sounds like some of the models were generated outside of R. I
 think that the sampling uncertainty can be large. In other words, if
 you were to do another training/test split, you would get different
 results so the CI for accuracy or kappa on a single test set don't
 really reflect this sampling noise. If you were doing models in R, I
 would suggest that you do many training/test splits and look at the
 distributions of those metrics.
 
 
 Max
_


ore_022009
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Have a function like the _n_ in R ? (Automatic count function )

2009-02-25 Thread hadley wickham
On Wed, Feb 25, 2009 at 8:41 AM, Wacek Kusnierczyk
waclaw.marcin.kusnierc...@idi.ntnu.no wrote:
 hadley wickham wrote:
 And for completeness here's a function that returns the next integer
 on each call.

 n - (function(){
   i - 0
   function() {
     i - i + 1
     i
   }
 })()


 actually, you do not need the external function to have the functionality:

    n = local({
        i = 0
        function() (i - i + 1)[1] })

    n()
    # 1
    n()
    # 2

Yes, I'm just using the function as a way of creating an environment.
The function method is a little more flexible if you want multiple
independent counters though.

Hadley



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


[R] C-index for models fitted using start, stop in Surv?

2009-02-25 Thread Eleni Rapsomaniki
Dear R-users,

One can use the rcorr.cens function in Design to compute the C index when only 
the stop time is indicated (I think implicitely start=0 in that case). When the 
start and stop times are used in a Surv object, e.g. 

library(Design)
S=with(heart, Surv(start,stop,event))

the object returned is no longer a single number vector, so none of the 
following ways to compare a model fit to S makes sense:

rcorr.cens(-cph(S~ age+transplant+surgery, heart)$linear.predictors, 
with(heart, Surv(start,stop,event)))
#   C IndexDxy   S.D.  nmissing 
#  4.95e-01  -9.66e-03   7.15e-02   1.72e+02   0.00e+00 
#this seems bad because it compares the fit to a different Surv than the one 
used to fit it (S, above)

rcorr.cens(-cph(S~ age+transplant+surgery, heart)$linear.predictors, 
with(heart, Surv(stop-start,event)))
#   C IndexDxy   S.D.  nmissing 
#  6.02e-01   2.03e-01   7.54e-02   1.72e+02   0.00e+00 

Is there some way I can compute the correlation for this type of survival time 
specification in R? If not, does anybody have some tips on how to go about 
computing it myself?

Many Thanks

Eleni Rapsomaniki
Research Associate
Strangeways Research Laboratory
Department of Public Health and Primary Care
University of Cambridge
 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Have a function like the _n_ in R ? (Automatic count function )

2009-02-25 Thread Gustaf Rydevik
On Wed, Feb 25, 2009 at 3:30 PM, hadley wickham h.wick...@gmail.com wrote:
 And for completeness here's a function that returns the next integer
 on each call.

 n - (function(){
  i - 0
  function() {
    i - i + 1
    i
  }
 })()

 n()
 [1] 1
 n()
 [1] 2
 n()
 [1] 3
 n()
 [1] 4
 n()
 [1] 5
 n()
 [1] 6


 ;)

 Hadley



*headache*!
I can't wrap my head around this one - too strange code!
Could someone please give a hint on what's going on?
How doesi- i+1 modify i permanently, seeing as i is defined as 0
to start with?

/Gustaf

-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Have any way to write a funtion into a list ?

2009-02-25 Thread Nash

Have any way to write a funtion into a list ?

--
Nash - morri...@ibms.sinica.edu.tw

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Have any way to write a funtion into a list ?

2009-02-25 Thread Philipp Pagel
On Wed, Feb 25, 2009 at 11:11:51PM +0800, Nash wrote:
 Have any way to write a funtion into a list ?

You can do that the same way you would use with any other object:

 foo - function(x){x^2}
 foo(12)
[1] 144
 a - list(foo, 12, 'as')
 a
[[1]]
function(x){x^2}

[[2]]
[1] 12

[[3]]
[1] as


cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 make warning message colorful (or have sound)?

2009-02-25 Thread Sean Zhang
Dear R-helpers:

I am new to R and wonder how to make a warning message colorful (if
possible, having sound is also welcome). I did some research and failed
to see options to allow this functionality. Is this a techical limitation so
far, or I miss some information.

Many thanks in advance.

-sean

[[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 label the branches of a tree

2009-02-25 Thread Philip Twumasi-Ankrah
You may have to change/scale the sizes of the font by using cex and
then to keep all labels within the plotting window, use xpd=TRUE.
Like in



text(fit, use.n=TRUE, cex=0.8, xpd=TRUE)
Philip

--
A Smile costs Nothing But Rewards Everything
  - Anonymous

Happiness is not perfected until it is shared
  -Jane Porter  
  


--- On Wed, 2/25/09, David Winsemius dwinsem...@comcast.net wrote:
From: David Winsemius dwinsem...@comcast.net
Subject: Re: [R] how to label the branches of a tree
To: Utkarsh Singhal utkar...@ambaresearch.com
Cc: R-help Forum r-help@r-project.org
Date: Wednesday, February 25, 2009, 7:28 AM

When I execute that code, I get labels both on the branching points and at the
leaves of the tree. So I guess my reply is cannot reproduce or
do not understand.  They are however not properly positioned and the
edges and bottoms of some of the labels are cut off, but that did not sound like
your question.

Using Mac OS X 10.5.6 and the ATT binary of R2.8.1. ‘rpart’ version 3.1-42.

--David Winsemius

Note:  your mailer is putting single quotes inside the enclosing angle brackets
so my mailer does not recognize the r-help address as a valid address. Since
this is the first time I have encountered this construction, I wonder if your
mailer is adhering to standards in its reply-to functions.



On Feb 25, 2009, at 1:19 AM, Utkarsh Singhal wrote:

 Hi,
 
 
 
 I am using rpart package to fit classification trees.
 
 
 
 library(rpart)
 
 fit - rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)
 
 plot(fit,uniform=T)
 
 text(fit, use.n=TRUE)
 
 
 
 But I am unable to label the branches (not the nodes) of the tree. Can
somebody help me out in this?
 
 
 
 Thank you,
 
 Regards
 
 Utkarsh Singhal | Amba Research
 
 Ph +91 80 3980 8017 | Mob +91 99 0295 8815
 
 Bangalore * Colombo * London * New York * San José * Singapore *
www.ambaresearch.com  mailto:utkar...@ambaresearch.com
 
 
 
 
 
 This e-mail may contain confidential and/or privileged i...{{dropped:13}}
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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.



  
[[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] Have any way to write a funtion into a list ?

2009-02-25 Thread Uwe Ligges



Nash wrote:

Have any way to write a funtion into a list ?



Sure:

A - list(mean, var)
A[[1]](1:2) # 1.5
A[[2]](1:2) # 0.5

Uwe Ligges




--
Nash - morri...@ibms.sinica.edu.tw

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Have a function like the _n_ in R ? (Automatic count function )

2009-02-25 Thread Charles C. Berry

On Wed, 25 Feb 2009, Gustaf Rydevik wrote:


On Wed, Feb 25, 2009 at 3:30 PM, hadley wickham h.wick...@gmail.com wrote:

And for completeness here's a function that returns the next integer
on each call.

n - (function(){
 i - 0
 function() {
   i - i + 1
   i
 }
})()


n()

[1] 1

n()

[1] 2

n()

[1] 3

n()

[1] 4

n()

[1] 5

n()

[1] 6


;)

Hadley




*headache*!
I can't wrap my head around this one - too strange code!
Could someone please give a hint on what's going on?
How doesi- i+1 modify i permanently, seeing as i is defined as 0
to start with?



i is not _defined_ as zero. It is initially _assigned_ the value of zero 
and is subsequently assigned other values.


As for the details of what goes here, see

An Introduction to R
Section 10.7 Scope

and study the open.acount()  example there.

HTH,

Chuck



/Gustaf

--
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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:cbe...@tajo.ucsd.edu   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] Data Envelopment Analysis in R

2009-02-25 Thread Arup

How do I do a data envelopment analysis in R...provide me with the step by
step procedure for that..thanks in advance...

Arup
-- 
View this message in context: 
http://www.nabble.com/Data-Envelopment-Analysis-in-R-tp22199360p22199360.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] Using very large matrix

2009-02-25 Thread Tony Breyal
looks like you've run out of memory mate, because that sure is a big
matrix, you'd probably need 64 bit OS/CPU/R and loads of RAM.

see thread: 
http://www.nabble.com/Error-in-matrix:--too-many-elements-specified-td20457910.html

I know there are some packages on cran which help with large datasets,
but i haven't got around to using them myself (yet).

from: http://cran.r-project.org/web/views/HighPerformanceComputing.html

[quote start...]
Large memory and out-of-memory data

* The bigmemory package by Kane and Emerson permits storing large
objects such as matrices in memory and uses external pointer objects
to refer to them. This permits transparent access from R without
bumping against R's internal memory limits. Several R processes on the
same computer can also shared big memory objects.

* A large number of database packages, and database-alike packages
(such as sqldf by Grothendieck) are also of potential interest but not
(yet?) reviewed here.
[quote end.]

Just for fun, i just tried (for the first time):
 library(bigmemory)
 big.matrix(nrow=8, ncol=8, type='double')

but i ended up crashing out of R on my low spec windows XP uni
laptop :D

hope that helps a little,
Tony Breyal

On 25 Feb, 11:04, Corrado ct...@york.ac.uk wrote:
 Dear friends,

 I have to use a very large matrix. Something of the sort of
 matrix(8,8,n)  where n is something numeric of the sort 0.xx

 I have not found a way of doing it. I keep getting the error

 Error in matrix(nrow = 8, ncol = 8, 0.2) : too many elements specified

 Any suggestions? I have searched the mailing list, but to no avail.

 Best,
 --
 Corrado Topi

 Global Climate Change  Biodiversity Indicators
 Area 18,Department of Biology
 University of York, York, YO10 5YW, UK
 Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

 __
 r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guidehttp://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] All the products of common factors

2009-02-25 Thread Stavros Macrakis
On Wed, Feb 25, 2009 at 9:25 AM, Fox, Gordon g...@cas.usf.edu wrote:
 The tricky part isn't finding the common factors -- we knew how to do
 that, though not in so concise a fashion as some of these suggestions.
 It was finding all their products without what I (as a recovered Fortran
 programmer) would call truly brute force. Several of these suggestions
 solve the problem nicely!

Are you sure you are not confusing *prime factors* with *factors*?  My
understanding is that you are looking for all the factors of A which
are also factors of B, i.e. the common factors of A and B.  Why else
would you be computing all those products?

   -s

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 get JRI to work from my NetBeans

2009-02-25 Thread Yakub Sebastian
Hi,
I need your help. I have downloaded a precompiled JRI as part of rJava. I
have included rJava as part of my R package libraries.
Now I need to be able to work with some R functions from my Java apps. I'm
using NetBeans on Windows.

I have followed some instructions from http://www.rforge.net/JRI/
but i keep on getting errors when compiling my Java app as follows:

run:
Cannot find JRI native library!
Please make sure that the JRI native library is in a directory listed in
java.library.path.

java.lang.UnsatisfiedLinkError: no jri in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at org.rosuda.JRI.Rengine.clinit(Rengine.java:9)
at rtest.main(rtest.java:61)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)


Can anyone help me with detailed steps to solve the problem? Thanks.

-- 
Yakub

[[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] Linear Discriminant Analysis

2009-02-25 Thread Arup

Kindly let me know the process to carry out a Linear discriminant
analysis...thanks in advance

Arup
-- 
View this message in context: 
http://www.nabble.com/Linear-Discriminant-Analysis-tp22199424p22199424.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] read and reshape time series table with empty items

2009-02-25 Thread Bastian Pöschl
Dear useR's,
I have a problem to read data (daily precipitation).
The data are formated in months by columns wich leads to empty items in
months with less then 31 days.

What i did was reading the file and try to reshape the object

a- read.table(nds.txt, header=TRUE, sep=;, dec = .,
na.string=NA)
ar-reshape(a,
timevar=month,varying=list(c(Jan,Febr,März,April,Mai,Juni,Juli,Aug,Sept,Okt,Nov,Dez)),direction=long)

My problem is:
months are rowed instead of years (78Jan,79Jan,...,79Dec,80Dec)
empty items (like Feb30 and Feb31) are filled with NA

My aim is toget a simple data frame ore time series with format:

Date,value
1979/4/1;0.6
1979/4/2;0.0
...
1980/4/1;1.2
1980/4/1;1.3
1980/4/1;0.0

The data I've got have been excel tables for each year. I transformed
them to a text file that looks like:

#Precipitation in mm like in nds.txt
Jahr;Tag;Jan;Febr;März;April;Mai;Juni;Juli;Aug;Sept;Okt;Nov;Dez
1978;1;NA;NA;NA;0.0;5.5;0.0;11.8;0.0;2.4;6.4;0.0;0.0
1978;2;NA;NA;NA;0.0;0.5;0.0;2.0;2.0;0.0;9.0;0.0;0.0
1978;3;NA;NA;NA;0.3;0.0;3.0;3.2;0.4;0.0;24.7;0.0;0.0
1978;4;NA;NA;NA;0.7;0.0;0.0;24.4;1.1;0.0;8.6;0.0;0.0
1978;5;NA;NA;NA;11.8;2.2;0.0;17.0;0.0;0.0;0.0;0.0;0.0
1978;6;NA;NA;NA;0.5;0.5;0.0;4.5;4.4;10.6;0.0;0.0;0.0
1978;7;NA;NA;NA;0.0;6.5;0.0;0.5;29.0;9.4;0.0;0.0;0.0
1978;8;NA;NA;1.0;0.0;7.3;4.0;0.0;6.0;6.7;0.0;0.0;7.0
1978;9;NA;NA;4.0;0.3;2.0;3.5;2.7;0.4;2.9;0.0;0.0;0.0
1978;10;NA;NA;0.0;1.5;2.4;19.5;0.5;1.8;0.5;0.0;0.0;0.0
1978;11;NA;NA;3.8;9.0;2.8;0.0;4.0;0.0;0.0;0.0;0.0;0.0
1978;12;NA;NA;0.0;6.8;3.5;0.0;2.5;0.0;11.3;0.0;0.0;3.0
1978;13;NA;NA;1.3;2.8;5.4;3.8;2.3;3.4;0.5;0.0;0.0;1.0
1978;14;NA;NA;0.7;1.0;0.3;0.2;7.9;0.0;0.0;0.0;0.0;1.0
1978;15;NA;NA;3.7;2.7;4.8;0.0;4.2;0.0;0.0;0.0;0.0;0.0
1978;16;NA;NA;13.7;2.8;0.0;1.4;0.0;5.5;0.0;0.0;0.5;1.8
1978;17;NA;NA;0.0;1.5;3.8;2.3;0.0;2.3;0.0;3.5;0.0;0.0
1978;18;NA;NA;0.0;0.0;1.0;0.0;11.6;0.0;0.5;5.3;0.0;0.0
1978;19;NA;NA;1.0;0.0;7.0;0.0;1.1;0.0;0.0;0.0;0.0;4.0
1978;20;NA;NA;17.5;0.0;0.5;0.2;0.0;0.0;0.0;0.0;0.0;0.3
1978;21;NA;NA;1.0;1.5;4.5;0.0;2.6;0.0;0.0;0.0;0.0;0.7
1978;22;NA;NA;0.5;0.0;12.0;1.6;0.0;0.0;0.2;1.7;0.0;3.5
1978;23;NA;NA;4.0;0.5;5.8;5.8;0.0;0.0;13.0;3.7;0.0;1.3
1978;24;NA;NA;0.8;0.0;12.0;24.3;0.0;0.0;3.3;0.0;0.0;0.0
1978;25;NA;NA;0.0;0.0;0.0;4.4;0.0;0.0;0.0;0.0;0.0;0.0
1978;26;NA;NA;5.0;0.0;0.5;0.2;1.0;0.0;0.0;6.0;5.7;0.0
1978;27;NA;NA;2.2;6.0;0.0;1.3;9.8;0.0;2.3;3.0;2.9;0.0
1978;28;NA;NA;0.7;1.8;0.0;0.4;0.0;0.0;5.4;0.0;1.5;0.0
1978;29;NA;;0.0;0.5;0.5;0.0;0.0;4.0;3.5;0.0;0.0;3.5
1978;30;NA;;0.0;1.0;0.0;0.0;0.0;6.0;6.1;0.0;0.0;1.5
1978;31;NA;;0.0;;0.0;;0.0;1.5;;0.0;;0.9
1979;1;3.5;1.0;0.5;NA;NA;0.1;0.0;0.5;0.0;0.0;0.0;0.0
1979;2;0.3;0.0;0.0;NA;NA;0.7;2.7;0.5;0.0;0.0;1.6;0.0
1979;3;0.5;2.7;0.0;NA;NA;0.0;3.0;2.5;1.0;0.0;1.0;0.0
1979;4;0.0;0.9;0.3;NA;NA;0.0;0.9;3.0;0.1;0.0;0.0;0.0
1979;5;0.0;2.2;0.0;NA;NA;0.0;0.0;0.0;0.0;0.6;3.5;0.0
1979;6;0.0;1.0;0.0;NA;NA;0.1;0.0;0.4;0.0;1.7;11.5;0.0
1979;7;0.0;1.0;0.0;NA;NA;1.0;0.6;0.0;0.0;0.0;5.0;0.0
1979;8;0.0;0.7;0.3;NA;NA;1.8;6.5;7.5;6.8;0.0;3.5;0.0
1979;9;3.5;1.8;0.8;NA;NA;0.2;9.3;2.2;4.3;0.0;6.5;0.9
1979;10;0.0;1.2;18.8;NA;NA;1.0;11.0;7.0;0.2;0.0;9.0;2.0
1979;11;1.2;1.0;7.8;NA;NA;3.4;0.0;1.4;0.0;0.3;0.0;12.0
1979;12;0.8;0.5;1.8;NA;NA;1.0;7.0;2.3;0.0;0.0;0.3;2.5
1979;13;1.4;0.0;0.0;NA;NA;3.2;3.0;0.0;0.0;5.3;0.0;0.0
1979;14;0.0;0.0;NA;NA;NA;30.5;0.7;0.0;3.3;4.6;0.8;3.9
1979;15;0.0;13.5;NA;NA;NA;1.4;0.0;0.0;2.2;19.0;8.0;3.4
1979;16;0.5;1.5;NA;NA;NA;20.2;0.0;0.0;0.0;1.2;6.8;1.8
1979;17;0.5;5.5;NA;NA;NA;14.8;4.0;5.5;0.0;11.1;9.8;1.4
1979;18;0.0;3.5;NA;NA;NA;2.0;0.0;14.5;0.0;0.0;3.0;0.8
1979;19;0.0;0.0;NA;NA;NA;0.0;4.0;0.0;0.0;0.0;6.0;4.0
1979;20;0.0;0.0;NA;NA;NA;0.0;6.2;1.0;2.3;0.0;6.2;1.2
1979;21;0.0;0.0;NA;NA;NA;0.0;0.0;0.0;36.0;0.0;1.0;4.0
1979;22;0.0;0.0;NA;NA;NA;0.0;0.0;0.0;35.9;0.8;8.0;17.0
1979;23;2.3;0.0;NA;NA;NA;0.0;0.0;1.5;4.6;5.8;0.0;3.0
1979;24;0.0;0.0;NA;NA;NA;0.0;0.0;27.3;1.9;0.0;0.0;1.0
1979;25;0.5;0.0;NA;NA;NA;0.7;0.0;0.8;0.0;0.0;0.0;0.0
1979;26;4.0;0.0;NA;NA;0.0;2.0;0.0;2.1;0.0;0.0;0.0;0.0
1979;27;11.5;0.0;NA;NA;4.5;3.6;0.0;0.0;0.0;0.0;4.0;0.0
1979;28;3.0;2.0;NA;NA;0.0;1.1;1.0;0.5;0.0;3.6;0.0;0.0
1979;29;0.8;;NA;NA;0.0;0.0;5.0;0.0;0.0;0.6;0.0;0.0
1979;30;0.8;;NA;NA;0.0;0.0;5.4;0.0;0.0;1.8;0.0;0.0
1979;31;0.4;;NA;;1.7;;15.5;0.0;;0.4;;0.0
1980;1;NA;NA;NA;NA;NA;0.6;0.0;0.0;1.0;0.0;0.0;NA
1980;2;NA;NA;NA;NA;NA;0.5;0.0;0.0;0.0;1.5;0.0;NA
1980;3;NA;NA;NA;NA;NA;0.7;3.6;0.0;0.0;0.0;0.0;NA
1980;4;NA;NA;NA;NA;NA;17.2;0.0;6.5;0.0;0.0;2.2;NA
1980;5;NA;NA;NA;NA;NA;0.0;0.0;0.0;0.0;0.0;0.7;NA
1980;6;NA;NA;NA;NA;NA;0.5;0.0;0.0;6.4;0.0;NA;NA
1980;7;NA;NA;NA;NA;0.0;0.0;2.3;0.0;0.0;0.5;NA;NA
1980;8;NA;NA;NA;NA;2.3;2.3;2.8;10.5;0.0;10.5;NA;NA
1980;9;NA;NA;NA;NA;6.7;2.2;21.0;0.0;3.8;7.8;NA;NA
1980;10;NA;NA;NA;NA;0.9;2.7;3.5;0.0;2.2;2.3;NA;NA
1980;11;NA;NA;NA;NA;0.9;1.2;0.3;0.0;4.0;3.4;NA;NA
1980;12;NA;NA;NA;NA;0.0;0.0;0.0;5.0;0.0;1.5;NA;NA
1980;13;NA;NA;NA;NA;0.0;0.0;3.5;0.0;0.0;0.0;NA;NA
1980;14;NA;NA;NA;NA;8.3;0.0;0.0;0.0;0.0;0.0;NA;NA
1980;15;NA;NA;NA;NA;19.0;2.0;0.5;1.3;0.0;0.0;NA;NA

[R] survival::predict.coxph

2009-02-25 Thread Bernhard Reinhardt

Hi,

if I got it right then the survival-time we expect for a subject is the 
integral over the specific survival-function of the subject from 0 to t_max.


If I have a trained cox-model and want to make a prediction of the 
survival-time for a new subject I could use
survfit(coxmodel, newdata=newSubject) to estimate a new 
survival-function which I have to integrate thereafter.


Actually I thought predict(coxmodel, newSubject) would do this for me, 
but I´m confused which type I have to declare. If I understand the 
little pieces of documentation right then none of the available types is 
exactly the predicted survival-time.
I think I have to use the mean survival-time of the baseline-function 
times exp(the result of type linear predictor).


Am I right?

Regards

Bernhard

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] read multiplan or sylk files in R

2009-02-25 Thread Philip Twumasi-Ankrah
According to the microsoft site http://support.microsoft.com/kb/323626;, SYLK 
files are 
ordinary text or csv files with a peculiar character in that the first two 
characters of the file are the uppercase letters.
  For example for a csv file, the first column may contain the 
variable identity written as ID. Excel would indicate this as a SYLK file. 
The way around this is to change the variable name to lower case id then you 
can save this file in any format that is readable to R.

Have a great day. 

--
A Smile costs Nothing But Rewards Everything
  - Anonymous

Happiness is not perfected until it is shared
  -Jane Porter  
  


--- On Wed, 2/25/09, GOUACHE David d.goua...@arvalisinstitutduvegetal.fr 
wrote:
From: GOUACHE David d.goua...@arvalisinstitutduvegetal.fr
Subject: [R] read multiplan or sylk files in R
To: r-h...@stat.math.ethz.ch
Date: Wednesday, February 25, 2009, 7:48 AM

Hello,

This may sound crazy, but I have a large number of Multiplan data files I'm
in the process of recuperating, and I'm hoping to avoid having to open them
one by one to convert them into a modern, directly usable format. So I was
wondering if someone somewhere had encountered this and maybe had a way to read
Multiplan files in R, or, at least, a way to read SYLK files directly in R.

Any help appreciated.
Thanks.

David Gouache
ARVALIS - Institut du végétal
Station de La Minière
78280 Guyancourt
Tel: 01.30.12.96.22 / Port: 06.86.08.94.32

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] how to label the branches of a tree

2009-02-25 Thread Utkarsh Singhal
Hi David, 

 

May be I was not clear, but I want to label the branches itself and not the 
branching points or the leaves.

 

Regards

Utkarsh

 



From: Philip Twumasi-Ankrah [mailto:nana_kwadwo_der...@yahoo.com] 
Sent: Wednesday, February 25, 2009 9:07 PM
To: Utkarsh Singhal
Cc: R-help Forum
Subject: Re: [R] how to label the branches of a tree



You may have to change/scale the sizes of the font by using cex and then to 
keep all labels within the plotting window, use xpd=TRUE. Like in

text(fit, use.n=TRUE, cex=0.8, xpd=TRUE)

Philip

--
A Smile costs Nothing But Rewards Everything
  - Anonymous

Happiness is not perfected until it is shared
  -Jane Porter  
http://ads.forbes.com/RealMedia/ads/adstream_lx.ads/welcome.forbes.com/fdc/65545913/Block/SonyHDTV_Welcome_Thought_070105/Sybase_Welcome_Thought_061130.html/6163393332613435396536363430?_RM_EMPTY_;
   



--- On Wed, 2/25/09, David Winsemius dwinsem...@comcast.net wrote:

From: David Winsemius dwinsem...@comcast.net
Subject: Re: [R] how to label the branches of a tree
To: Utkarsh Singhal utkar...@ambaresearch.com
Cc: R-help Forum r-help@r-project.org
Date: Wednesday, February 25, 2009, 7:28 AM

When I execute that code, I get labels both on the branching points and at the

leaves of the tree. So I guess my reply is cannot reproduce or

do not understand.  They are however not properly positioned and the

edges and
 bottoms of some of the labels are cut off, but that did not sound like

your question.

  

Using Mac OS X 10.5.6 and the ATT binary of R2.8.1. 'rpart' version 3.1-42.

  

--David Winsemius

  

Note:  your mailer is putting single quotes inside the enclosing angle brackets

so my mailer does not recognize the r-help address as a valid address. Since

this is the first time I have encountered this construction, I wonder if your

mailer is adhering to standards in its reply-to functions.

  

  

  

On Feb 25, 2009, at 1:19 AM, Utkarsh Singhal wrote:

  

 Hi,

 

 

 

 I am using rpart package to fit classification trees.

 

 

 

 library(rpart)

 

 fit - rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)

 

 plot(fit,uniform=T)

 

 text(fit, use.n=TRUE)

 

 

 

 But I am unable to label the branches (not
 the nodes) of the tree. Can

somebody help me out in this?

 

 

 

 Thank you,

 

 Regards

 

 Utkarsh Singhal | Amba Research

 

 Ph +91 80 3980 8017 | Mob +91 99 0295 8815

 

 Bangalore * Colombo * London * New York * San José * Singapore *

www.ambaresearch.com  mailto:utkar...@ambaresearch.com

 

 

 

 

 

 This e-mail may contain confidential and/or privileged i...{{dropped:13}}

 

 __

 R-help@r-project.org mailing list

 https://stat.ethz.ch/mailman/listinfo/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.



This e-mail may contain confidential and/or privileged i...{{dropped:13}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Linear Discriminant Analysis

2009-02-25 Thread Jorge Ivan Velez
Dear Arup,
See the lda function in the MASS package. In general,

 require(MASS)
Loading required package: MASS
 ?lda

HTH,

Jorge


On Wed, Feb 25, 2009 at 4:44 AM, Arup arup.pramani...@gmail.com wrote:


 Kindly let me know the process to carry out a Linear discriminant
 analysis...thanks in advance

 Arup
 --
 View this message in context:
 http://www.nabble.com/Linear-Discriminant-Analysis-tp22199424p22199424.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.


[[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] Similarity between clusters generated by hclust + cutree

2009-02-25 Thread Corrado
Dear friends

I have clustered some objects using the hclust algorithm, with method ward. I 
then cutree with 48 classes. 

distPredTurn-as.dist(resultMatrix)
hctr-hclust(distPredTurn,ward)
cutree(hctr,k=NC)

I would like to estimate the similarity between each pair of the 48 clusters, 
for example as (1-distance or dissimilarity) between the centroids.

Any clue on how I can do that?

Regards
-- 
Corrado Topi

Global Climate Change  Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


Re: [R] Linear Discriminant Analysis

2009-02-25 Thread Christos Hatzis
Maybe as a starter

RSiteSearch(linear discriminant analysis) 

R has tools to help you help yourself with this types of questions.

-Christos

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Arup
 Sent: Wednesday, February 25, 2009 4:45 AM
 To: r-help@r-project.org
 Subject: [R] Linear Discriminant Analysis
 
 
 Kindly let me know the process to carry out a Linear 
 discriminant analysis...thanks in advance
 
 Arup
 --
 View this message in context: 
 http://www.nabble.com/Linear-Discriminant-Analysis-tp22199424p
 22199424.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 


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


Re: [R] Have a function like the _n_ in R ? (Automatic count function )

2009-02-25 Thread Wacek Kusnierczyk
hadley wickham wrote:
 On Wed, Feb 25, 2009 at 8:41 AM, Wacek Kusnierczyk
 waclaw.marcin.kusnierc...@idi.ntnu.no wrote:
   
 hadley wickham wrote:
 
 And for completeness here's a function that returns the next integer
 on each call.

 n - (function(){
   i - 0
   function() {
 i - i + 1
 i
   }
 })()

   
 actually, you do not need the external function to have the functionality:

n = local({
i = 0
function() (i - i + 1)[1] })

n()
# 1
n()
# 2
 

 Yes, I'm just using the function as a way of creating an environment.
 The function method is a little more flexible if you want multiple
 independent counters though.
   

not as it stands above, because you immediately apply your function and
lose grip of it -- so it's just as do-once a solution as that with
local.  but clearly, to have multiple independent counters, you'd need
two nested functions, as in this generalized version:

make.counter =
function(value)
function(increment)
(value - value + increment)[1]

counters =
lapply(rep(0, 3), make.counter)
mapply(
function(counter, increment)
counter(increment),
counters, 1)
# 1 1 1

which is what you presumably had in mind, roughly.

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Help with Latex (Hmisc)

2009-02-25 Thread Marc Schwartz
on 02/25/2009 07:52 AM Frank E Harrell Jr wrote:
 Dieter Menne wrote:
 Frank E Harrell Jr f.harrell at vanderbilt.edu writes:

 ... Word and pdf

 It depends on how you copy.  By all means use Insert ... Picture ...
 from file and directly insert pdf.  

 Please, tell me how you got this to work.

 Dieter

 
 On Word 2003 there was no pdf option but I just used Insert ... Picture
 ... From File ... encapsulated postscript.  We need to check that Word
 did not convert this to bitmap though.

That is still the case with Office 2007, that is, no PDF import.

If you import an EPS file and there is no pre-existing preview image, a
bitmapped preview image will be generated upon import. It is the
bitmapped image that you will see visually on the display and this is
the image that will be printed by default, as Office does not natively
render EPS. As I recall, older versions of Office would just leave you
with a box-like placeholder for the EPS image, with no other indication
of the content.

You need to print to a PS compatible printer in order for the EPS image
to be used.

The same general situation is in place for OO.org relative to EPS images.

There is a beta version of an OO.org PDF import filter available here:

http://extensions.services.openoffice.org/project/pdfimport

however, my experience with it last fall was less than enthusiastic and
it still has a ways to go. It looks like there have been no updates for
a while.

There are commercial applications available that can enable you to
import a PDF file into Office and a Google search will yield many
options. I have not tried any of them, so buyer beware.

HTH,

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 get JRI to work from my NetBeans

2009-02-25 Thread Rowe, Brian Lee Yung (Portfolio Analytics)
Did you set a system property for java.libary.path that points to the
native library as the error message instructs?

I'm not familiar with NetBeans, but in Eclipse you can set the JVM
properties in a dialog. Otherwise you can always pass it in via the
command line: -Djava.library.path=path to the JRI library

HTH,
Brian

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Yakub Sebastian
Sent: Wednesday, February 25, 2009 4:34 AM
To: r-help@r-project.org
Subject: [R] How to get JRI to work from my NetBeans


Hi,
I need your help. I have downloaded a precompiled JRI as part of rJava.
I
have included rJava as part of my R package libraries.
Now I need to be able to work with some R functions from my Java apps.
I'm
using NetBeans on Windows.

I have followed some instructions from http://www.rforge.net/JRI/
but i keep on getting errors when compiling my Java app as follows:

run:
Cannot find JRI native library!
Please make sure that the JRI native library is in a directory listed in
java.library.path.

java.lang.UnsatisfiedLinkError: no jri in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at org.rosuda.JRI.Rengine.clinit(Rengine.java:9)
at rtest.main(rtest.java:61)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)


Can anyone help me with detailed steps to solve the problem? Thanks.

-- 
Yakub

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

--
This message w/attachments (message) may be privileged, confidential or 
proprietary, and if you are not an intended recipient, please notify the 
sender, do not use or share it and delete it. Unless specifically indicated, 
this message is not an offer to sell or a solicitation of any investment 
products or other financial product or service, an official confirmation of any 
transaction, or an official statement of Merrill Lynch. Subject to applicable 
law, Merrill Lynch may monitor, review and retain e-communications (EC) 
traveling through its networks/systems. The laws of the country of each 
sender/recipient may impact the handling of EC, and EC may be archived, 
supervised and produced in countries other than the country in which you are 
located. This message cannot be guaranteed to be secure or error-free. 
References to Merrill Lynch are references to any company in the Merrill 
Lynch  Co., Inc. group of companies, which are wholly-owned by Bank of America 
Corporation. Secu!
 rities and Insurance Products: * Are Not FDIC Insured * Are Not Bank 
Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to 
Any Banking Service or Activity * Are Not Insured by Any Federal Government 
Agency. Attachments that are part of this E-communication may have additional 
important disclosures and disclaimers, which you should read. This message is 
subject to terms available at the following link: 
http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you 
consent to the foregoing.
--

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Have a function like the _n_ in R ? (Automatic count function )

2009-02-25 Thread Gustaf Rydevik
On Wed, Feb 25, 2009 at 4:43 PM, Charles C. Berry cbe...@tajo.ucsd.edu wrote:
 On Wed, 25 Feb 2009, Gustaf Rydevik wrote:

 On Wed, Feb 25, 2009 at 3:30 PM, hadley wickham h.wick...@gmail.com
 wrote:

 And for completeness here's a function that returns the next integer
 on each call.

 n - (function(){
  i - 0
  function() {
    i - i + 1
    i
  }
 })()

 n()

 [1] 1

 n()

 [1] 2

 n()

 [1] 3

 n()

 [1] 4

 n()

 [1] 5

 n()

 [1] 6


 ;)

 Hadley



 *headache*!
 I can't wrap my head around this one - too strange code!
 Could someone please give a hint on what's going on?
 How doesi- i+1 modify i permanently, seeing as i is defined as 0
 to start with?


 i is not _defined_ as zero. It is initially _assigned_ the value of zero and
 is subsequently assigned other values.

 As for the details of what goes here, see

        An Introduction to R
        Section 10.7 Scope

 and study the open.acount()  example there.

 HTH,

 Chuck



Thank you - I think I finally understood how that code got parsed.
Does the text below describe things correctly?
First, Hadley defines a function that returns another function, like this:

function(){
 i - 0
 function() {
   i - i + 1
   i
 }
}

Since the returned function is defined in a local environment , R
returns the function together with that local environment, and lexical
scoping can work it's magic
Finally Hadley evaluates the above defined function-returning
function, and stores the returned function in n.

n-function(){
 i - 0
 function() {
   i - i + 1
   i
 }
}()

*Phew*
That wasn't too difficult after all :-)

/Gustaf


-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] : record which entry in one file doesn't appear in a different file

2009-02-25 Thread Laura Rodriguez Murillo
Hi dear list,

If anybody could help me, it would be great!

I have two files:
File 1 is a list (one column and around 10 rows)
File 2 is a list with all the names from file one and a few more (one
column and more than 10 rows)

What I want is to add a column in file 2 that says which name appeared
in file 1 and which doesn't (yes and no would work as a code)
It's very important to keep the order of the names in file 2.

Thank you!

Laura

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] : record which entry in one file doesn't appear in a different file

2009-02-25 Thread Tal Galili
Hi Laura.

Let's assume file 1 and 2 are vectors loaded in R named: vec1 and vec2,


here is a short code (with dummy numbers) for a solution:



vec1 - c(1,2,34,4,3,6,76)
vec2 - c(1,2,34,76,24,62,1,4234,435,4333,4422,304,776)

which.vec2.where.in.vec1 - vec2 %in% vec1
which.vec2.where.in.vec1.turned.into.yes.and.no-ifelse(which.vec2.where.in.vec1
, yes, no)

cbind(vec2, which.vec2.where.in.vec1.turned.into.yes.and.no)



Cheers,
Tal







On Wed, Feb 25, 2009 at 6:17 PM, Laura Rodriguez Murillo 
laura.lmuri...@gmail.com wrote:

 Hi dear list,

 If anybody could help me, it would be great!

 I have two files:
 File 1 is a list (one column and around 10 rows)
 File 2 is a list with all the names from file one and a few more (one
 column and more than 10 rows)

 What I want is to add a column in file 2 that says which name appeared
 in file 1 and which doesn't (yes and no would work as a code)
 It's very important to keep the order of the names in file 2.

 Thank you!

 Laura

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




-- 
--


My contact information:
Tal Galili
Phone number: 972-50-3373767
FaceBook: Tal Galili
My Blogs:
www.talgalili.com
www.biostatistics.co.il

[[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] Computing sd across an array with missing values

2009-02-25 Thread Matt Oliver
Dear help, suppose I have this array and want to compute sd aross rows and
columns.

p - array(c(1:5, rep(NA, times = 3)), dim = c(5, 5, 3))

apply(p, 1:2, sd) fails because sd requires at least 2 numbers to compute sd

apply(p, 1:2, sd, na.rm = TRUE) fails for the same reason

I crafted my own function that does what I want

sd_fun - function(i){
if(sum(!is.na(i))==0){
temp.sd - NA
}else{
temp.sd - sd(i, na.rm = TRUE)
}
return(temp.sd)
}


apply(p, 1:2, sd_fun)

This does what I want, but when I scale up to large arrays like

pp - array(c(1:5, rep(NA, times = 3)), dim = c(1000, 1000, 60))

the apply function takes a long time to run.

Is there a faster, more efficient way to do this?

Thanks in advance

Matt


-- 
Matthew J. Oliver
Assistant Professor
College of Marine and Earth Studies
University of Delaware
700 Pilottown Rd.
Lewes, DE, 19958
302-645-4079
http://www.ocean.udel.edu/people/profile.aspx?moliver

[[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] Anova Help?

2009-02-25 Thread Dar
I am conducting an experiment where students are put into 5 total
groups (one is the control group).  They are given a task and then I'm
measuring if there are differences (A 5 X 1 between-subject design
will be used for the experiment).  I'm a little confused on the data
explanation (or should I say how do I explain what is being analyzed
versus just comparing values)  Any help?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Anova Help?

2009-02-25 Thread Tal Galili
Hi Dar.

I am not sure I got your question -
Are you asking what analysis to perform ?
Or how to perform it ?

Could you please give more details ?




On Wed, Feb 25, 2009 at 5:52 PM, Dar darre...@aol.com wrote:

 I am conducting an experiment where students are put into 5 total
 groups (one is the control group).  They are given a task and then I'm
 measuring if there are differences (A 5 X 1 between-subject design
 will be used for the experiment).  I'm a little confused on the data
 explanation (or should I say how do I explain what is being analyzed
 versus just comparing values)  Any help?

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




-- 
--


My contact information:
Tal Galili
Phone number: 972-50-3373767
FaceBook: Tal Galili
My Blogs:
www.talgalili.com
www.biostatistics.co.il

[[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] : record which entry in one file doesn't appear in a different file

2009-02-25 Thread Patrizio Frederic
hey Laura,
I hope this help

f1 = c(a,b,c)
f2 = c(b,a,c,d)
match(f2,f1)
f3 = match(f2,f1,0)
?match
cbind(f2,f3)
cbind(f2,f30)
f4 = ifelse(f30,yes,no)
cbind(f2,f4)
data.frame(f2,f4)

Patrizio

2009/2/25 Laura Rodriguez Murillo laura.lmuri...@gmail.com:
 Hi dear list,

 If anybody could help me, it would be great!

 I have two files:
 File 1 is a list (one column and around 10 rows)
 File 2 is a list with all the names from file one and a few more (one
 column and more than 10 rows)

 What I want is to add a column in file 2 that says which name appeared
 in file 1 and which doesn't (yes and no would work as a code)
 It's very important to keep the order of the names in file 2.

 Thank you!

 Laura

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Computing sd across an array with missing values

2009-02-25 Thread Jorge Ivan Velez
Dear Matt,

Here are two ways:

# Data
p - array(c(1:5, rep(NA, times = 3)), dim = c(5, 5, 3))

# First
res-apply(p,3,function(X)
   c(scols=apply(X,2,sd,na.rm=TRUE),srows=apply(X,2,sd,na.rm=TRUE))
   )
res

# Second
res2-apply(p,3,function(X)
   list(scols=apply(X,2,sd,na.rm=TRUE),srows=apply(X,1,sd,na.rm=TRUE))
   )

lapply(res2,function(x) do.call(rbind,x))

HTH,

Jorge


On Wed, Feb 25, 2009 at 10:53 AM, Matt Oliver moli...@udel.edu wrote:

 Dear help, suppose I have this array and want to compute sd aross rows and
 columns.

 p - array(c(1:5, rep(NA, times = 3)), dim = c(5, 5, 3))

 apply(p, 1:2, sd) fails because sd requires at least 2 numbers to compute
 sd

 apply(p, 1:2, sd, na.rm = TRUE) fails for the same reason

 I crafted my own function that does what I want

 sd_fun - function(i){
 if(sum(!is.na(i))==0){
 temp.sd - NA
 }else{
 temp.sd - sd(i, na.rm = TRUE)
 }
 return(temp.sd)
 }


 apply(p, 1:2, sd_fun)

 This does what I want, but when I scale up to large arrays like

 pp - array(c(1:5, rep(NA, times = 3)), dim = c(1000, 1000, 60))

 the apply function takes a long time to run.

 Is there a faster, more efficient way to do this?

 Thanks in advance

 Matt


 --
 Matthew J. Oliver
 Assistant Professor
 College of Marine and Earth Studies
 University of Delaware
 700 Pilottown Rd.
 Lewes, DE, 19958
 302-645-4079
 http://www.ocean.udel.edu/people/profile.aspx?moliver

[[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] Using gregexpr with multiple search elements

2009-02-25 Thread Corey Sparks

Dear list,
I am trying to use gregexpr to see if entries in a dataframe have  
either of two possible values for a string.

here's an example
text-c(fat, rat, cat, dog, log, fish)

If I just wanted to find if any one of the elements in text match the  
pattern at I would do

gregexpr(\\at, text)

which would match on the first three elements, you can do something like
ifelse(gregexpr(\\at,text)-1, 1,0)

to see if a particular entry in the data text is matched.
My problem is I need to check if either of two patterns match in the  
data, an example that doesn't work is

gregexpr(c(\\at, \\og), text)

which is the basic form of what I'm looking to do, if this would work  
I would get a match for elements 1 through 5 of text, since either  
at or og occurs.


If anyone might have an idea about this I would greatly appreciate it.
Best,
Corey

Corey Sparks
Assistant Professor
Department of Demography and Organization Studies
University of Texas at San Antonio
One UTSA Circle
San Antonio, TX 78249
210 458 6858
corey.spa...@utsa.edu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] survival::survfit,plot.survfit

2009-02-25 Thread Jeff Xu

I am confused when trying the function survfit.
my question is:  what does the survival curve given by plot.survfit mean?
is it the survival curve with different covariates at different points?
or just the baseline survival curve?

for example, I run the following code and get the survival curve


library(survival)
fit-coxph(Surv(futime,fustat)~resid.ds+rx+ecog.ps,data=ovarian)
plot(survfit(fit,type=breslow))
summary(survfit(fit,type=breslow))


for the first two failure points, we have s(59|x1)=0.971, s(115|x2)=0.942
how can we guarantee that s(59|x1) is always greater than s(115|x2)?
since s(59|x1)=s_0(59)^exp(\beta'x1) and s(115|x2)=s_0(115)^exp(\beta'x2),
we can manipulate covariates to make s(59|x1)  s(115|x2), right?
do I miss anything?

thanks in advance
Jeff 

-- 
View this message in context: 
http://www.nabble.com/survival%3A%3Asurvfit%2Cplot.survfit-tp22206954p22206954.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] Using gregexpr with multiple search elements

2009-02-25 Thread Christos Hatzis
gregexpr(\\at|\\og, text) 

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Corey Sparks
 Sent: Wednesday, February 25, 2009 11:50 AM
 To: R Help
 Subject: [R] Using gregexpr with multiple search elements
 
 Dear list,
 I am trying to use gregexpr to see if entries in a dataframe 
 have either of two possible values for a string.
 here's an example
 text-c(fat, rat, cat, dog, log, fish)
 
 If I just wanted to find if any one of the elements in text 
 match the pattern at I would do gregexpr(\\at, text)
 
 which would match on the first three elements, you can do 
 something like ifelse(gregexpr(\\at,text)-1, 1,0)
 
 to see if a particular entry in the data text is matched.
 My problem is I need to check if either of two patterns match 
 in the data, an example that doesn't work is 
 gregexpr(c(\\at, \\og), text)
 
 which is the basic form of what I'm looking to do, if this 
 would work I would get a match for elements 1 through 5 of 
 text, since either at or og occurs.
 
 If anyone might have an idea about this I would greatly appreciate it.
 Best,
 Corey
 
 Corey Sparks
 Assistant Professor
 Department of Demography and Organization Studies University 
 of Texas at San Antonio One UTSA Circle San Antonio, TX 78249 
 210 458 6858 corey.spa...@utsa.edu
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] All the products of common factors

2009-02-25 Thread Gordon Fox
Sorry - I didn't express myself very clearly. Yes, we're looking for 
common factors of A and B. One way to get there is by my initial 
approach: find the prime factors of each, select those that are in 
common, and then take pairwise products. My initial question was about 
the last step only. But your approach to the whole problem sidesteps 
that. It's more elegant, as well as faster, than the way I thought of 
the problem.

Gordon

Stavros Macrakis wrote:
 On Wed, Feb 25, 2009 at 9:25 AM, Fox, Gordon g...@cas.usf.edu wrote:
   
 The tricky part isn't finding the common factors -- we knew how to do
 that, though not in so concise a fashion as some of these suggestions.
 It was finding all their products without what I (as a recovered Fortran
 programmer) would call truly brute force. Several of these suggestions
 solve the problem nicely!
 

 Are you sure you are not confusing *prime factors* with *factors*?  My
 understanding is that you are looking for all the factors of A which
 are also factors of B, i.e. the common factors of A and B.  Why else
 would you be computing all those products?

-s
   

-- 
Dr. Gordon A. Fox   Voice: (813)974-7352   Fax: (813)974-3263
Dept. of Integrative Biology ((for US mail:)SCA 110) ((for FedEx etc:)NES 107)
Univ. of South Florida 4202 E. Fowler Ave.
Tampa, FL 33620, USA   http://foxlab.cas.usf.edu

Trying is the first step towards failure. -- Homer Simpson



[[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] Computing sd across an array with missing values

2009-02-25 Thread Jorge Ivan Velez
Hi Mark,
There is a typo in the first way. My apologies. It should be:
# First
res-apply(p,3,function(X)
   c(scols=apply(X,2,sd,na.rm=TRUE),srows=apply(X,1,sd,na.rm=TRUE))
   )
res

HTH,

Jorge


On Wed, Feb 25, 2009 at 11:42 AM, Jorge Ivan Velez jorgeivanve...@gmail.com
 wrote:


 Dear Matt,

 Here are two ways:

 # Data
 p - array(c(1:5, rep(NA, times = 3)), dim = c(5, 5, 3))

 # First
 res-apply(p,3,function(X)
c(scols=apply(X,2,sd,na.rm=TRUE),srows=apply(X,2,sd,na.rm=TRUE))
)
 res

 # Second
 res2-apply(p,3,function(X)
list(scols=apply(X,2,sd,na.rm=TRUE),srows=apply(X,1,sd,na.rm=TRUE))
)

 lapply(res2,function(x) do.call(rbind,x))

 HTH,

 Jorge


 On Wed, Feb 25, 2009 at 10:53 AM, Matt Oliver moli...@udel.edu wrote:

 Dear help, suppose I have this array and want to compute sd aross rows and
 columns.

 p - array(c(1:5, rep(NA, times = 3)), dim = c(5, 5, 3))

 apply(p, 1:2, sd) fails because sd requires at least 2 numbers to compute
 sd

 apply(p, 1:2, sd, na.rm = TRUE) fails for the same reason

 I crafted my own function that does what I want

 sd_fun - function(i){
 if(sum(!is.na(i))==0){
 temp.sd - NA
 }else{
 temp.sd - sd(i, na.rm = TRUE)
 }
 return(temp.sd)
 }


 apply(p, 1:2, sd_fun)

 This does what I want, but when I scale up to large arrays like

 pp - array(c(1:5, rep(NA, times = 3)), dim = c(1000, 1000, 60))

 the apply function takes a long time to run.

 Is there a faster, more efficient way to do this?

 Thanks in advance

 Matt


 --
 Matthew J. Oliver
 Assistant Professor
 College of Marine and Earth Studies
 University of Delaware
 700 Pilottown Rd.
 Lewes, DE, 19958
 302-645-4079
 http://www.ocean.udel.edu/people/profile.aspx?moliver

[[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] vertically aligned X axis labels disappear off R Graphics window

2009-02-25 Thread R User R User
Hi guys,
I'm evaluating R for basic data exploration. I produce a bar plot of the
data, with the x axis labels aligned vertically. However, the start of
labels longer than about 10 characters are cut off by the bottom of the
graphics window.

I'd appreciate your help in properly spacing the space around a plot
reserved for labels so that this problem can be avoided.

Thanks,
Richie

[[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] C-index for models fitted using start, stop in Surv?

2009-02-25 Thread Frank E Harrell Jr

Eleni Rapsomaniki wrote:

Dear R-users,

One can use the rcorr.cens function in Design to compute the C index when only the stop time is indicated (I think implicitely start=0 in that case). When the start and stop times are used in a Surv object, e.g. 


library(Design)
S=with(heart, Surv(start,stop,event))

the object returned is no longer a single number vector, so none of the 
following ways to compare a model fit to S makes sense:

rcorr.cens(-cph(S~ age+transplant+surgery, heart)$linear.predictors, 
with(heart, Surv(start,stop,event)))
#   C IndexDxy   S.D.  nmissing 
#  4.95e-01  -9.66e-03   7.15e-02   1.72e+02   0.00e+00 
#this seems bad because it compares the fit to a different Surv than the one used to fit it (S, above)


rcorr.cens(-cph(S~ age+transplant+surgery, heart)$linear.predictors, 
with(heart, Surv(stop-start,event)))
#   C IndexDxy   S.D.  nmissing 
#  6.02e-01   2.03e-01   7.54e-02   1.72e+02   0.00e+00 


Is there some way I can compute the correlation for this type of survival time 
specification in R? If not, does anybody have some tips on how to go about 
computing it myself?

Many Thanks

Eleni Rapsomaniki
Research Associate
Strangeways Research Laboratory
Department of Public Health and Primary Care
University of Cambridge
 



rcorr.cens is not meant for that.
Frank

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

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


Re: [R] how to label the branches of a tree

2009-02-25 Thread David Winsemius
How do you want the labels to appear? Each branch will be the logical  
conjunction of the criteria for *all* of the upstream splits. Perhaps  
you can get direction by looking at the code of text.rpart:


getAnywhere(text.rpart)

Any split would need to add an  Split-N yes or an  Split-N No to  
any lower branch.


--
David Winsemius

On Feb 25, 2009, at 10:44 AM, Utkarsh Singhal wrote:


Hi David,

May be I was not clear, but I want to label the branches itself and  
not the branching points or the leaves.


Regards
Utkarsh

From: Philip Twumasi-Ankrah [mailto:nana_kwadwo_der...@yahoo.com]
Sent: Wednesday, February 25, 2009 9:07 PM
To: Utkarsh Singhal
Cc: R-help Forum
Subject: Re: [R] how to label the branches of a tree

You may have to change/scale the sizes of the font by using cex  
and then to keep all labels within the plotting window, use  
xpd=TRUE. Like in

text(fit, use.n=TRUE, cex=0.8, xpd=TRUE)
Philip
--
A Smile costs Nothing But Rewards Everything
  -  
Anonymous


Happiness is not perfected until it is shared
  -Jane  
Porter



--- On Wed, 2/25/09, David Winsemius dwinsem...@comcast.net wrote:
From: David Winsemius dwinsem...@comcast.net
Subject: Re: [R] how to label the branches of a tree
To: Utkarsh Singhal utkar...@ambaresearch.com
Cc: R-help Forum r-help@r-project.org
Date: Wednesday, February 25, 2009, 7:28 AM
When I execute that code, I get labels both on the branching points  
and at the


leaves of the tree. So I guess my reply is cannot reproduce or

do not understand.  They are however not properly positioned and the

edges and
 bottoms of some of the labels are cut off, but that did not sound  
like


your question.



Using Mac OS X 10.5.6 and the ATT binary of R2.8.1. ‘rpart’ version  
3.1-42.




--David Winsemius



Note:  your mailer is putting single quotes inside the enclosing  
angle brackets


so my mailer does not recognize the r-help address as a valid  
address. Since


this is the first time I have encountered this construction, I  
wonder if your


mailer is adhering to standards in its reply-to functions.







On Feb 25, 2009, at 1:19 AM, Utkarsh Singhal wrote:



 Hi,







 I am using rpart package to fit classification trees.







 library(rpart)



 fit - rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)



 plot(fit,uniform=T)



 text(fit, use.n=TRUE)







 But I am unable to label the branches (not
 the nodes) of the tree. Can

somebody help me out in this?







 Thank you,



 Regards



 Utkarsh Singhal | Amba Research



 Ph +91 80 3980 8017 | Mob +91 99 0295 8815



 Bangalore * Colombo * London * New York * San José * Singapore *

www.ambaresearch.com  mailto:utkar...@ambaresearch.com











 This e-mail may contain confidential and/or privileged i... 
{{dropped:13}}




 __

 R-help@r-project.org mailing list

 https://stat.ethz.ch/mailman/listinfo/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.

This e-mail may contain confidential and/or privileged...{{dropped:12}}


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] multiple regressions on columns

2009-02-25 Thread Greg Snow
Well add1 (and others) does fit the regressions you asked about if you give it 
the base model only including the intercept and the scope including the x 
variables of interest.  Unfortunately it only returns certain statistics on 
those models, not the whole object, but if you were interested in the test of 
significance, then the F that you could ask to be returned would give that to 
you (you could also modify the function to return any additional information 
that you want/need).  You did not specify what information from the fits you 
wanted, so add1 was a possibility if it matched with what you wanted.

I have made a note to my future self asking future me to use the timetravel 
package to send a copy of the ESP package back in time to past me to help with 
answering posts.  However, present me has not received it yet.  Possibly near 
future me does something that results in far future me not wanting to 
cooperate, I guess I should stick to my diet a little better.

It looks like you found the lapply solution, another option would be to stack 
the data and use the lmList function from the nlme package, or the by function, 
or ..., but if lapply works for you, it is probably not worth the effort to try 
the others.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of GOUACHE David
 Sent: Wednesday, February 25, 2009 1:56 AM
 To: Greg Snow; r-h...@stat.math.ethz.ch
 Subject: [R] RE : multiple regressions on columns
 
 Hello and thanks for your reply, but as you said, this is not really
 what I'm trying to do.
 My purpose is not one of variable selection within a model with
 multiple predictors, but simply fitting a large number of models with
 only one predictor.
 I was just hoping there would be a solution as simple as the one given
 in my example which gives the results of many regression models of the
 type Yi~x where i spans all the colums in a matrix and x is one
 predictor. My objective being the fitting of many regression models of
 the type y~Xi where i spans all the columns in a matrix and y is one
 dependent variable.
 
 Best regards,
 
 David Gouache
 ARVALIS - Institut du végétal
 Station de La Minière
 78280 Guyancourt
 Tel: 01.30.12.96.22 / Port: 06.86.08.94.32
 
 
 -Message d'origine-
 De : Greg Snow [mailto:greg.s...@imail.org]
 Envoyé : mardi 24 février 2009 18:22
 À : GOUACHE David; r-h...@stat.math.ethz.ch
 Objet : RE: multiple regressions on columns
 
 The add1 function might be what you want, there is also addterm in the
 MASS package and the leaps package can do some things along this line
 (plus more).
 
 But before doing this, you may want to ask yourself what question you
 are really trying to answer, then explore if this answers that question
 or not.
 
 --
 Gregory (Greg) L. Snow Ph.D.
 Statistical Data Center
 Intermountain Healthcare
 greg.s...@imail.org
 801.408.8111
 
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
  project.org] On Behalf Of GOUACHE David
  Sent: Tuesday, February 24, 2009 10:13 AM
  To: r-h...@stat.math.ethz.ch
  Subject: [R] multiple regressions on columns
 
  R-helpers,
 
  A quick question regarding my wanting to run multiple regressions
  without writing a loop.
  Looking at a previous discussion :
  http://tolstoy.newcastle.edu.au/R/e2/help/07/02/9740.html
 
  my objective is to do the opposite, i.e. instead of having the same
  independent variable and testing it against multiple dependent
  variables, my goal is to test multiple independent variables against
  the same dependent variable.
 
  Using the iris dataset:
 
  iris4 - as.matrix(iris[,-c(1,5)])
  summary(lm(iris4 ~ Sepal.Length, iris))
 
  what I would have liked is to do the following :
 
  summary(lm(Sepal.Length ~ iris4, iris))
 
  and obtain the results from 3 separate regressions, as above, instead
  of one multiple regression...
 
  Any clues ?
 
  Tanks in advance
 
  David Gouache
  ARVALIS - Institut du végétal
  Station de La Minière
  78280 Guyancourt
  Tel: 01.30.12.96.22 / Port: 06.86.08.94.32
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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 

Re: [R] C-index for models fitted using start, stop in Surv?

2009-02-25 Thread Eleni Rapsomaniki
 rcorr.cens is not meant for that.

Thank you for the clarification. On a second thought, I think (hope) a
time-dependent AUC index should be more appropriate in this case, such
as survivalROC. 

Many many thanks for all your help!

Eleni Rapsomaniki
 
Research Associate
Tel: +44 (0) 1223 740273
Strangeways Research Laboratory
Department of Public Health and Primary Care
University of Cambridge
 

-Original Message-
From: Frank E Harrell Jr [mailto:f.harr...@vanderbilt.edu] 
Sent: 25 February 2009 17:50
To: Eleni Rapsomaniki
Cc: r-help@r-project.org
Subject: Re: [R] C-index for models fitted using start, stop in Surv?

Eleni Rapsomaniki wrote:
 Dear R-users,
 
 One can use the rcorr.cens function in Design to compute the C index
when only the stop time is indicated (I think implicitely start=0 in
that case). When the start and stop times are used in a Surv object,
e.g. 
 
 library(Design)
 S=with(heart, Surv(start,stop,event))
 
 the object returned is no longer a single number vector, so none of
the following ways to compare a model fit to S makes sense:
 
 rcorr.cens(-cph(S~ age+transplant+surgery, heart)$linear.predictors,
with(heart, Surv(start,stop,event)))
 #   C IndexDxy   S.D.  n
missing 
 #  4.95e-01  -9.66e-03   7.15e-02   1.72e+02
0.00e+00 
 #this seems bad because it compares the fit to a different Surv than
the one used to fit it (S, above)
 
 rcorr.cens(-cph(S~ age+transplant+surgery, heart)$linear.predictors,
with(heart, Surv(stop-start,event)))
 #   C IndexDxy   S.D.  n
missing 
 #  6.02e-01   2.03e-01   7.54e-02   1.72e+02
0.00e+00 
 
 Is there some way I can compute the correlation for this type of
survival time specification in R? If not, does anybody have some tips on
how to go about computing it myself?
 
 Many Thanks
 
 Eleni Rapsomaniki
 Research Associate
 Strangeways Research Laboratory
 Department of Public Health and Primary Care
 University of Cambridge
  
 

rcorr.cens is not meant for that.
Frank

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

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


Re: [R] how to label the branches of a tree

2009-02-25 Thread David Winsemius
Following Dr Ripley's advice I looked at the text.rpart documentation  
a bit more thoroughly and after seeing The edges connecting the nodes  
are labeled by left and right splits. I find that the fancy=TRUE  
invocation does cause a labeling of what you appear to be calling  
branches.


See if this minor modification of the rpart example code produces your  
desired result:


library(rpart)
fit - rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)
par(mfrow=c(1,1), xpd=NA)  # otherwise on some devices the text is  
clipped

plot(fit)
text(fit, use.n=TRUE, fancy=TRUE)

On my devices (Mac OS X 10.5.6, R 2.8.1, quartz) the boxes around  
the leaf labels are a bit too low on the default screen device, and  
sending the output to a pdf file does not correct that problem, but as  
always the code is there for you to work with.


--
David Winsemius

 sessionInfo()
R version 2.8.1 Patched (2009-01-07 r47515)
i386-apple-darwin9.6.0

locale:
en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] rpart_3.1-42

loaded via a namespace (and not attached):
[1] grid_2.8.1  lattice_0.17-20 tools_2.8.1

 capabilities()
jpeg  png tifftcltk  X11 aqua http/ftp   
sockets   libxml fifo   cledit
TRUE TRUEFALSE TRUE TRUE TRUE TRUE  
TRUE TRUE TRUE TRUE

   iconv  NLS  profmemcairo
TRUE TRUEFALSE TRUE


On Feb 25, 2009, at 1:01 PM, David Winsemius wrote:

How do you want the labels to appear? Each branch will be the  
logical conjunction of the criteria for *all* of the upstream  
splits. Perhaps you can get direction by looking at the code of  
text.rpart:


getAnywhere(text.rpart)

Any split would need to add an  Split-N yes or an  Split-N No  
to any lower branch.


--
David Winsemius

On Feb 25, 2009, at 10:44 AM, Utkarsh Singhal wrote:


Hi David,

May be I was not clear, but I want to label the branches itself and  
not the branching points or the leaves.


Regards
Utkarsh

From: Philip Twumasi-Ankrah [mailto:nana_kwadwo_der...@yahoo.com]
Sent: Wednesday, February 25, 2009 9:07 PM
To: Utkarsh Singhal
Cc: R-help Forum
Subject: Re: [R] how to label the branches of a tree

You may have to change/scale the sizes of the font by using cex  
and then to keep all labels within the plotting window, use  
xpd=TRUE. Like in

text(fit, use.n=TRUE, cex=0.8, xpd=TRUE)
Philip
--
A Smile costs Nothing But Rewards Everything
 -  
Anonymous


Happiness is not perfected until it is shared
 -Jane  
Porter



--- On Wed, 2/25/09, David Winsemius dwinsem...@comcast.net wrote:
From: David Winsemius dwinsem...@comcast.net
Subject: Re: [R] how to label the branches of a tree
To: Utkarsh Singhal utkar...@ambaresearch.com
Cc: R-help Forum r-help@r-project.org
Date: Wednesday, February 25, 2009, 7:28 AM
When I execute that code, I get labels both on the branching points  
and at the


leaves of the tree. So I guess my reply is cannot reproduce or

do not understand.  They are however not properly positioned and  
the


edges and
bottoms of some of the labels are cut off, but that did not sound  
like


your question.



Using Mac OS X 10.5.6 and the ATT binary of R2.8.1. ‘rpart’ version  
3.1-42.




--David Winsemius



Note:  your mailer is putting single quotes inside the enclosing  
angle brackets


so my mailer does not recognize the r-help address as a valid  
address. Since


this is the first time I have encountered this construction, I  
wonder if your


mailer is adhering to standards in its reply-to functions.







On Feb 25, 2009, at 1:19 AM, Utkarsh Singhal wrote:



 Hi,







 I am using rpart package to fit classification trees.







 library(rpart)



 fit - rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)



 plot(fit,uniform=T)



 text(fit, use.n=TRUE)







 But I am unable to label the branches (not
the nodes) of the tree. Can

somebody help me out in this?







 Thank you,



 Regards



 Utkarsh Singhal | Amba Research



 Ph +91 80 3980 8017 | Mob +91 99 0295 8815



 Bangalore * Colombo * London * New York * San José * Singapore *

www.ambaresearch.com  mailto:utkar...@ambaresearch.com











 This e-mail may contain confidential and/or privileged i... 
{{dropped:13}}




 __

 R-help@r-project.org mailing list

 https://stat.ethz.ch/mailman/listinfo/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 

[R] monotonic GAM with more than one term

2009-02-25 Thread Benjamin Tyner
Hi,

Does anyone know how to fit a GAM where one or more smooth terms are
constrained to be monotonic, in the presence of by variables or
other terms? I looked at the example in ?pcls but so far have not been
able to adapt it to the case where there is more than one predictor.
For example,

require(mgcv)

set.seed(0)
n-100


# Generate data from a monotonic truth.
x-runif(100)*4-1
x-sort(x)

m - structure(rep(1:2,50), .Label=c(one,two), class=factor)

f-as.integer(m) * exp(4*x)/(1+exp(4*x))
y-f+rnorm(100)*0.1
plot(x,y,xlim=c(min(x), max(x)*2))
dat-data.frame(x=x,m=m,y=y)



# Show regular spline fit (and save fitted object)
f.ug-gam(y~m+s(x,k=10,by=m,bs=cr))

bool - m==one
yhat - fitted(f.ug)

lines(x[bool],yhat[bool])
lines(x[!bool],yhat[!bool])

xx - seq(max(x), 2*max(x), length=100)
mm - structure(rep(1:2,50), .Label=c(one,two), class=factor)
yy - predict(f.ug, newdata=data.frame(m=mm,x=xx))

bool - mm==one

lines(xx[bool],yy[bool], lty=2) # show effect of extrapolation
lines(xx[!bool],yy[!bool], lty=2)


# this is where I start running into trouble
   sm-smoothCon(s(x,k=10,by=m,bs=cr),dat,knots=NULL)[[1]]
   FF-mono.con(sm$xp);   # get constraints
   G-list(y=y,
   w=rep(1, n),
   X=sm$X,
   C=matrix(0,0,0),
   S = sm$S,
   off = 0,
   sp=f.ug$sp,
   p=sm$xp,
   Ain = FF$A,
   bin = FF$b
   )


p-pcls(G)  # fit spline (using s.p. from unconstrained fit)
fv-Predict.matrix(sm,data.frame(x=x))%*%p

# can we do this without calling smoothCon directly ?
# also having trouble here.
   f.nofit-gam(y~m+s(x,k=10,by=m,bs=cr),fit=FALSE)
   FF2 - mono.con(f.nofit$smooth[[1]]$xp)

   stopifnot(identical(FF, FF2))

   G2 - list(y = f.nofit$y,
  w = f.nofit$w,
  X = f.nofit$X,
  C = f.nofit$C,
  S = f.nofit$smooth[[1]]$S,
  off = f.nofit$off,
  sp = f.ug$sp,
  p = f.nofit$smooth[[1]]$xp,
  Ain = FF2$A,
  bin = FF2$b
  )

p2 - pcls(G2)
fv2-Predict.matrix(f.nofit$smooth[[1]],data.frame(x=x))%*%p2



Many thanks
-Ben

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] vertically aligned X axis labels disappear off R Graphics window

2009-02-25 Thread Uwe Ligges



R User R User wrote:

Hi guys,
I'm evaluating R for basic data exploration. I produce a bar plot of the
data, with the x axis labels aligned vertically. However, the start of
labels longer than about 10 characters are cut off by the bottom of the
graphics window.

I'd appreciate your help in properly spacing the space around a plot
reserved for labels so that this problem can be avoided.



See ?par, particularly its argument mar.

Uwe Ligges



Thanks,
Richie

[[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] Anova Help?

2009-02-25 Thread Dar
I’m just setting up the experiment and need help explaining what the
data analysis would be.  Let me know of any questions….. what would be
compared and how it would be measured.  Is it a multi-way or 1-way
anova?
Thanks!

A 5 X 1 between-subject design will be used for the experiment. Four
tool groups (Group1, Group2, Group3, Group4) will be able to view one
category of information that their groups are allowed to in their
tools. The control group, however, will have no access to the
experimental tool.

Pre-survey has demographic and previous experience questionnaire.

The independent variable is the exposure to the information. The
independent variable has five levels: no information, appearance
information, educational information, contact information, and
personal information.

The dependent variable will be (2 dependent variables) gathered
through a questionnaire at the end of the study.
Connectedness. This variable will be operationalized as the
Connectedness score
Learning. This variable will be operationalized as the Learning score

Covariates:
Frequency of using tool
Duration of tool use
Previous experience (three types of previous experience).


On Feb 25, 11:35 am, Tal Galili tal.gal...@gmail.com wrote:
 Hi Dar.

 I am not sure I got your question -
 Are you asking what analysis to perform ?
 Or how to perform it ?

 Could you please give more details ?

 On Wed, Feb 25, 2009 at 5:52 PM, Dar darre...@aol.com wrote:
  I am conducting an experiment where students are put into 5 total
  groups (one is the control group).  They are given a task and then I'm
  measuring if there are differences (A 5 X 1 between-subject design
  will be used for the experiment).  I'm a little confused on the data
  explanation (or should I say how do I explain what is being analyzed
  versus just comparing values)  Any help?

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

 --
 --

 My contact information:
 Tal Galili
 Phone number: 972-50-3373767
 FaceBook: Tal Galili
 My Blogs:www.talgalili.comwww.biostatistics.co.il

         [[alternative HTML version deleted]]

 __
 r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guidehttp://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] make check reg-tests-1.R error on solaris

2009-02-25 Thread Karen Noel
R 2.5.1 compiled, passed the make check and has been successfully  
running for a couple years on a Sun Fire V490 running Solaris 9. I  
need a newer version of R, but can't get a newer version of R to pass  
the make check. I've tried 2.8.1, 2.7.2, 2.6.2 and 2.6.0. (2.5.1 still  
passes on this server) At this point I thought I'd try to compile it  
on another Sun server (Solaris 10), but it had the same problem.  
Configuring with no options didn't help. I commented out the failed  
test from the Makefile to see if it would pass the rest of the tests.  
It passes all the rest of the tests. Here is the failure error from  
make check.


make[2]: Entering directory `/usr/local/src/R-2.8.1/tests'
running regression tests
make[3]: Entering directory `/usr/local/src/R-2.8.1/tests'
running code in 'reg-tests-1.R' ...make[3]: *** [reg-tests-1.Rout]  
Error 1

make[3]: Leaving directory `/usr/local/src/R-2.8.1/tests'
make[2]: *** [test-Reg] Error 2
make[2]: Leaving directory `/usr/local/src/R-2.8.1/tests'
make[1]: *** [test-all-basics] Error 1
make[1]: Leaving directory `/usr/local/src/R-2.8.1/tests'
make: *** [check] Error 2
bash-2.05#

Here is output from reg-tests-1.Rout.fail.

[1] 41c6167e dir1 dir2 dirs  
file275c23f2

[6] file33f963f2 moredirs
 file.create(file.path(dd, somefile))
[1] TRUE TRUE TRUE TRUE
 dir(., recursive=TRUE)
[1] 41c6167e  dir1/somefile dir2/somefile
[4] dirs/somefile file275c23f2  file33f963f2
[7] moredirs/somefile
 stopifnot(unlink(dir?) == 1) # not an error
Error: unlink(dir?) == 1 is not TRUE
Execution halted
rm: Cannot remove any directory in the path of the current working  
directory

/tmp/RtmprBjF6W

Looking through the archives I did find a couple other people with  
this error, both running Solaris 10. PR#10501 and PR#11738 have quite  
a lot of information about this error, but I don't see any resolution  
for them.


This looks like it could possibly be enough of a problem that I  
haven't put 2.8.1 in production. Can you help me with a resolution or  
let me know if it is safe to ignore? I'd appreciate it.


Thank you!
Karen

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Gradient function for optim.

2009-02-25 Thread rkevinburton
I have read that when the gradient function is not supplied (is null) then 
first order differencing is used to find the differential. I was trying to 
track down this for my own information but I run into .Internal(optim.). I 
was not sure where to look next to see the function that is automatically 
supplied for the gradient.

Thank you.

Kevin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] run latent class analysis with R

2009-02-25 Thread Drew Linzer

poLCA is designed to work this way.  There's a complete user's guide and
manual on the project website at 

http://userwww.service.emory.edu/~dlinzer/poLCA/
http://userwww.service.emory.edu/~dlinzer/poLCA/ 

Thanks,
Drew

==
Drew Linzer
Assistant Professor
Department of Political Science
Emory University
102 Tarbutton
dlin...@emory.edu
http://userwww.service.emory.edu/~dlinzer
404-727-0697




Wen Gu wrote:
 
 
 What's the best approach to running latent class analysis with R? I've
 downloaded both randomLCA and poLCA packages, but I am interesting in
 running a standard LCA with individual records (not frequency table) as
 input data.
 
 Wen Gu
 
 John Jay College of Criminal Justice445 West 59 StreetNew York, NY 10029
 w...@gc.cuny.edu
 
 
 
 _
 
 
 50F681DAD532637!7540.entry?ocid=TXT_TAGLM_WL_t2_ugc_post_022009
   [[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.
 
 

-- 
View this message in context: 
http://www.nabble.com/run-latent-class-analysis-with-R-tp22197424p22209341.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] biplot.princomp - changing score labels

2009-02-25 Thread Héctor Villalobos
Perhaps this may help you.

Regards




data(iris3)

ir - rbind(iris3[ , , 1], iris3[ , , 2], iris3[ , , 3])

  ir.pca - princomp(ir)
  biplot(ir.pca)

# Rehacer Biplot
# Calcular Factor para re-escalar scores y eigenvectores
  lambda - ir.pca$sdev[1:2] * sqrt(ir.pca$n.obs)

  scores - t( t(ir.pca$scores[ , c(1, 2)]) / lambda )
  variables - t( t(ir.pca$loadings[ , c(1, 2)]) * lambda )


  x11()
  plot(scores, type=p, xlim=c(-0.22, 0.24), ylim=c(-0.2, 0.2),
  pch=c(rep(16, 50), rep(21, 50), rep(14, 50)),
  col=c(rep(red, 50), rep(blue, 50), rep(green, 50)))
abline(v=0, h=0, lty=3)
  par(new=TRUE)
  plot(variables, type=n, xaxt=n, yaxt=n, xlim=c(-22, 24), ylim=c(-20, 
20))
arrows(0, 0, variables[ , 1], variables[ , 2], len=0.1, col=red)
text(2*variables, rownames(variables), col=red, xpd=TRUE)
axis(3); axis(4)



On 25 Feb 2009 at 9:52, Axel Strauß wrote:

Date sent:  Wed, 25 Feb 2009 09:52:54 +0100
From:   Axel Strauß a.stra...@tu-bs.de
To: R-help@r-project.org
Subject:Re: [R] biplot.princomp - changing score labels

 Prof Brian Ripley schrieb:
  On Tue, 24 Feb 2009, Axel Strauß wrote:
 
  OK, the one thing I figured out:
  Is should be like:
  biplot(test.pca, cex=c(2,1), col=c(red,green)...
  to change size, colours etc separately. But I still don't know how
  change lables of observations to symbols properly.
 
  That's not part of the design of the function, so just make a copy
  and edit to meet your fancies.
 
  The designer of biplot.princomp.
 
 The idea behind my question was actually not a styling one but to
 provide additional information in the graph. My observations have
 different species richness and I wanted to adopt symbol size to the
 number of species to show the change of species richness along the
 PCs. Anyway, thanks for the comment - and for designing
 biplot.princomp.

 Axel



--
Héctor Villalobos hvill...@ipn.mx
 CICIMAR - IPN
 A.P. 592. Col. Centro
 La Paz, Baja California Sur, MÉXICO. 23000
 Tels. (+52 612) 122 53 44; 123 46 58; 123 47 34  ext. 82425
 Fax.  (+52 612) 122 53 22

[[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] biplot.princomp - changing score labels

2009-02-25 Thread stephen sefick
have you thought about extracting the data and using this in ggplot?

On Wed, Feb 25, 2009 at 3:52 AM, Axel Strauß a.stra...@tu-bs.de wrote:
 Prof Brian Ripley schrieb:

 On Tue, 24 Feb 2009, Axel Strauß wrote:

 OK, the one thing I figured out:
 Is should be like:
 biplot(test.pca, cex=c(2,1), col=c(red,green)...
 to change size, colours etc separately. But I still don't know how change
 lables of observations to symbols properly.

 That's not part of the design of the function, so just make a copy and
 edit to meet your fancies.

 The designer of biplot.princomp.

 The idea behind my question was actually not a styling one but to provide
 additional information in the graph. My observations have different species
 richness and I wanted to adopt symbol size to the number of species to show
 the change of species richness along the PCs. Anyway, thanks for the comment
 - and for designing biplot.princomp.

 Axel

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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

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.


Re: [R] read and reshape time series table with empty items

2009-02-25 Thread Gabor Grothendieck
Try this:

Lines - 
'Jahr;Tag;Jan;Febr;März;April;Mai;Juni;Juli;Aug;Sept;Okt;Nov;Dez
1978;1;NA;NA;NA;0.0;5.5;0.0;11.8;0.0;2.4;6.4;0.0;0.0
1978;2;NA;NA;NA;0.0;0.5;0.0;2.0;2.0;0.0;9.0;0.0;0.0
1978;3;NA;NA;NA;0.3;0.0;3.0;3.2;0.4;0.0;24.7;0.0;0.0
1978;4;NA;NA;NA;0.7;0.0;0.0;24.4;1.1;0.0;8.6;0.0;0.0
1978;5;NA;NA;NA;11.8;2.2;0.0;17.0;0.0;0.0;0.0;0.0;0.0
1978;6;NA;NA;NA;0.5;0.5;0.0;4.5;4.4;10.6;0.0;0.0;0.0
1978;7;NA;NA;NA;0.0;6.5;0.0;0.5;29.0;9.4;0.0;0.0;0.0
1978;8;NA;NA;1.0;0.0;7.3;4.0;0.0;6.0;6.7;0.0;0.0;7.0
1978;9;NA;NA;4.0;0.3;2.0;3.5;2.7;0.4;2.9;0.0;0.0;0.0
1978;10;NA;NA;0.0;1.5;2.4;19.5;0.5;1.8;0.5;0.0;0.0;0.0
1978;11;NA;NA;3.8;9.0;2.8;0.0;4.0;0.0;0.0;0.0;0.0;0.0
1978;12;NA;NA;0.0;6.8;3.5;0.0;2.5;0.0;11.3;0.0;0.0;3.0
1978;13;NA;NA;1.3;2.8;5.4;3.8;2.3;3.4;0.5;0.0;0.0;1.0
1978;14;NA;NA;0.7;1.0;0.3;0.2;7.9;0.0;0.0;0.0;0.0;1.0
1978;15;NA;NA;3.7;2.7;4.8;0.0;4.2;0.0;0.0;0.0;0.0;0.0
1978;16;NA;NA;13.7;2.8;0.0;1.4;0.0;5.5;0.0;0.0;0.5;1.8
1978;17;NA;NA;0.0;1.5;3.8;2.3;0.0;2.3;0.0;3.5;0.0;0.0
1978;18;NA;NA;0.0;0.0;1.0;0.0;11.6;0.0;0.5;5.3;0.0;0.0
1978;19;NA;NA;1.0;0.0;7.0;0.0;1.1;0.0;0.0;0.0;0.0;4.0
1978;20;NA;NA;17.5;0.0;0.5;0.2;0.0;0.0;0.0;0.0;0.0;0.3
1978;21;NA;NA;1.0;1.5;4.5;0.0;2.6;0.0;0.0;0.0;0.0;0.7
1978;22;NA;NA;0.5;0.0;12.0;1.6;0.0;0.0;0.2;1.7;0.0;3.5
1978;23;NA;NA;4.0;0.5;5.8;5.8;0.0;0.0;13.0;3.7;0.0;1.3
1978;24;NA;NA;0.8;0.0;12.0;24.3;0.0;0.0;3.3;0.0;0.0;0.0
1978;25;NA;NA;0.0;0.0;0.0;4.4;0.0;0.0;0.0;0.0;0.0;0.0
1978;26;NA;NA;5.0;0.0;0.5;0.2;1.0;0.0;0.0;6.0;5.7;0.0
1978;27;NA;NA;2.2;6.0;0.0;1.3;9.8;0.0;2.3;3.0;2.9;0.0
1978;28;NA;NA;0.7;1.8;0.0;0.4;0.0;0.0;5.4;0.0;1.5;0.0
1978;29;NA;;0.0;0.5;0.5;0.0;0.0;4.0;3.5;0.0;0.0;3.5
1978;30;NA;;0.0;1.0;0.0;0.0;0.0;6.0;6.1;0.0;0.0;1.5
1978;31;NA;;0.0;;0.0;;0.0;1.5;;0.0;;0.9
1979;1;3.5;1.0;0.5;NA;NA;0.1;0.0;0.5;0.0;0.0;0.0;0.0
1979;2;0.3;0.0;0.0;NA;NA;0.7;2.7;0.5;0.0;0.0;1.6;0.0
1979;3;0.5;2.7;0.0;NA;NA;0.0;3.0;2.5;1.0;0.0;1.0;0.0
1979;4;0.0;0.9;0.3;NA;NA;0.0;0.9;3.0;0.1;0.0;0.0;0.0
1979;5;0.0;2.2;0.0;NA;NA;0.0;0.0;0.0;0.0;0.6;3.5;0.0
1979;6;0.0;1.0;0.0;NA;NA;0.1;0.0;0.4;0.0;1.7;11.5;0.0
1979;7;0.0;1.0;0.0;NA;NA;1.0;0.6;0.0;0.0;0.0;5.0;0.0
1979;8;0.0;0.7;0.3;NA;NA;1.8;6.5;7.5;6.8;0.0;3.5;0.0
1979;9;3.5;1.8;0.8;NA;NA;0.2;9.3;2.2;4.3;0.0;6.5;0.9
1979;10;0.0;1.2;18.8;NA;NA;1.0;11.0;7.0;0.2;0.0;9.0;2.0
1979;11;1.2;1.0;7.8;NA;NA;3.4;0.0;1.4;0.0;0.3;0.0;12.0
1979;12;0.8;0.5;1.8;NA;NA;1.0;7.0;2.3;0.0;0.0;0.3;2.5
1979;13;1.4;0.0;0.0;NA;NA;3.2;3.0;0.0;0.0;5.3;0.0;0.0
1979;14;0.0;0.0;NA;NA;NA;30.5;0.7;0.0;3.3;4.6;0.8;3.9
1979;15;0.0;13.5;NA;NA;NA;1.4;0.0;0.0;2.2;19.0;8.0;3.4
1979;16;0.5;1.5;NA;NA;NA;20.2;0.0;0.0;0.0;1.2;6.8;1.8
1979;17;0.5;5.5;NA;NA;NA;14.8;4.0;5.5;0.0;11.1;9.8;1.4
1979;18;0.0;3.5;NA;NA;NA;2.0;0.0;14.5;0.0;0.0;3.0;0.8
1979;19;0.0;0.0;NA;NA;NA;0.0;4.0;0.0;0.0;0.0;6.0;4.0
1979;20;0.0;0.0;NA;NA;NA;0.0;6.2;1.0;2.3;0.0;6.2;1.2
1979;21;0.0;0.0;NA;NA;NA;0.0;0.0;0.0;36.0;0.0;1.0;4.0
1979;22;0.0;0.0;NA;NA;NA;0.0;0.0;0.0;35.9;0.8;8.0;17.0
1979;23;2.3;0.0;NA;NA;NA;0.0;0.0;1.5;4.6;5.8;0.0;3.0
1979;24;0.0;0.0;NA;NA;NA;0.0;0.0;27.3;1.9;0.0;0.0;1.0
1979;25;0.5;0.0;NA;NA;NA;0.7;0.0;0.8;0.0;0.0;0.0;0.0
1979;26;4.0;0.0;NA;NA;0.0;2.0;0.0;2.1;0.0;0.0;0.0;0.0
1979;27;11.5;0.0;NA;NA;4.5;3.6;0.0;0.0;0.0;0.0;4.0;0.0
1979;28;3.0;2.0;NA;NA;0.0;1.1;1.0;0.5;0.0;3.6;0.0;0.0
1979;29;0.8;;NA;NA;0.0;0.0;5.0;0.0;0.0;0.6;0.0;0.0
1979;30;0.8;;NA;NA;0.0;0.0;5.4;0.0;0.0;1.8;0.0;0.0
1979;31;0.4;;NA;;1.7;;15.5;0.0;;0.4;;0.0
1980;1;NA;NA;NA;NA;NA;0.6;0.0;0.0;1.0;0.0;0.0;NA
1980;2;NA;NA;NA;NA;NA;0.5;0.0;0.0;0.0;1.5;0.0;NA
1980;3;NA;NA;NA;NA;NA;0.7;3.6;0.0;0.0;0.0;0.0;NA
1980;4;NA;NA;NA;NA;NA;17.2;0.0;6.5;0.0;0.0;2.2;NA
1980;5;NA;NA;NA;NA;NA;0.0;0.0;0.0;0.0;0.0;0.7;NA
1980;6;NA;NA;NA;NA;NA;0.5;0.0;0.0;6.4;0.0;NA;NA
1980;7;NA;NA;NA;NA;0.0;0.0;2.3;0.0;0.0;0.5;NA;NA
1980;8;NA;NA;NA;NA;2.3;2.3;2.8;10.5;0.0;10.5;NA;NA
1980;9;NA;NA;NA;NA;6.7;2.2;21.0;0.0;3.8;7.8;NA;NA
1980;10;NA;NA;NA;NA;0.9;2.7;3.5;0.0;2.2;2.3;NA;NA
1980;11;NA;NA;NA;NA;0.9;1.2;0.3;0.0;4.0;3.4;NA;NA
1980;12;NA;NA;NA;NA;0.0;0.0;0.0;5.0;0.0;1.5;NA;NA
1980;13;NA;NA;NA;NA;0.0;0.0;3.5;0.0;0.0;0.0;NA;NA
1980;14;NA;NA;NA;NA;8.3;0.0;0.0;0.0;0.0;0.0;NA;NA
1980;15;NA;NA;NA;NA;19.0;2.0;0.5;1.3;0.0;0.0;NA;NA
1980;16;NA;NA;NA;NA;2.3;0.5;0.0;6.7;0.0;6.5;NA;NA
1980;17;NA;NA;NA;NA;2.4;23.3;0.0;4.4;0.0;50.5;NA;NA
1980;18;NA;NA;NA;NA;0.5;1.2;0.0;0.0;0.0;6.5;NA;NA
1980;19;NA;NA;NA;NA;0.0;0.0;0.0;0.0;0.0;1.5;NA;NA
1980;20;NA;NA;NA;NA;0.0;0.5;9.5;2.2;0.0;0.0;NA;NA
1980;21;NA;NA;NA;NA;1.2;8.5;14.0;4.3;0.0;0.0;NA;NA
1980;22;NA;NA;NA;NA;0.4;11.0;0.0;0.5;0.0;0.0;NA;NA
1980;23;NA;NA;NA;NA;0.5;5.0;0.0;0.2;8.3;0.0;NA;NA
1980;24;NA;NA;NA;NA;0.2;5.5;0.0;0.0;0.0;2.0;NA;NA
1980;25;NA;NA;NA;NA;0.5;0.7;0.0;0.0;0.0;19.0;NA;NA
1980;26;NA;NA;NA;NA;0.0;0.3;0.0;0.0;0.0;0.5;NA;NA
1980;27;NA;NA;NA;NA;0.0;9.0;0.0;0.0;0.0;0.0;NA;NA
1980;28;NA;NA;NA;NA;2.1;0.0;0.0;2.1;0.0;0.0;NA;NA
1980;29;NA;NA;NA;NA;1.9;0.0;6.9;2.0;0.0;0.0;NA;NA
1980;30;NA;;NA;NA;0.9;0.0;1.6;2.8;0.0;0.0;NA;NA
1980;31;NA;;NA;;1.1;;0.0;2.2;;0.0;;NA'

# DF - read.csv2(myfile, as.is = TRUE)
DF - 

[R] make check reg-tests-1.R error on solaris

2009-02-25 Thread Karen Noel
R 2.5.1 compiled, passed the make check and has been successfully running
for a couple years on a Sun Fire V490 running Solaris 9. I need a newer
version of R, but can't get a newer version of R to pass the make check.
I've tried 2.8.1, 2.7.2, 2.6.2 and 2.6.0. (2.5.1 still passes on this
server) At this point I thought I'd try to compile it on another Sun server
(Solaris 10), but it had the same problem. Configuring with no options
didn't help. I commented out the failed test from the Makefile to see if it
would pass the rest of the tests. It passes all the rest of the tests. Here
is the failure error from make check.

make[2]: Entering directory `/usr/local/src/R-2.8.1/tests'
running regression tests
make[3]: Entering directory `/usr/local/src/R-2.8.1/tests'
running code in 'reg-tests-1.R' ...make[3]: *** [reg-tests-1.Rout] Error 1
make[3]: Leaving directory `/usr/local/src/R-2.8.1/tests'
make[2]: *** [test-Reg] Error 2
make[2]: Leaving directory `/usr/local/src/R-2.8.1/tests'
make[1]: *** [test-all-basics] Error 1
make[1]: Leaving directory `/usr/local/src/R-2.8.1/tests'
make: *** [check] Error 2
bash-2.05#

Here is output from reg-tests-1.Rout.fail.

[1] 41c6167e dir1 dir2 dirs
file275c23f2
[6] file33f963f2 moredirs
 file.create(file.path(dd, somefile))
[1] TRUE TRUE TRUE TRUE
 dir(., recursive=TRUE)
[1] 41c6167e  dir1/somefile dir2/somefile
[4] dirs/somefile file275c23f2  file33f963f2
[7] moredirs/somefile
 stopifnot(unlink(dir?) == 1) # not an error
Error: unlink(dir?) == 1 is not TRUE
Execution halted
rm: Cannot remove any directory in the path of the current working directory
/tmp/RtmprBjF6W

Looking through the archives I did find a couple other people with this
error, both running Solaris 10. PR#10501 and PR#11738 have quite a lot of
information about this error, but I don't see any resolution for them.

This looks like it could possibly be enough of a problem that I haven't put
2.8.1 in production. Can you help me with a resolution or let me know if it
is safe to ignore? I'd appreciate it.

Thank you!
Karen

[[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, joint scaling test, quantitative genetic analysis sensitivity to model violations

2009-02-25 Thread Maureen Ryan
Hi all,This is really a stats question as much as an R question.  I'm
trying to do a joint scaling test (JST - see below) on some very
oddly-distributed data and was wondering if anyone can suggest a good way of
dealing with model violations and/or using R to evaluate how sensitive the
model is to violations of the normality assumption.

Here's a quick explanation of the analysis, the goal of which is to describe
variation in phenotype z (time to metamorphosis, for example) between a
series of hybrid crosses between two parental species.  i used a mixed
effects framework to fit a standard quantitative genetic model:

z(i) = mu(0) + b(S)S(i) + b(H)H(i) + b(SS)S^2(i) + b(HH)H^2(i) +
b(SH)S(i)H(i) + block +error

where S(i) is the ancestry index (proportional to the expected fraction of
parent 2 alleles in individual i based on its cross type), H(i) is the
heterozygosity index (proportional to the expected fraction of loci with one
allele from parent 1 and one allele from parent 2), b(i) are the regression
coefficients and mu(0) is the mean phenotype of the F2 generation of hybrids
(reference generation). Non-genetic components of variation are partitioned
into individual (error) and block terms. Regression coefficients represent
additive (b(S)), dominance (b(H)) and epistatic (b(SS), b(HH), b(SH))
effects of genetic differences between parental lineages. I fit a series,
starting with the additive effect only and adding dominance and epistatic
effects up to the full model and use AIC to choose the best model.

The problem I'm facing is that there is a great deal of heterogeneity in the
distributions of hybrid cross type (6 types total). the full model does well
in modeling means (which are actually similar across distributions), but
can't capture the heterogeneity of distributions if i assume a consistent
error function.  Any suggestions on ways of dealing with this problem, or at
least ways of evaluating model sensitivity to these kinds of violations
would be very welcome.

thanks, mo

[[alternative HTML version deleted]]

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


  1   2   >