Re: [R] Potential minor GUI bug

2005-06-17 Thread Francisco J. Zagmutt

Dear Any

Thanks for your response.  Maybe I did not explain the behavior well.  I am 
aware that the Not Responding is a windows default.  What I was trying to 
explain is that once the process that generated the Not Responding is 
finished and I can use R for othe computations the Not Responding caption 
will remain in the task bar icon but not in the caption on the main Gui 
form.  Please see the attached screen caption for an example.


Regards

Francisco




From: Liaw, Andy [EMAIL PROTECTED]
To: 'Francisco J. Zagmutt' 
[EMAIL PROTECTED],R-help@stat.math.ethz.ch

Subject: RE: [R] Potential minor GUI bug
Date: Thu, 16 Jun 2005 17:26:03 -0400

I don't think that's a bug.  Almost every Windows application can do that:
when it's busy with computation, you'll see the not responding message.

Andy

 From: Francisco J. Zagmutt

 Is this an interface bug?  Using RGUI for windows I run into a Not
 Responding process (I smartly coded an infinite loop,
 yaiks!), I hit esc
 and the interpreter was stopped and I recovered the console
 functionality
 but the caption on the R icon in my windows taskbar (the
 individual icon
 shown for every software currently running in the session)
 was not updated
 so the caption still reads RGui (Not Responding). This behavior is
 repeated everytime I run into a Not responding process.
 Off course if I
 end the session and open a new session the icon caption goes
 back to the
 normal RGui.

 I am running R2.1.0 on Windows XP Pro V. 2002 SP2, Pentium M,
 1.00 Gb Ram.

 Cheers

 Francisco

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






--
Notice:  This e-mail message, together with any attachments, contains 
information of Merck  Co., Inc. (One Merck Drive, Whitehouse Station, New 
Jersey, USA 08889), and/or its affiliates (which may be known outside the 
United States as Merck Frosst, Merck Sharp  Dohme or MSD and in Japan, as 
Banyu) that may be confidential, proprietary copyrighted and/or legally 
privileged. It is intended solely for the use of the individual or entity 
named on this message.  If you are not the intended recipient, and have 
received this message in error, please notify us immediately by reply 
e-mail and then delete it from your system.

--


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

Re: [R] Potential minor GUI bug

2005-06-17 Thread Liaw, Andy
Now I understand.  I get the same thing in SDI mode (R-2.1.0 on WinXPPro).
No idea why...

Andy

 From: Francisco J. Zagmutt 
 
 Dear Any
 
 Thanks for your response.  Maybe I did not explain the 
 behavior well.  I am 
 aware that the Not Responding is a windows default.  What I 
 was trying to 
 explain is that once the process that generated the Not Responding is 
 finished and I can use R for othe computations the Not 
 Responding caption 
 will remain in the task bar icon but not in the caption on 
 the main Gui 
 form.  Please see the attached screen caption for an example.
 
 Regards
 
 Francisco
 
 
 
 From: Liaw, Andy [EMAIL PROTECTED]
 To: 'Francisco J. Zagmutt' 
 [EMAIL PROTECTED],R-help@stat.math.ethz.ch
 Subject: RE: [R] Potential minor GUI bug
 Date: Thu, 16 Jun 2005 17:26:03 -0400
 
 I don't think that's a bug.  Almost every Windows 
 application can do that:
 when it's busy with computation, you'll see the not 
 responding message.
 
 Andy
 
   From: Francisco J. Zagmutt
  
   Is this an interface bug?  Using RGUI for windows I run 
 into a Not
   Responding process (I smartly coded an infinite loop,
   yaiks!), I hit esc
   and the interpreter was stopped and I recovered the console
   functionality
   but the caption on the R icon in my windows taskbar (the
   individual icon
   shown for every software currently running in the session)
   was not updated
   so the caption still reads RGui (Not Responding). This 
 behavior is
   repeated everytime I run into a Not responding process.
   Off course if I
   end the session and open a new session the icon caption goes
   back to the
   normal RGui.
  
   I am running R2.1.0 on Windows XP Pro V. 2002 SP2, Pentium M,
   1.00 Gb Ram.
  
   Cheers
  
   Francisco
  
   __
   R-help@stat.math.ethz.ch mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide!
   http://www.R-project.org/posting-guide.html
  
  
  
 
 
 
 -
 -
 Notice:  This e-mail message, together with any attachments, 
 contains 
 information of Merck  Co., Inc. (One Merck Drive, 
 Whitehouse Station, New 
 Jersey, USA 08889), and/or its affiliates (which may be 
 known outside the 
 United States as Merck Frosst, Merck Sharp  Dohme or MSD 
 and in Japan, as 
 Banyu) that may be confidential, proprietary copyrighted 
 and/or legally 
 privileged. It is intended solely for the use of the 
 individual or entity 
 named on this message.  If you are not the intended 
 recipient, and have 
 received this message in error, please notify us immediately 
 by reply 
 e-mail and then delete it from your system.
 -
 -
 


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


[R] CORRELATION MATRIX CONVERSION

2005-06-17 Thread Omer Bakkalbasi
How do I convert the output of cor(x) to a columnar format? 
Ex. from format below
XYZ
X  1.0  0.9  0.5
Y  0.9  1.0  0.1
Z  0.5  0.1  1.0

to format below

X X 1.0
X Y 0.9
X Z 0.5
Y X 0.9
Y Y 1.0
Y Z 0.1
Z X 0.5
Z Y 0.1
Z Z 1.0

Thanks!

Omer

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


Re: [R] Potential minor GUI bug

2005-06-17 Thread Uwe Ligges
Liaw, Andy wrote:

 Now I understand.  I get the same thing in SDI mode (R-2.1.0 on WinXPPro).
 No idea why...

I guess this is a Windows bug, because I have seen it in other 
applications as well. Hence I don't think we should waste our time here ...

Uwe Ligges



 
 Andy
 
 
From: Francisco J. Zagmutt 

Dear Any

Thanks for your response.  Maybe I did not explain the 
behavior well.  I am 
aware that the Not Responding is a windows default.  What I 
was trying to 
explain is that once the process that generated the Not Responding is 
finished and I can use R for othe computations the Not 
Responding caption 
will remain in the task bar icon but not in the caption on 
the main Gui 
form.  Please see the attached screen caption for an example.

Regards

Francisco




From: Liaw, Andy [EMAIL PROTECTED]
To: 'Francisco J. Zagmutt' 
[EMAIL PROTECTED],R-help@stat.math.ethz.ch
Subject: RE: [R] Potential minor GUI bug
Date: Thu, 16 Jun 2005 17:26:03 -0400

I don't think that's a bug.  Almost every Windows 

application can do that:

when it's busy with computation, you'll see the not 

responding message.

Andy


From: Francisco J. Zagmutt

Is this an interface bug?  Using RGUI for windows I run 

into a Not

Responding process (I smartly coded an infinite loop,
yaiks!), I hit esc
and the interpreter was stopped and I recovered the console
functionality
but the caption on the R icon in my windows taskbar (the
individual icon
shown for every software currently running in the session)
was not updated
so the caption still reads RGui (Not Responding). This 

behavior is

repeated everytime I run into a Not responding process.
Off course if I
end the session and open a new session the icon caption goes
back to the
normal RGui.

I am running R2.1.0 on Windows XP Pro V. 2002 SP2, Pentium M,
1.00 Gb Ram.

Cheers

Francisco

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






-

-

Notice:  This e-mail message, together with any attachments, 

contains 

information of Merck  Co., Inc. (One Merck Drive, 

Whitehouse Station, New 

Jersey, USA 08889), and/or its affiliates (which may be 

known outside the 

United States as Merck Frosst, Merck Sharp  Dohme or MSD 

and in Japan, as 

Banyu) that may be confidential, proprietary copyrighted 

and/or legally 

privileged. It is intended solely for the use of the 

individual or entity 

named on this message.  If you are not the intended 

recipient, and have 

received this message in error, please notify us immediately 

by reply 

e-mail and then delete it from your system.
-

-


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

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


Re: [R] CORRELATION MATRIX CONVERSION

2005-06-17 Thread Uwe Ligges
Omer Bakkalbasi wrote:

 How do I convert the output of cor(x) to a columnar format? 
 Ex. from format below
 XYZ
 X  1.0  0.9  0.5
 Y  0.9  1.0  0.1
 Z  0.5  0.1  1.0
 
 to format below
 
 X X 1.0
 X Y 0.9
 X Z 0.5
 Y X 0.9
 Y Y 1.0
 Y Z 0.1
 Z X 0.5
 Z Y 0.1
 Z Z 1.0


See, e.g., ?reshape

Uwe Ligges


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

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


Re: [R] Potential minor GUI bug

2005-06-17 Thread Francisco J. Zagmutt
Dear Uwe

I have not seen this behavior in other windows applications but I 
definitivelly agree with you that it is probably not worth spending time on 
this trivial issue.

Thanks

Francisco


From: Uwe Ligges [EMAIL PROTECTED]
To: Liaw, Andy [EMAIL PROTECTED]
CC: 'Francisco J. Zagmutt' 
[EMAIL PROTECTED],R-help@stat.math.ethz.ch
Subject: Re: [R] Potential minor GUI bug
Date: Fri, 17 Jun 2005 08:21:05 +0200

Liaw, Andy wrote:

Now I understand.  I get the same thing in SDI mode (R-2.1.0 on WinXPPro).
No idea why...

I guess this is a Windows bug, because I have seen it in other applications 
as well. Hence I don't think we should waste our time here ...

Uwe Ligges




Andy


From: Francisco J. Zagmutt

Dear Any

Thanks for your response.  Maybe I did not explain the behavior well.  I 
am aware that the Not Responding is a windows default.  What I was 
trying to explain is that once the process that generated the Not 
Responding is finished and I can use R for othe computations the Not 
Responding caption will remain in the task bar icon but not in the 
caption on the main Gui form.  Please see the attached screen caption for 
an example.

Regards

Francisco




From: Liaw, Andy [EMAIL PROTECTED]
To: 'Francisco J. Zagmutt' 
[EMAIL PROTECTED],R-help@stat.math.ethz.ch
Subject: RE: [R] Potential minor GUI bug
Date: Thu, 16 Jun 2005 17:26:03 -0400

I don't think that's a bug.  Almost every Windows

application can do that:

when it's busy with computation, you'll see the not

responding message.

Andy


From: Francisco J. Zagmutt

Is this an interface bug?  Using RGUI for windows I run

into a Not

Responding process (I smartly coded an infinite loop,
yaiks!), I hit esc
and the interpreter was stopped and I recovered the console
functionality
but the caption on the R icon in my windows taskbar (the
individual icon
shown for every software currently running in the session)
was not updated
so the caption still reads RGui (Not Responding). This

behavior is

repeated everytime I run into a Not responding process.
Off course if I
end the session and open a new session the icon caption goes
back to the
normal RGui.

I am running R2.1.0 on Windows XP Pro V. 2002 SP2, Pentium M,
1.00 Gb Ram.

Cheers

Francisco

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






-

-

Notice:  This e-mail message, together with any attachments,

contains

information of Merck  Co., Inc. (One Merck Drive,

Whitehouse Station, New

Jersey, USA 08889), and/or its affiliates (which may be

known outside the

United States as Merck Frosst, Merck Sharp  Dohme or MSD

and in Japan, as

Banyu) that may be confidential, proprietary copyrighted

and/or legally

privileged. It is intended solely for the use of the

individual or entity

named on this message.  If you are not the intended

recipient, and have

received this message in error, please notify us immediately

by reply

e-mail and then delete it from your system.
-

-




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


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


Re: [R] Potential minor GUI bug

2005-06-17 Thread Prof Brian Ripley
Yes, it is a Windows bug: the frame is controlled by Windows and not by R.

On Fri, 17 Jun 2005, Uwe Ligges wrote:

 Liaw, Andy wrote:

 Now I understand.  I get the same thing in SDI mode (R-2.1.0 on WinXPPro).
 No idea why...

 I guess this is a Windows bug, because I have seen it in other
 applications as well. Hence I don't think we should waste our time here ...

 Uwe Ligges




 Andy


 From: Francisco J. Zagmutt

 Dear Any

 Thanks for your response.  Maybe I did not explain the
 behavior well.  I am
 aware that the Not Responding is a windows default.  What I
 was trying to
 explain is that once the process that generated the Not Responding is
 finished and I can use R for othe computations the Not
 Responding caption
 will remain in the task bar icon but not in the caption on
 the main Gui
 form.  Please see the attached screen caption for an example.

 Regards

 Francisco




 From: Liaw, Andy [EMAIL PROTECTED]
 To: 'Francisco J. Zagmutt'
 [EMAIL PROTECTED],R-help@stat.math.ethz.ch
 Subject: RE: [R] Potential minor GUI bug
 Date: Thu, 16 Jun 2005 17:26:03 -0400

 I don't think that's a bug.  Almost every Windows

 application can do that:

 when it's busy with computation, you'll see the not

 responding message.

 Andy


 From: Francisco J. Zagmutt

 Is this an interface bug?  Using RGUI for windows I run

 into a Not

 Responding process (I smartly coded an infinite loop,
 yaiks!), I hit esc
 and the interpreter was stopped and I recovered the console
 functionality
 but the caption on the R icon in my windows taskbar (the
 individual icon
 shown for every software currently running in the session)
 was not updated
 so the caption still reads RGui (Not Responding). This

 behavior is

 repeated everytime I run into a Not responding process.
 Off course if I
 end the session and open a new session the icon caption goes
 back to the
 normal RGui.

 I am running R2.1.0 on Windows XP Pro V. 2002 SP2, Pentium M,
 1.00 Gb Ram.

 Cheers

 Francisco

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






 -

 -

 Notice:  This e-mail message, together with any attachments,

 contains

 information of Merck  Co., Inc. (One Merck Drive,

 Whitehouse Station, New

 Jersey, USA 08889), and/or its affiliates (which may be

 known outside the

 United States as Merck Frosst, Merck Sharp  Dohme or MSD

 and in Japan, as

 Banyu) that may be confidential, proprietary copyrighted

 and/or legally

 privileged. It is intended solely for the use of the

 individual or entity

 named on this message.  If you are not the intended

 recipient, and have

 received this message in error, please notify us immediately

 by reply

 e-mail and then delete it from your system.
 -

 -




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

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


-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] lm and time series: simple question

2005-06-17 Thread Prof Brian Ripley
On Thu, 16 Jun 2005 [EMAIL PROTECTED] wrote:

 This question is partly about R and partly out of my ignorance about 
 time series.

 I want to regress one time series on another, taking into account the
 autocorrelation (in an AR1 model) within each series.  I am interested in how
 the standard error changes when the acf is taken into account.

This does not happen with least-squares fitting as done by lm. You can use 
arima or gls (in package nlme).  Note that both assume a model for the 
residuals, not for the series themselves.

You could also make a joint model of the two time series.  That is 
probably not what you want.

 I've made both of my datasets into ts objects and used the basic lm 
 function (with na.action=NULL) to no effect (i.e. the resulting standard 
 error is the same as if they were not times series).  I've also looked 
 at binding the two series together with ts.union or ts.intersect, but 
 then I am left with a single object, and don't understand how to regress 
 one of the components of this onto the other.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] possible bug in merge with duplicate blank names in 'by' field.

2005-06-17 Thread Prof Brian Ripley
What version of R is this (please do see the posting guide)?

In both 2.1.0 and 2.1.1 beta I get

 all
   Promoter ip.x ip.y ip
130   40 40
240   40 40
3a   10   NA NA
4c   20   20 20
5b   NA   15 15
6d   NA   30 30

so cannot reproduce your result. Are you sure that the `blanks' really are 
empty and not some character that is printing as empty on your unstated 
OS?

BTW ' ' is what is normally called `blank'.

BTW, these are not `names' but character strings: `names' has other 
meanings in R.

On Thu, 16 Jun 2005, Frank Gibbons wrote:

 Run this:

 p - c('a', 'c', '', ''); a - c(10, 20, 30, 40); d1 -
 data.frame(Promoter=p, ip=a) # Note duplicate empty names in p.
 p - c('b', 'c', 'd', ''); a - c(15, 20, 30, 40); d2 -
 data.frame(Promoter=p, ip=a)
 all - merge(x=d1, y=d2, by=Promoter, all=T)
 all - merge(x=all, y=d2, by=Promoter, all=T)
 all

 Data is this:

 d1
   Promoter ip
 1a 10
 2c 20
 3  30
 4  40

 d2
   Promoter ip
 1b 15
 2c 20
 3d 30
 4  40

 Output looks like this:

   Promoter ip.x ip.y ip
 140   30 30
 240   40 30
 340   30 40
 440   40 40
 5b   15   NA NA
 6c   20   20 20
 7d   30   NA NA
 8a   NA   10 10

 The weird thing about this is (in my view) that each instance of '' is
 considered unique, so with each successive merge, all combinatorial
 possibilities are explored, like a SQL outer join (Cartesian product). For
 non-empty names, an inner join is performed.

 Dealing with genomic data (10^4 datapoints), it's easy to have a couple of
 blanks buried in the middle of things, and to combine several replicates
 with successive merges. I couldn't understand how my three replicates of
 6000 points, in which I expected  substantial overlap in the labels, were
 taking so long to merge and ultimately generating 57000 labels. The culprit
 turned out to be a few hundred blanks buried in the middle.

 Why does the empty (null) name merit special treatment? Perhaps I'm
 missing something. I hesitate to submit this as a bug, since technically I
 guess you could say that blank names, especially duplicates, are not
 kosher. But on the other hand, this combinatorial behaviour seems to occur
 only for blanks.

 -Frank

 PhD, Computational Biologist,
 Harvard Medical School BCMP/SGM-322, 250 Longwood Ave, Boston MA 02115, USA.
 Tel: 617-432-3555   Fax:
 617-432-3557   http://llama.med.harvard.edu/~fgibbons

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


-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] Analysing ordinal/nominal data

2005-06-17 Thread Prof Brian Ripley
On Thu, 16 Jun 2005, Piotr Majdak wrote:

 I'm looking for a solution to analyse data, which consists of
 dichotomous  responses (yes/no) for 2 multinomial ordinal variables.

Please explain how you get a binary response for a `multinomial ordinal 
variables'?  If you intend these variables to be explanatory variables, in 
what sense are they `multinomial'?

 I was trying glm() and got hierarhical models treating all variables as 
 nominal, but I can't figure out how to tell glm() to use a model for 
 ordinal data like this:

 log(Mij) = intercept + X + Y + Z + beta*(x-x')*(y-y')

 where beta is a regression factor for interaction between X and Y.

What are Mij, X, x, x', Y, y, y' and Z?  One normally fits a logistic 
regression to a binary response.

 Do you know a trick to code it in R or point me to some documentation?

Probably no `trick' is required, but we need to start from a complete and 
accurate description of the model you want to fit.

This could be a simple as

R2-level factor
U, V ordered factors

glm(R ~ U + V + as.numeric(U)*as.numeric(V), family = binomial)

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] regressing each column of a matrix on all other columns

2005-06-17 Thread Prof Brian Ripley
apply() is just a for() loop internally so why do you expect it to be 
faster?

Some comments:

1) Here predict() is just extracting the fitted values.
2) Using lm.fit will be faster if fitted values is all you want.
3) You are actually regressing each column on all other columns plus an
intercept.
4) The as.matrix is wasteful.

So it would be faster to use

A1 - cbind(1, A)
for (i in 2:ncol(A)) B[,i-1] - lm.fit(A1[,-i], A1[,i])$fitted

You can do this reasonably efficiently in matrix algebra: one way is to 
form the inverse of X^TX after removing column means and use the Goodnight 
sweep operation on each column in turn.

On Thu, 16 Jun 2005, Stefan Mischke wrote:

 DeaR list

 I would like to predict the values of each column of a matrix A by
 regressing it on all other columns of the same matrix A. I do this with
 a for loop:

   A - B - matrix(round(runif(10*3,1,10),0),10)
   A
   for (i in 1:length(A[1,]))B[,i] - as.matrix(predict(lm( A[,i] ~
 A[,-i] )))
   B

 It works fine, but I need it to be faster. I've looked at *apply but
 just can't seem to figure it out.
 Maybe the solution could look somewhat like this:

   mylm - function(y,ci) {
   x - A[,-ci]
   b - lm(y~x)
   }
   B - apply(A,2,mylm,ci=current_column_index(A))

 Is there a way to pass the index of the current column in apply to my
 function? Am I on the right path at all?
 Thanks for your help.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] Computing generalized eigenvalues

2005-06-17 Thread Prof Brian Ripley
On Thu, 16 Jun 2005, Joshua Gilbert wrote:

 I need to compute generalized eigenvalues. The eigen function in base
 doesn't do it and I can't find a package that does.

They are very rarely used in statistics, so this is not surprising.

I presume you mean solving Ax = lambda B x: if B is non-singular this 
reduces to a conventional eigenproblem for B^{-1}A.

 As I understand it, Lapack __can__ computer them
 (http://www.netlib.org/lapack/lawn41/node111.html) and R can use
 Lapack. If there is no function already, can I access Lapack from R
 and use those routines directly?

Yes, you can: for real matrices the requisite routines are already 
compiled into R.  See DGGES or DGGEV.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] Plotting second axes outside xyplot

2005-06-17 Thread Andrew Robinson
Paul,

thanks!  An elegant solution.  
Andrew

--
Andrew Robinson  Ph: 208 885 7115
Department of Forest Resources   Fa: 208 885 6226
University of Idaho  E : [EMAIL PROTECTED]
PO Box 441133W : http://www.uidaho.edu/~andrewr
Moscow ID 83843  Or: http://www.biometrics.uidaho.edu
No statement above necessarily represents my employer's opinion.



- Original Message -
From: Paul Murrell [EMAIL PROTECTED]
Date: Thursday, June 16, 2005 7:07 pm
Subject: Re: [R] Plotting second axes outside xyplot

 Hi
 
 
 Andrew Robinson wrote:
  Hi all,
  
  I'm trying to find a way to get xyplot to produce a second set 
 of axes outside the right hand side of the graph.  This is my 
 progress so far:
  
  EE - equal.count(ethanol$E, number=9, overlap=1/4)
  xyplot(NOx ~ C | EE, data = ethanol,
 prepanel = function(x, y) prepanel.loess(x, y, span = 1),
 xlab = Compression Ratio, ylab = NOx (micrograms/J),
 panel = function(x, y) {
  panel.grid(h=-1, v= 2)
  panel.xyplot(x, y)
  panel.loess(x,y, span=1)
  panel.axis(side = right, at = c(1, 3),
labels = c(1, 3), outside = T)
  },
  aspect = xy)
  
  Does anyone have any suggestions?
 
 
 I suspect the output from panel.axis() is getting clipped.  You 
 might 
 get it to work as follows ...
 
 EE - equal.count(ethanol$E, number=9, overlap=1/4)
 xyplot(NOx ~ C | EE, data = ethanol,
prepanel = function(x, y) {
  prepanel.loess(x, y, span = 1)
},
xlab = Compression Ratio,
ylab = NOx (micrograms/J),
panel = function(x, y) {
  panel.grid(h=-1, v= 2)
  panel.xyplot(x, y)
  panel.loess(x,y, span=1)
  # don't call panel.axis in here
},
aspect = xy)
 # return to the right-most panel WITH CLIPPING OFF
 trellis.focus(panel, 9, 1, clip.off=TRUE)
 # draw the extra axis
 panel.axis(side = right, at = c(1, 3),
labels = c(1, 3), outside = T)
 trellis.unfocus()
 
 
 Paul
 -- 
 Dr Paul Murrell
 Department of Statistics
 The University of Auckland
 Private Bag 92019
 Auckland
 New Zealand
 64 9 3737599 x85392
 [EMAIL PROTECTED]
 http://www.stat.auckland.ac.nz/~paul/
 


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


[R] glmmADMB: Mixed models for overdispersed and zero-inflated count data in R

2005-06-17 Thread Hans Skaug
Dear R-users,

Earlier this year I posted a message to this list regarding
negative binomial mixed models in R.  It was suggested that
the program I had written should be turned into an R-package.
This has now been done, in collaboration with David Fournier
and Anders Nielsen.

The R-package glmmADMB provides the following GLMM framework:
- Negative binomial or Poisson responses.
- Zero-inflation (optionally), e.g. a mixture of a Poisson or
 negative binomial distribution and a point mass at zero.

The computational method is based on the Laplace approximation
for integrating out the random effects, together with the
option of employing importance sampling at the posterior mode
of the random effects to permit arbitrarily close approximation
to the exact MLE. (However for these models differences appear to be
very small.)

Some of the generic convenience functions, such as
predict(), fitted.values(), ...  are still missing from
this package, but will hopefully be added in later
versions (contributions/suggestions are most welcome).
Other response distributions than negative binomial or
Poisson could easily be added.

Download site:

http://otter-rsch.com/admbre/examples/glmmadmb/glmmADMB.html

The package is based on the software ADMB-RE, but the full
unrestricted R-package is made freely available by Otter Research Ltd
and does not require ADMB-RE to run with user supplied data.

I you will find this useful,

Hans Skaug

-- 
Hans  Skaug

Department of Mathematics
University of Bergen, Norway
email:  [EMAIL PROTECTED]
ph. (+47) 55 58 48 61

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


[R] About simulations

2005-06-17 Thread Caroline TRUNTZER
Hello
I would like to generate covariance matrix with autoregressive
structure. I saw some functions in nlme such as corAR1 for example but I
don't know how to use it for my goal. Could someone help me or advise me
another function?
Thank you in advance
Caroline

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


[R] axis labels vertically

2005-06-17 Thread BoM DS
Hi,

I have a plot and a custom axis labeling, e.g.

  x-c(...) 
  plot(x,axes=FALSE)
  axis(2)
  axis(1,1:50,c(label1,...,label50))

now since the labels are quite long, only a few fit on the page.
Can I rotate each label by 90 degree counterclockwise 
(so that they are vertical)

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


Re: [R] About simulations

2005-06-17 Thread Prof Brian Ripley
ARMAacf() will give you the acf for an autoregression, and toeplitz()
wil turn this into a correlation matrix.  Then just multiply by the 
desired variance.

I am not sure what this has to do with your subject line, and ?arima.sim 
might be helpful for that.

On Fri, 17 Jun 2005, Caroline TRUNTZER wrote:

 Hello
 I would like to generate covariance matrix with autoregressive
 structure. I saw some functions in nlme such as corAR1 for example but I
 don't know how to use it for my goal. Could someone help me or advise me
 another function?
 Thank you in advance
 Caroline

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] Analysing ordinal/nominal data

2005-06-17 Thread Piotr Majdak
Prof Brian Ripley wrote:

 On Thu, 16 Jun 2005, Piotr Majdak wrote:
 
 I'm looking for a solution to analyse data, which consists of
 dichotomous  responses (yes/no) for 2 multinomial ordinal variables.
 
 
 Please explain how you get a binary response for a `multinomial ordinal 
 variables'?  If you intend these variables to be explanatory variables, 
 in what sense are they `multinomial'?

My data are results from a pychoacoustical experiment:
- Response: 2 levels, frequencies for yes/no
- PR: factor, independent variable, 4 levels, ordinal
- ENV: factor, independent variable, 3 levels, ordinal

The hypothesis is that:
- PR is independent of ENV, given Response
- Response and ENV are conditionally dependent, given PR
- Response and PR are conditionally dependent, given ENV

The model:

fit=glm(count ~ PR+ENV+Response + PR:Response + ENV:Response, 
data=table, family=poisson)

fits with p=0.04 only. My explanations are:
- I have a three-way interaction
- I must consider the ordinal information of PR and ENV

 One normally fits a logistic 
 regression to a binary response.
 Probably no `trick' is required, but we need to start from a complete 
 and accurate description of the model you want to fit.

I don't know how to include the interaction to the logit model.
I think the log-linear row effects model for the 3-dim. nominal-ordinal 
table (Agresti 1984, p.89) would be the right one, but please correct me 
if I'm on a wrong way:

log mijk = intercept + lambda^X_i + lambda^Y_j + lambda^Z_k +
tau^XY_i*(v_j-v') + tau^XZ_i*(w_k-w') +
   beta^YZ*(v_j-v')*(w_k-w')

mijk: expected frequencies for cell with indicies i,j,k
v_j: scores of Y with {v_1  v_2  ..  v_j}
w_k: scores of Z with {w_1  w_2  ..  w_k}
lambda^X_i, lambda^Y_j, lambda^Z_k: estimated parameters for X, Y and Z
tau^XY_i, tau^XZ_j: association parameters for XY and XZ
beta^YZ: association parameter for ordinal factors Y and Z

In my case, X==Response, Y==PR and Z==ENV. I presume no interaction 
between Y and Z and would like to test beta. My idea is: if beta is 
significant, this model won't hold, the saturated model fits only and I 
must calculate odds ratios and beta's from partial tables. But: how can 
I tell glm() to use something like beta*PR*ENVm in the formula? And, am 
I on the right way?

Thanks a lot for your response.

Piotr Majdak


Agresti 1984: Analysis of ordinal categorical data. John Wiley  Sons Inc.


-- 

Piotr Majdak
Acoustics Research Institute
Austrian Academy of Sciences
Reichsratsstr. 17
A-1010 Vienna
AUSTRIA
phone: +43-1-4277-29511
fax: +43-1-4277-9296
email: [EMAIL PROTECTED]
WWW: http://www.kfs.oeaw.ac.at

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


Re: [R] Computing generalized eigenvalues

2005-06-17 Thread Peter Dalgaard
Prof Brian Ripley [EMAIL PROTECTED] writes:

 On Thu, 16 Jun 2005, Joshua Gilbert wrote:
 
  I need to compute generalized eigenvalues. The eigen function in base
  doesn't do it and I can't find a package that does.
 
 They are very rarely used in statistics, so this is not surprising.

An aside, going a bit off-topic:

However, there's the related  generalized singular value decomposition:

 K = U Sigma inv(T) 
 L = V M inv(T)

U'U = V'V = I ;  Sigma and M diagonal (Sigma^2 + M^2 = I by
convention) ; T regular

(Look at K'K and L'L to see the connection.)

This is used in Tikhonov regularization, which is penalized least
squares, which is a statistical issue (whether numerical analysts
realize it or not). Smoothing splines is a special case. Deconvolution
is another. 

 
 I presume you mean solving Ax = lambda B x: if B is non-singular this 
 reduces to a conventional eigenproblem for B^{-1}A.

(There are some complications if both A and B are singular. That's
why the GSVD has that peculiar-looking convention.) 

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

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


Re: [R] Analysing ordinal/nominal data

2005-06-17 Thread Prof Brian Ripley
As I suggested before, a binomial logistic model is appropriate here, not 
a Poisson log-linear one.  (They are equivalent, but the binomial version 
is easier to interpret and less wasteful to fit.)

You have still not defined v' and w', nor the scores (are they estimated 
or not).  But the model I suggested is such a model with scores 1,2,...

On Fri, 17 Jun 2005, Piotr Majdak wrote:

 Prof Brian Ripley wrote:

 On Thu, 16 Jun 2005, Piotr Majdak wrote:
 
 I'm looking for a solution to analyse data, which consists of
 dichotomous  responses (yes/no) for 2 multinomial ordinal variables.
 
 
 Please explain how you get a binary response for a `multinomial ordinal 
 variables'?  If you intend these variables to be explanatory variables, in 
 what sense are they `multinomial'?

 My data are results from a pychoacoustical experiment:
 - Response: 2 levels, frequencies for yes/no
 - PR: factor, independent variable, 4 levels, ordinal
 - ENV: factor, independent variable, 3 levels, ordinal

 The hypothesis is that:
 - PR is independent of ENV, given Response
 - Response and ENV are conditionally dependent, given PR
 - Response and PR are conditionally dependent, given ENV

 The model:

 fit=glm(count ~ PR+ENV+Response + PR:Response + ENV:Response, data=table, 
 family=poisson)

 fits with p=0.04 only. My explanations are:
 - I have a three-way interaction
 - I must consider the ordinal information of PR and ENV

 One normally fits a logistic regression to a binary response.
 Probably no `trick' is required, but we need to start from a complete and 
 accurate description of the model you want to fit.

 I don't know how to include the interaction to the logit model.
 I think the log-linear row effects model for the 3-dim. nominal-ordinal table 
 (Agresti 1984, p.89) would be the right one, but please correct me if I'm on 
 a wrong way:

 log mijk = intercept + lambda^X_i + lambda^Y_j + lambda^Z_k +
   tau^XY_i*(v_j-v') + tau^XZ_i*(w_k-w') +
  beta^YZ*(v_j-v')*(w_k-w')

 mijk: expected frequencies for cell with indicies i,j,k
 v_j: scores of Y with {v_1  v_2  ..  v_j}
 w_k: scores of Z with {w_1  w_2  ..  w_k}
 lambda^X_i, lambda^Y_j, lambda^Z_k: estimated parameters for X, Y and Z
 tau^XY_i, tau^XZ_j: association parameters for XY and XZ
 beta^YZ: association parameter for ordinal factors Y and Z

 In my case, X==Response, Y==PR and Z==ENV. I presume no interaction between Y 
 and Z and would like to test beta. My idea is: if beta is significant, this 
 model won't hold, the saturated model fits only and I must calculate odds 
 ratios and beta's from partial tables. But: how can I tell glm() to use 
 something like beta*PR*ENVm in the formula? And, am I on the right way?

 Thanks a lot for your response.

 Piotr Majdak


 Agresti 1984: Analysis of ordinal categorical data. John Wiley  Sons Inc.


 -- 

 Piotr Majdak
 Acoustics Research Institute
 Austrian Academy of Sciences
 Reichsratsstr. 17
 A-1010 Vienna
 AUSTRIA
 phone: +43-1-4277-29511
 fax: +43-1-4277-9296
 email: [EMAIL PROTECTED]
 WWW: http://www.kfs.oeaw.ac.at



-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


[R] Mixed model question

2005-06-17 Thread Alfonso M Sanchez-Lafuente
Hi,

I am new to this list as a poster, but a reader for some time.

I've using R for several weeks now, and I have a lot of questions about 
certain procedures. Here I go:

I want to test if there are differences in the time spent by pollinators 
visiting flowers of a given plant species, according to a number of 
experimental manipulations made on those flowers. All experimental 
manipulations (factor with 5 levels) are replicated within plants (i.e. 
plant is my sampling unit). Further, I have two populations (two level 
factor), and a number of pollinator groups (again, two levels, the same 
in both populations). The response variables in the numbe of seconds 
invested in each probe. Further, I have plant floral display as a 
covariate, as it may influence visitation rates.

I think I have to analyse this desing considering population, pollinator 
group and their interaction as fixed effects, and treatment nested 
within plant, and its interaction with population and pollinator group, 
as random factors.

In SAS terminology, the model looks like this:

proc mixed data=flwfunc.visitflower covtest method=reml;
class site pollclass treatm plantid;
model time = site|pollclass flwinflor / chisq;
random treatm site*treatm pollclass*treatm / subject=plantid;
lsmeans site pollclass site*pollclass;
run;

I've been successfully trying lm, but I think is not suitable for random 
effects. Thus, I've tried lme, but no success when defining the random 
part or trying to interpret the results...

Any help will be welcome!

-- 

--
Alfonso M. Sanchez-Lafuente
Departamento de Biologia Vegetal y Ecologia
Facultad de Biologia
Universidad de Sevilla
Avd. Reina Mercedes 9
E-41012, Sevilla, Spain
email: [EMAIL PROTECTED] / [EMAIL PROTECTED]

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


[R] Mixed model question

2005-06-17 Thread Alfonso M Sanchez-Lafuente
Hi,

I am new to this list as a poster, but a reader for some time.

I've using R for several weeks now, and I have a lot of questions about 
certain procedures. Here I go:

I want to test if there are differences in the time spent by pollinators 
visiting flowers of a given plant species, according to a number of 
experimental manipulations made on those flowers. All experimental 
manipulations (factor with 5 levels) are replicated within plants (i.e. 
plant is my sampling unit). Further, I have two populations (two level 
factor), and a number of pollinator groups (again, two levels, the same 
in both populations). The response variables in the numbe of seconds 
invested in each probe. Further, I have plant floral display as a 
covariate, as it may influence visitation rates.

I think I have to analyse this desing considering population, pollinator 
group and their interaction as fixed effects, and treatment nested 
within plant, and its interaction with population and pollinator group, 
as random factors.

In SAS terminology, the model looks like this:

proc mixed data=flwfunc.visitflower covtest method=reml;
 class site pollclass treatm plantid;
 model time = site|pollclass flwinflor / chisq;
 random treatm site*treatm pollclass*treatm / subject=plantid;
 lsmeans site pollclass site*pollclass;
run;

I've been successfully trying lm, but I think is not suitable for random 
effects. Thus, I've tried lme, but no success when defining the random 
part or trying to interpret the results...

Any help will be welcome!

-- 

--
Alfonso M. Sanchez-Lafuente
Departamento de Biologia Vegetal y Ecologia
Facultad de Biologia
Universidad de Sevilla
Avd. Reina Mercedes 9
E-41012, Sevilla, Spain
email: [EMAIL PROTECTED] / [EMAIL PROTECTED]

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


Re: [R] axis labels vertically

2005-06-17 Thread Sundar Dorai-Raj


BoM DS wrote:
 Hi,
 
 I have a plot and a custom axis labeling, e.g.
 
   x-c(...) 
   plot(x,axes=FALSE)
   axis(2)
   axis(1,1:50,c(label1,...,label50))
 
 now since the labels are quite long, only a few fit on the page.
 Can I rotate each label by 90 degree counterclockwise 
 (so that they are vertical)

You should (re-)read ?axis, which points you to the las parameter:

x - 1:50
plot(x, axes = FALSE)
axis(1, x, paste(label, x), las = 2, cex.axis = 0.5)
axis(2)
box()


--sundar

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


Re: [R] CORRELATION MATRIX CONVERSION

2005-06-17 Thread Muhammad Subianto
Maybe like:

  dat
 X   Y   Z
X 1.0 0.9 0.5
Y 0.9 1.0 0.1
Z 0.5 0.1 1.0
  datrow - stack(as.data.frame(dat))
  datrow$X=rownames(dat)
  datrow
   values ind X
11.0   X X
20.9   X Y
30.5   X Z
40.9   Y X
51.0   Y Y
60.1   Y Z
70.5   Z X
80.1   Z Y
91.0   Z Z
 

Regards,
Muhammad Subianto

On this day 6/17/2005 8:14 AM, Omer Bakkalbasi wrote:
 How do I convert the output of cor(x) to a columnar format? 
 Ex. from format below
 XYZ
 X  1.0  0.9  0.5
 Y  0.9  1.0  0.1
 Z  0.5  0.1  1.0
 
 to format below
 
 X X 1.0
 X Y 0.9
 X Z 0.5
 Y X 0.9
 Y Y 1.0
 Y Z 0.1
 Z X 0.5
 Z Y 0.1
 Z Z 1.0
 
 Thanks!
 
 Omer
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


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


Re: [R] axis labels vertically

2005-06-17 Thread Uwe Ligges
BoM DS wrote:

 Hi,
 
 I have a plot and a custom axis labeling, e.g.
 
   x-c(...) 
   plot(x,axes=FALSE)
   axis(2)
   axis(1,1:50,c(label1,...,label50))
 
 now since the labels are quite long, only a few fit on the page.
 Can I rotate each label by 90 degree counterclockwise 
 (so that they are vertical)

See ?par and its argument las.

Uwe Ligges

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

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


Re: [R] Analysing ordinal/nominal data

2005-06-17 Thread Piotr Majdak


Prof Brian Ripley wrote:

 You have still not defined v' and w', nor the scores (are they estimated 
 or not).  But the model I suggested is such a model with scores 1,2,...

Sorry for that, here it is:
scores v and w: integer scores, reflecting the ordering of columns/rows. 
Agresti suggests to use 1,2,3,... as you did.
v' and w': mean of v and w, respectively

  As I suggested before, a binomial logistic model is appropriate here,
  not a Poisson log-linear one.  (They are equivalent, but the binomial
  version is easier to interpret and less wasteful to fit.)

After your suggestions I've read the logit-Chapter in Agresti (1984) and 
tried to fit a logit model to my data:

log(m_ij2/m_ij1) = intercept + beta^PR_i(u_i-u') +
beta^ENV_j(v_j-v')

with:
mijk: expected frequencies for cell with indicies i,j,k
u_i: scores of PR with u={0,1,2,3}
v_j: scores of ENV with v={0,1,2}
beta^PR: association parameter for PR with responses
beta^ENV: association parameter for ENV with responses

I wrote in R:

count=c(250,274,285,241,279,299,247,246,255,280,355,362,
 230,207,195,239,200,181,233,235,224,200,125,118)
PR=as.integer(gl(4,3,12))-1
ENV=as.integer(gl(3,1,12))-1
countM=matrix(count,12,2)
fit=glm(countM ~ as.integer(PR)+as.integer(ENV),
family=binomial(link=logit))
summary(fit)


R gives me:

Coefficients:
 Estimate Std. Error z value Pr(|z|)
(Intercept)  0.184350.07737   2.383 0.017179 *
as.integer(PR)  -0.105380.03085  -3.416 0.000635 ***
as.integer(ENV) -0.070750.04748  -1.490 0.136191

Looking at my data, I know that for PR=0 I have a very weak dependence 
on ENV and for PR=3 very strong dependence on ENV. How can I get this 
interpretation from the summary above? I'm new in R: is 
fit$linearpredictors what I'm looking for?




-- 
Piotr Majdak
Institut fr Schallforschung
sterreichische Akademie der Wissenschaften
Reichsratsstr. 17
A-1010 Wien
Tel.: +43-1-4277-29511
Fax: +43-1-4277-9296
E-Mail: [EMAIL PROTECTED]
WWW: http://www.kfs.oeaw.ac.at

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


Re: [R] axis labels vertically

2005-06-17 Thread BoM DS
2005/6/17, Sundar Dorai-Raj [EMAIL PROTECTED]:

 You should (re-)read ?axis, which points you to the las parameter:
 
 x - 1:50
 plot(x, axes = FALSE)
 axis(1, x, paste(label, x), las = 2, cex.axis = 0.5)
 axis(2)
 box()

thank you very much. This answer helps me in several ways:
 1. it solves my particular problem
 2. I wasn't aware that there is an online-help. (was using the
tutorial on the web, which is nat at all detailed.
 3. ?axis leaded me to ?par

Thank you very much

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


[R] Error message from pamr

2005-06-17 Thread luk
Hi, 
 
I got the fowllowing error message when I run pamr. Could you please advise me 
what does this error mean?
 
Many thanks
--

 mydata - pamr.from.excel(datgrp4, 352, sample.labels=TRUE)

Read 812768 items

Read in 2307 genes

Read in 350 samples

Read in 350 sample labels

Make sure these figures are correct!!

 mytrain - pamr.train(mydata)

Error in if (from == to || length.out  2) by - 1 :

missing value where logical needed





-

 Rekindle the Rivalries. Sign up for Fantasy Football
[[alternative HTML version deleted]]

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


[R] mlbench xor

2005-06-17 Thread Thorstensen Nicolas
HI!

I have 2D feature vectors and 2 classes. I want to solve this 
classification problem with SVM. I create an object XOR of the mlbench 
library.
Then I replace the values of the XOR object with my values. Then I do a 
plot and I have my data plotted and coloured with the labels from the 
XOR object. So I replace the class labels
in the xor object with my class labels. But when I do a plot with the 
new class labels every object is coloured in one colour. But half of the 
points should be in different colour(because different class label). As 
well when I apply svm on the xor object with th replaced data it finds 
just one class.

someone any idea

thx

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


[R] wapply from gplots -- How do I get a local estimate of variance?

2005-06-17 Thread Fredrik Karlsson
Dear list,

I am trying to plot the local variance in a moving window on a
dataset. The function that I am trying to use for this is wapply from
gtools.

However, from the lattice panel function code:

snip
cat(x)
cat(y)
wapply(x,y,method=range,width=1/10,fun=sd,na.rm=TRUE) - outvar
/snip

I get:

snip
109 109 109 109 109 109 116 116 116 116 119 119 123 123 123 123 127
127 133 133 133 133 133 138 138 138 138 138 138 138 138138 138 138 142
142 142 142 142 142 142 147 147 147 147 147 158 158 158 158 158 158
158 158 158 158 158 158 158
20.234 28.431 10.762 45.613 15.028 10.775 18.516 13.371 18.516 13.371
20.61 31.08 9.338 210.77 11.927 39.438 -35.079 15.872 12.272
9.1122.665 7.355 22.057 -49.289 11.212 16.236 20.654 16.236 20.654
15.181 57.271 37.513 57.271 37.513 8.518 -108.517 -14.444 10.702 4.482
16.422 23.003 42.451 12.998 42.451 12.998 14.292 5.945 7.115 16.079
-13.172 10.62 16.079 -13.172 10.62 16.079 -13.172 10.62 20.477 22.656
Error in var(x, na.rm = na.rm) : 'x' is empty
/snip

What am I doing wrong with this? The variables that I think is
supplied to the var function does not seem to be empty like the error
message suggests.

The gplots package is from the 2.0.7 version of the gregmisc bundle.


/Fredrik Karlsson

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


[R] Fwd: lattice, panel.grid, and scales=list(tick.number=XXX)

2005-06-17 Thread Deepayan Sarkar
I just realised that I had forgotten to copy this to the list.

-- Forwarded message --
From: Deepayan Sarkar [EMAIL PROTECTED]
Date: Jun 15, 2005 12:13 PM
Subject: Re: [R] lattice, panel.grid, and scales=list(tick.number=XXX)
To: Berton Gunter [EMAIL PROTECTED]


On 6/14/05, Berton Gunter [EMAIL PROTECTED] wrote:
 If you look at the code of panel.grid, you'll see why  it doesn't work -- it
 does not use any of the scale parameters. Moreover the Help page for
 panel.grid explicitly warns that the h,v=-1 specification may not work, so
 no promises have been broken.


Right, the determination of tick mark locations can be arbitrarily
complicated, via the use of methods of the (unexported) generic
'formattedTicksAndLabels'.  The only way I can think of to make
panel.grid aware of that is to store the results of that computation
somewhere. Note that these results could potentially be different for
every panel. While this is not impossible, it violates the principle
that a panel function only has access to the data for that panel (not
that this isn't ever violated, but not to this extent), and I would be
inclined to keep things as they are unless there are better reasons.

In this particular case, the tick computations are simple, so one
could do (using the recently added 'current.panel.limits', only
available if you update lattice to the latest version):

bwplot(voice.part ~ height, data=singer,
   scales = list(tick.number = 10),
   panel = function(...) {
   ref.line - trellis.par.get(reference.line)
   panel.abline(v = pretty(current.panel.limits()$xlim, n = 10),
col = ref.line$col,
lty = ref.line$lty,
lwd = ref.line$lwd)
   panel.bwplot(...)
   })

[...]
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of M. K.
 Sent: Tuesday, June 14, 2005 3:37 PM
 To: R-help mailing list
 Subject: [R] lattice, panel.grid, and scales=list(tick.number=XXX)

 I have a Lattice plot in which I want to adjust the number of tick
 marks used, and I want to have the drawn grid reflect that change.
 Here is what I'm doing:

 bwplot(var1 ~ var2, data=df, scales=list(tick.number=10),
panel=function(...) {
panel.grid(h=0,v=-1,...);
panel.stripplot(col=gray40, pch=|, cex=2, ...);
panel.bwplot(...);
})

 Unfortunately this doesn't quite work.  Although the bwplot's tick
 marks are indeed increased as requested, the panel.grid produces the
 same (3 line) grid as before, seemingly unaware of the changed # of
 ticks.

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


Re: [R] mlbench xor

2005-06-17 Thread Uwe Ligges
Thorstensen Nicolas wrote:

 HI!
 
 I have 2D feature vectors and 2 classes. I want to solve this 
 classification problem with SVM. I create an object XOR of the mlbench 
 library.
 Then I replace the values of the XOR object with my values. Then I do a 
 plot and I have my data plotted and coloured with the labels from the 
 XOR object. So I replace the class labels
 in the xor object with my class labels. But when I do a plot with the 
 new class labels every object is coloured in one colour. But half of the 
 points should be in different colour(because different class label). As 
 well when I apply svm on the xor object with th replaced data it finds 
 just one class.
 
 someone any idea

No, almost impossible without having a reproducible example 

Uwe Ligges

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

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


Re: [R] Error message from pamr

2005-06-17 Thread Uwe Ligges
luk wrote:

 Hi, 
  
 I got the fowllowing error message when I run pamr. Could you please advise 
 me what does this error mean?
  
 Many thanks
 --
 
 
mydata - pamr.from.excel(datgrp4, 352, sample.labels=TRUE)
 
 
 Read 812768 items
 
 Read in 2307 genes
 
 Read in 350 samples
 
 Read in 350 sample labels
 
 Make sure these figures are correct!!
 
 
mytrain - pamr.train(mydata)
 
 
 Error in if (from == to || length.out  2) by - 1 :
 
 missing value where logical needed


There is no reproducible example given, hence we can only guess.
Might be a bug in package pamr or user error, if the first, you want 
to contact the package maintainer rather than R help.

Uwe Ligges




 
 
 
   
 -
 
  Rekindle the Rivalries. Sign up for Fantasy Football
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] mlbench xor

2005-06-17 Thread Friedrich . Leisch
 On Fri, 17 Jun 2005 13:28:21 +0200,
 Thorstensen Nicolas (TN) wrote:

   HI!
   I have 2D feature vectors and 2 classes. I want to solve this 
   classification problem with SVM. I create an object XOR of the mlbench 
   library.
   Then I replace the values of the XOR object with my values. Then I do a 
   plot and I have my data plotted and coloured with the labels from the 
   XOR object. So I replace the class labels
   in the xor object with my class labels. But when I do a plot with the 
   new class labels every object is coloured in one colour. But half of the 
   points should be in different colour(because different class label). As 
   well when I apply svm on the xor object with th replaced data it finds 
   just one class.

It is not the purpose of the r-help mailing list that undergraduate
students ask questions about their classwork. We have a lab session
scheduled for next Wednesday where you can ask questions like this in
person. 

My apologies to the list for the noise that has been generated.

Best,
Fritz Leisch

-- 
---
Friedrich Leisch 
Institut fr Statistik Tel: (+43 1) 58801 10715
Technische Universitt WienFax: (+43 1) 58801 10798
Wiedner Hauptstrae 8-10/1071
A-1040 Wien, Austria http://www.ci.tuwien.ac.at/~leisch

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


[R] Rmpi installation over MPICH

2005-06-17 Thread Sean Davis
This is a rather obscure question, I realize.  I have written to the 
package author but have not heard back as of yet.  I have read the 
README in the package, as well, but it didn't give me enough detail to 
diagnose the problems that I am having.  (I did edit out the LAM-MPI 
check in zzz.R.in.)

I am working to install Rmpi on top of MPICH on a beowulf cluster.  
Below is the output of the install command (which seems to go OK and 
then the start of the R session, which fails.  I was hoping someone 
with some experience installing Rmpi on MPICH could give me some help 
with doing so.

Any help would be greatly appreciated

Sean



[EMAIL PROTECTED] Rmpi]$ R CMD INSTALL 
--configure-args=--with-mpi=/opt/lib32/usr/lib 
--library='/home/sdavis/R/library' ../Rmpi_0.4-9.tar.gz
* Installing *source* package 'Rmpi' ...
Try to find mpi.h ...
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking mpi.h usability... yes
checking mpi.h presence... yes
checking for mpi.h... yes
Try to find libmpi ...
checking for main in -lmpi... yes
Try to find liblam ...
checking for main in -llam... no
liblam not found. Probably not LAM-MPI
checking for openpty in -lutil... yes
checking for main in -lpthread... yes
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/zzz.R
** libs
gcc -I/usr/lib/R/include -DPACKAGE_NAME=\\ -DPACKAGE_TARNAME=\\ 
-DPACKAGE_VERSION=\\ -DPACKAGE_STRING=\\ -DPACKAGE_BUGREPORT=\\ 
-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 
-DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 
-DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 
-DHAVE_UNISTD_H=1-I/usr/local/include   -fPIC  -O2 -g -pipe 
-march=i386 -mcpu=i686 -c conversion.c -o conversion.o
gcc -I/usr/lib/R/include -DPACKAGE_NAME=\\ -DPACKAGE_TARNAME=\\ 
-DPACKAGE_VERSION=\\ -DPACKAGE_STRING=\\ -DPACKAGE_BUGREPORT=\\ 
-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 
-DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 
-DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 
-DHAVE_UNISTD_H=1-I/usr/local/include   -fPIC  -O2 -g -pipe 
-march=i386 -mcpu=i686 -c internal.c -o internal.o
gcc -I/usr/lib/R/include -DPACKAGE_NAME=\\ -DPACKAGE_TARNAME=\\ 
-DPACKAGE_VERSION=\\ -DPACKAGE_STRING=\\ -DPACKAGE_BUGREPORT=\\ 
-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 
-DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 
-DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 
-DHAVE_UNISTD_H=1-I/usr/local/include   -fPIC  -O2 -g -pipe 
-march=i386 -mcpu=i686 -c Rmpi.c -o Rmpi.o
gcc -shared -L/usr/local/lib -o Rmpi.so conversion.o internal.o Rmpi.o 
-lmpi -lutil -lpthread
** R
** demo
** inst
** preparing package for lazy loading

** help
   Building/Updating help pages for package 'Rmpi'
  Formats: text html latex example
   hosts texthtmllatex
   internal  texthtmllatex
   mpi.abort texthtmllatex
   mpi.barrier   texthtmllatex
   mpi.bcast texthtmllatex
   mpi.bcast.Robjtexthtmllatex
   mpi.bcast.cmd texthtmllatex
   mpi.comm  texthtmllatex   example
   mpi.comm.disconnect   texthtmllatex
   mpi.comm.free texthtmllatex
   mpi.comm.intertexthtmllatex
   mpi.comm.set.errhandler   texthtmllatex
   mpi.comm.spawntexthtmllatex
   mpi.const texthtmllatex
   mpi.exit  texthtmllatex
   mpi.finalize  texthtmllatex
   mpi.gathertexthtmllatex
   mpi.get.count texthtmllatex
   mpi.get.processor.nametexthtmllatex
   mpi.get.sourcetag texthtmllatex
   mpi.info  texthtmllatex
   mpi.init.sprngtexthtmllatex
   mpi.intercomm.merge   texthtmllatex
   mpi.parallel.sim  texthtmllatex
   

Re: [R] CORRELATION MATRIX CONVERSION

2005-06-17 Thread Liaw, Andy
Something like:

 dat - data.frame(x=runif(10), y=runif(10), z=runif(10))
 m - cor(dat)
 m
  x  y  z
x 1.000  0.1183305  0.1096394
y 0.1183305  1.000 -0.2819285
z 0.1096394 -0.2819285  1.000
 mat2col - function(m) {
+ m2 - matrix(m, ncol=1)
+ rownames(m2) - outer(rownames(m), colnames(m), paste)
+ m2
+ }
 mat2col(m)
  [,1]
x x  1.000
y x  0.1183305
z x  0.1096394
x y  0.1183305
y y  1.000
z y -0.2819285
x z  0.1096394
y z -0.2819285
z z  1.000

Andy 

 From: Omer Bakkalbasi
 
 How do I convert the output of cor(x) to a columnar format? 
 Ex. from format below
 XYZ
 X  1.0  0.9  0.5
 Y  0.9  1.0  0.1
 Z  0.5  0.1  1.0
 
 to format below
 
 X X 1.0
 X Y 0.9
 X Z 0.5
 Y X 0.9
 Y Y 1.0
 Y Z 0.1
 Z X 0.5
 Z Y 0.1
 Z Z 1.0
 
 Thanks!
 
 Omer
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 
 


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


Re: [R] CORRELATION MATRIX CONVERSION

2005-06-17 Thread Omer Bakkalbasi
Excellent!  This is the most flexible and intuitive option. Thanks!

Omer 
Cell: (914) 671-7447

-Original Message-
From: Liaw, Andy [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 17, 2005 8:40 AM
To: '[EMAIL PROTECTED]'; r-help@stat.math.ethz.ch
Subject: RE: [R] CORRELATION MATRIX CONVERSION

Something like:

 dat - data.frame(x=runif(10), y=runif(10), z=runif(10))
 m - cor(dat)
 m
  x  y  z
x 1.000  0.1183305  0.1096394
y 0.1183305  1.000 -0.2819285
z 0.1096394 -0.2819285  1.000
 mat2col - function(m) {
+ m2 - matrix(m, ncol=1)
+ rownames(m2) - outer(rownames(m), colnames(m), paste)
+ m2
+ }
 mat2col(m)
  [,1]
x x  1.000
y x  0.1183305
z x  0.1096394
x y  0.1183305
y y  1.000
z y -0.2819285
x z  0.1096394
y z -0.2819285
z z  1.000

Andy 

 From: Omer Bakkalbasi
 
 How do I convert the output of cor(x) to a columnar format? 
 Ex. from format below
 XYZ
 X  1.0  0.9  0.5
 Y  0.9  1.0  0.1
 Z  0.5  0.1  1.0
 
 to format below
 
 X X 1.0
 X Y 0.9
 X Z 0.5
 Y X 0.9
 Y Y 1.0
 Y Z 0.1
 Z X 0.5
 Z Y 0.1
 Z Z 1.0
 
 Thanks!
 
 Omer
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 
 
 




--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

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


Re: [R] possible bug in merge with duplicate blank names in 'by' field.

2005-06-17 Thread Frank Gibbons
Thanks for your quick responses, Gabor and Brian.

I'm currently running R version 1.9.1 on Linux. Actually, I have just 
tested this on R v.2.1.0 running under Windows XP, and indeed, as you both 
indicate, the problem does not exist on that version for that OS. So, at an 
appropriate time I'll upgrade my Linux installation to the most recent 
version (1.9.1 is a year old, I guess).

-Frank

At 03:26 AM 6/17/2005, Prof Brian Ripley wrote:
What version of R is this (please do see the posting guide)?

In both 2.1.0 and 2.1.1 beta I get

all
   Promoter ip.x ip.y ip
130   40 40
240   40 40
3a   10   NA NA
4c   20   20 20
5b   NA   15 15
6d   NA   30 30

so cannot reproduce your result. Are you sure that the `blanks' really are 
empty and not some character that is printing as empty on your unstated OS?

BTW ' ' is what is normally called `blank'.

BTW, these are not `names' but character strings: `names' has other 
meanings in R.

PhD, Computational Biologist,
Harvard Medical School BCMP/SGM-322, 250 Longwood Ave, Boston MA 02115, USA.
Tel: 617-432-3555   Fax: 
617-432-3557   http://llama.med.harvard.edu/~fgibbons

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


[R] Trying to build R sources on Windows

2005-06-17 Thread Bill Northcott
I am trying without success to build the R-2.1.0 sources on Windows  
2003 server.

I have MinGW/bin in front of cygwin/bin in the Windows path.

However, I try to build, I get failures trying to include headers  
which are not part of MinGW.  I am definitely using the MinGW  
compilers, so why are the sources trying to access headers which are  
not included?

Examples would be:
argz.h included from l10nflist.c
alloca.h from errors.c
langinfo.h from main.c

Any clues about what I am doing wrong?

Bill Northcott

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


[R] reading csv-data

2005-06-17 Thread Johanna Sundvik

Hi!

I have had this problem for a long time. I have tried to study the manuals and
search the mailing lists, but I can not solve this. I think there has to be one
simple solution to this, but I just can not find it. 

I have saved the data in excel (csv-format). Then I read the data in R e.g.

data - read.csv2(example.csv, header=TRUE)

I look the data and it looks ok. E.g

data
 Mean1   
1   4.4332  
2   8.5113  
3  35.1624 
4   9.1693 
52.974 
6  65.1578 
7  43.2241 
8   3.1278 
9   5.3364 
10  3.9767 

However, this Mean1 is categorical when it should be real numbers.

 Mean1
[1] 4.4332  8.5113  35.1624 9.1693  2.974   65.1578 43.2241 3.1278  5.3364 
Levels: 2.974 3.1278 35.1624 4.4332 43.2241 5.3364 65.1578 8.5113 9.1693

Why R does not understand that this should be real numbers? What am I doing
wrong here? Thanks for your help.

Regards,
Johanna Sundvik

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


[R] [R-pkgs] New CRAN package sp: classes and methods for spatial data

2005-06-17 Thread Edzer J. Pebesma
We're happy to announce the CRAN release of sp, an R package which
has new-style classes and methods for spatial data, version 0.7-9.

Spatial data types that sp implements are: points, grids, lines, and
polygons (i.e., rings) optionally with holes. Methods include

+ the usual print, summary, plot, [, [[, $, ...
+ coercion between types (e.g. points and grids, matrices, data.frames)
+ coordinates(x), which returns the spatial coordinates of x
+ bbox(x), returns the coordinates bounding box of x
+ overlay, to query the value of e.g. points in polygons or grid
   (essentially does a point-in-polygon or point-in-raster cell)
+ spsample, for random sampling methods over a spatial domain.

An additional package (spproj) provides coordinate reference system
transformation (projection and re-projection) using the PROJ.4 library
[2]. Others (will) provide interfaces to GRASS 6 and gdal.

A good deal of work has also gone into providing plotting methods using
base, grid and lattice graphics, through the spplot function, a front-end
to lattice plots for spatial data (see gallery [1]).

The home page of these packages is found at
http://r-spatial.sourceforge.net/
See also the Task View on Spatial Data Analysis, linked from CRAN.

The reason why we wrote this package is that we think R is an excellent
environment to deal with spatial data, but that it lacks a uniform way
to deal with spatial data. Compared to the handling of dates and times,
which can utilize base classes or those provided in the chron package,
spatial data handling is much more fragmented. As a consequence:

- various packages make their own assumptions about how spatial data
   are organized
- spatial data organized for a certain package cannot easily be used
   for another package
- few (or no) packages address the full range of spatial data types
   (points, grids, lines, polygons) and their interaction
- generic spatial functionality (e.g. I/O to GIS, plotting, projection)
   is scattered and often limited in functionality.

It also means that many different package authors have to use time writing
similar data handling code, rather than concentrating on analytical
functions. If the sp package achieves its goals, data I/O will become
many-to-one, and data access for analysis one-to-many, providing a shared
data object layer for which shared methods can be written.

Classes and methods for spatial data are only useful when the spatial
packages support them. The sp development team includes maintainers of
a number of spatial R packages, on which we will work, and we hope that
over time other spatial package maintainers will also provide support
for the classes provided by this package.

Although we are working towards a fixed set of classes at this moment
of the development of sp we cannot fully guarantee that the exact
representation of the sp classes will not change in the future. Therefore,
we advise users to keep the scripts with instructions of building the
data into sp classes; it is most likely that we will not change the
building functions and methods.

Work in progress currently involves:
- support of sp classes by several spatial statistics packages
- automatic determination of hole polygons from shapefiles
- plotting filled polygons with holes
- gdal read/write support
- GRASS 6.0 support

The development of this package is a joint effort of Virgilio Gomez-Rubio,
Barry Rowlinson, Roger Bivand and Edzer Pebesma, and followed from
discussions held at a pre-DSC2003 workshop [3], announcements on R-sig-geo
[4], and a meeting held last November in Lancaster [5]. A beta release
of sp was announced a while ago on R-sig-geo [6].

With best regards,
--
Roger Bivand and Edzer Pebesma


[1] http://r-spatial.sourceforge.net/
[2] http://www.remotesensing.org/proj/
[3] http://spatial.nhh.no/meetings/vienna/index.html
[4] e.g. https://stat.ethz.ch/pipermail/r-sig-geo/2003-October/28.html
[5] http://elearning.maths.lancs.ac.uk:8080/RSpatial/
[6] https://stat.ethz.ch/pipermail/r-sig-geo/2005-April/000378.html

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

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


[R] drop elements of vector by class

2005-06-17 Thread E. Michael Foster
i'm trying to build a little summary table for the contents of a data frame.

t-sapply(macro, data.class)
c-sapply(macro, length)
m-sapply(macro, mean, na.rm=T, digits=2)
cbind(type=t, n=c , mean=m)

I want to drop the variables that are factors so I can include -max- and 
-min- in my table.
-macro- contacts the data--how do I drop the variables according to their 
data.class

thanks,
michael foster





E. Michael Foster
(W) 814-865-1923
(Fax) 814-863-

After 7/1

Work:
Professor of Maternal and Child Health
School of Public Health
University of North Carolina, Chapel Hill
Rosenau Hall, CB# 7445
Chapel Hill, NC 27599-7445

Home:
309 Old Larkspur Way
Chapel Hill, NC  27516


UNC School of Public Health--voted #2 SPH by
 . US News
 . Association of Hand-to-Fin Carp Fisherman
 . Iron Chef (not to be confused with the Iron Dukes!)

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


Re: [R] reading csv-data

2005-06-17 Thread Thomas Lumley
On Fri, 17 Jun 2005, Johanna Sundvik wrote:
 However, this Mean1 is categorical when it should be real numbers.

 Mean1
 [1] 4.4332  8.5113  35.1624 9.1693  2.974   65.1578 43.2241 3.1278  5.3364
 Levels: 2.974 3.1278 35.1624 4.4332 43.2241 5.3364 65.1578 8.5113 9.1693

 Why R does not understand that this should be real numbers? What am I doing
 wrong here? Thanks for your help.


Your files must have some entries that are not numbers, such as . or 
something.  R then can't tell that the field is supposed to be numeric. 
This may happen with missing data, in which case the na.strings= argument 
can be used to tell R how missing data are specified.

You can convert the data to numeric as described in FAQ 7.10

-thomas

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


[R] How to calculate random matrices from the multivariate normal distribution

2005-06-17 Thread Juan Carlos Quiroz Espinosa
Hi R users,

I am trying to calculate MonteCarlo from the multivariate normal
distribution. I am utilizing the parameters vector (how mean) and
covariance matrix (or 1/hessian) how input.  

Can anyone provide guidance on how I could do this?

Thank you.


Juan Carlos Quiroz
Instituto de Fomento Pesquero
Blanco 839
Valparaiso, CHILE.
Casilla 8V
Office: 56+032-322497
Email: [EMAIL PROTECTED]

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


[R] Fit values for NA's in linear regression

2005-06-17 Thread Luca Wacker
Hi,

To obtain estimates for some missing values in my data I fitted a 
linear regression and then used the command fitted(model) to get the 
fitted values from the model, but R doesn't return any values for the 
NA's. I can calculate the fitted values from the estimates obtained 
from the summary of model, but that's not very handy. Is there a way to 
include the missing values in the analysis and get fitted values for 
the NA's? I tried to use with the function na.action, but that didn't 
work.


thanks

Luca

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


Re: [R] Analysing ordinal/nominal data

2005-06-17 Thread Piotr Majdak
Hi Brian (and the list of course!),

I still have problems analysing data in R, because I don't know how to 
tell glm() use row-effect model, please. The models are well defined 
by Agresti, but can't get the link from the theory to the 
implementations in R. Different names, definitions and no explanation of 
results in the documentation of glm() or summary() make it hard to get in...

But I found another solution for my data: I just use the saturated 
log-linear model for categorial data and refer to the estimated 
parameter of the three-way-interaction only. That's enough statistics 
for my paper ;-).

Thanks for your help,

Piotr Majdak

Prof Brian Ripley wrote:

 As I suggested before, a binomial logistic model is appropriate here, 
 not a Poisson log-linear one.  (They are equivalent, but the binomial 
 version is easier to interpret and less wasteful to fit.)
 
 You have still not defined v' and w', nor the scores (are they estimated 
 or not).  But the model I suggested is such a model with scores 1,2,...

-- 
Piotr Majdak
Acoustics Research Institute
Austrian Academy of Sciences
Reichsratsstr. 17
A-1010 Vienna
AUSTRIA
phone: +43-1-4277-29511
fax: +43-1-4277-9296
email: [EMAIL PROTECTED]
WWW: http://www.kfs.oeaw.ac.at

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


Re: [R] reading csv-data

2005-06-17 Thread Ivar Herfindal


Thomas Lumley wrote:

 On Fri, 17 Jun 2005, Johanna Sundvik wrote:
 
However, this Mean1 is categorical when it should be real numbers.


Mean1

[1] 4.4332  8.5113  35.1624 9.1693  2.974   65.1578 43.2241 3.1278  5.3364
Levels: 2.974 3.1278 35.1624 4.4332 43.2241 5.3364 65.1578 8.5113 9.1693

Why R does not understand that this should be real numbers? What am I doing
wrong here? Thanks for your help.

 
 
 Your files must have some entries that are not numbers, such as . or 
 something.  R then can't tell that the field is supposed to be numeric. 
 This may happen with missing data, in which case the na.strings= argument 
 can be used to tell R how missing data are specified.
 
 You can convert the data to numeric as described in FAQ 7.10
 
   -thomas
 
I think the problem can be that you use read.csv2(), which expect a 
comma (,) as decimal-indicator (as is common in Scandinavia), and a 
semi-colon (;) as separator between columns. Either you should try 
read.csv(), or you can try read.csv2(example.csv, dec=., header=TRUE)

Have a look at ?read.csv (read.csv2 is in the same help-text).

Ivar

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

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


Re: [R] reading csv-data

2005-06-17 Thread Don MacQueen
In my experience, this has always been due to the presence of 
non-numeric values in the input.

In the example you show, it is not obvious that there is any. I would 
start by first inspecting the input file very carefully, using a text 
editor outside of R. Since your example appears to have only one 
column of data, you could try reading it with the scan() function. 
This might produce additional information that would help you 
identify any non-numeric data. Using count.fields() on the data file 
might reveal something.

If Mean1 is an element of data, then simply typing Mean1 at the 
prompt should produce a not found message. Yet Mean1 was found. 
Have you omitted something in your email, or is there another object 
named Mean1?

-Don

At 4:50 PM +0300 6/17/05, Johanna Sundvik wrote:
Hi!

I have had this problem for a long time. I have tried to study the manuals and
search the mailing lists, but I can not solve this. I think there 
has to be one
simple solution to this, but I just can not find it.

I have saved the data in excel (csv-format). Then I read the data in R e.g.

data - read.csv2(example.csv, header=TRUE)

I look the data and it looks ok. E.g

data
  Mean1  
1   4.4332 
2   8.5113 
3  35.1624
4   9.1693
52.974
6  65.1578
7  43.2241
8   3.1278
9   5.3364
10  3.9767

However, this Mean1 is categorical when it should be real numbers.

  Mean1
[1] 4.4332  8.5113  35.1624 9.1693  2.974   65.1578 43.2241 3.1278  5.3364
Levels: 2.974 3.1278 35.1624 4.4332 43.2241 5.3364 65.1578 8.5113 9.1693

Why R does not understand that this should be real numbers? What am I doing
wrong here? Thanks for your help.

Regards,
Johanna Sundvik

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


-- 
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA

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


Re: [R] How to calculate random matrices from the multivariate normal distribution

2005-06-17 Thread Duncan Murdoch
On 6/17/2005 11:03 AM, Juan Carlos Quiroz Espinosa wrote:
 Hi R users,
 
 I am trying to calculate MonteCarlo from the multivariate normal
 distribution. I am utilizing the parameters vector (how mean) and
 covariance matrix (or 1/hessian) how input.  
 
 Can anyone provide guidance on how I could do this?

You probably want the mvrnorm function from the MASS package.

Duncan Murdoch

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


Re: [R] drop elements of vector by class

2005-06-17 Thread Dimitris Rizopoulos
try this

# to get only the factors
macro.f - macro[sapply(macro, is.factor)]

to drop the factors
macro.nf - macro[sapply(macro, !is.factor)]

# to get only numerics
macro.n - macro[sapply(macro, is.numeric)]

and so on.

I hope it helps.

Best,
Dimitris


Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

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



- Original Message - 
From: E. Michael Foster [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Friday, June 17, 2005 4:57 PM
Subject: [R] drop elements of vector by class


 i'm trying to build a little summary table for the contents of a 
 data frame.

 t-sapply(macro, data.class)
 c-sapply(macro, length)
 m-sapply(macro, mean, na.rm=T, digits=2)
 cbind(type=t, n=c , mean=m)

 I want to drop the variables that are factors so I can include -max- 
 and
 -min- in my table.
 -macro- contacts the data--how do I drop the variables according to 
 their
 data.class

 thanks,
 michael foster




 
 E. Michael Foster
 (W) 814-865-1923
 (Fax) 814-863-

 After 7/1

 Work:
 Professor of Maternal and Child Health
 School of Public Health
 University of North Carolina, Chapel Hill
 Rosenau Hall, CB# 7445
 Chapel Hill, NC 27599-7445

 Home:
 309 Old Larkspur Way
 Chapel Hill, NC  27516


 UNC School of Public Health--voted #2 SPH by
 . US News
 . Association of Hand-to-Fin Carp Fisherman
 . Iron Chef (not to be confused with the Iron Dukes!)

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


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


Re: [R] How to calculate random matrices from the multivariate normal distribution

2005-06-17 Thread Spencer Graves
  RSiteSearch(random multivariate normal) produced 82 hits, the 
fourth of which was for multivariate normal distribution, function 
pmvnorm in library mvtnorm, which also includes a function rmvorm, that 
should do what you want.

  Buena suerte.  spencer graves

Juan Carlos Quiroz Espinosa wrote:

 Hi R users,
 
 I am trying to calculate MonteCarlo from the multivariate normal
 distribution. I am utilizing the parameters vector (how mean) and
 covariance matrix (or 1/hessian) how input.  
 
 Can anyone provide guidance on how I could do this?
 
 Thank you.
 
 
 Juan Carlos Quiroz
 Instituto de Fomento Pesquero
 Blanco 839
 Valparaiso, CHILE.
 Casilla 8V
 Office: 56+032-322497
 Email: [EMAIL PROTECTED]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] drop elements of vector by class

2005-06-17 Thread McGehee, Robert
a - data.frame(a = 1:2, b = c(a, b), c = I(c(a, b)))

a - a[ , !sapply(a, class) %in% factor]

-Original Message-
From: E. Michael Foster [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 17, 2005 10:58 AM
To: r-help@stat.math.ethz.ch
Subject: [R] drop elements of vector by class


i'm trying to build a little summary table for the contents of a data
frame.

t-sapply(macro, data.class)
c-sapply(macro, length)
m-sapply(macro, mean, na.rm=T, digits=2)
cbind(type=t, n=c , mean=m)

I want to drop the variables that are factors so I can include -max- and

-min- in my table.
-macro- contacts the data--how do I drop the variables according to
their 
data.class

thanks,
michael foster





E. Michael Foster
(W) 814-865-1923
(Fax) 814-863-

After 7/1

Work:
Professor of Maternal and Child Health
School of Public Health
University of North Carolina, Chapel Hill
Rosenau Hall, CB# 7445
Chapel Hill, NC 27599-7445

Home:
309 Old Larkspur Way
Chapel Hill, NC  27516


UNC School of Public Health--voted #2 SPH by
 . US News
 . Association of Hand-to-Fin Carp Fisherman
 . Iron Chef (not to be confused with the Iron Dukes!)

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

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


Re: [R] Mixed model question

2005-06-17 Thread Spencer Graves
  Have you also tried lmer in library(lme4)?  This is newer and 
better in many ways.  Unfortunately, I see only one example in the Help 
file, but you might be able to figure out how to use lmer from the help 
file and from the 125 hits on RSiteSearch(lmer).

  The definitive work on this subject, from my perspective, is Pinheiro 
and Bates (2000) Mixed-Effects Models in S and S-PLUS (Springer).  This 
book is primarily how to use lme.  I learned a lot from it (and from 
Doug Bates' other book with Don Watts on nonlinear regression).  I 
couldn't find Pinheiro and Bates in the catalog for the library at 
Universidad de Sevilla (though Bates and Watts was listed).

  Feel free to submit other questions after you've considered this, but 
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html first.  In particular, you 
might have gotten a more helpful reply to this question if you had 
included one of your attempts with lme, asking what you did wrong or 
what you don't understand about the results.

  Buena suerte,
  spencer graves

Alfonso M Sanchez-Lafuente wrote:
 Hi,
 
 I am new to this list as a poster, but a reader for some time.
 
 I've using R for several weeks now, and I have a lot of questions about 
 certain procedures. Here I go:
 
 I want to test if there are differences in the time spent by pollinators 
 visiting flowers of a given plant species, according to a number of 
 experimental manipulations made on those flowers. All experimental 
 manipulations (factor with 5 levels) are replicated within plants (i.e. 
 plant is my sampling unit). Further, I have two populations (two level 
 factor), and a number of pollinator groups (again, two levels, the same 
 in both populations). The response variables in the numbe of seconds 
 invested in each probe. Further, I have plant floral display as a 
 covariate, as it may influence visitation rates.
 
 I think I have to analyse this desing considering population, pollinator 
 group and their interaction as fixed effects, and treatment nested 
 within plant, and its interaction with population and pollinator group, 
 as random factors.
 
 In SAS terminology, the model looks like this:
 
 proc mixed data=flwfunc.visitflower covtest method=reml;
  class site pollclass treatm plantid;
  model time = site|pollclass flwinflor / chisq;
  random treatm site*treatm pollclass*treatm / subject=plantid;
  lsmeans site pollclass site*pollclass;
 run;
 
 I've been successfully trying lm, but I think is not suitable for random 
 effects. Thus, I've tried lme, but no success when defining the random 
 part or trying to interpret the results...
 
 Any help will be welcome!


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


Re: [R] Fit values for NA's in linear regression

2005-06-17 Thread Spencer Graves
  Have you considered:

  set.seed(1)
  tstDF - data.frame(x=1:4, y=c(NA, 2:4+rnorm(3)))
  fit - lm(y~x, tstDF)
  predict(fit)
234
1.678441 2.573854 3.469266
  predict(fit, tstDF)
 1 2 3 4
0.7830284 1.6784410 2.5738536 3.4692662

  spencer graves

Luca Wacker wrote:

 Hi,
 
 To obtain estimates for some missing values in my data I fitted a 
 linear regression and then used the command fitted(model) to get the 
 fitted values from the model, but R doesn't return any values for the 
 NA's. I can calculate the fitted values from the estimates obtained 
 from the summary of model, but that's not very handy. Is there a way to 
 include the missing values in the analysis and get fitted values for 
 the NA's? I tried to use with the function na.action, but that didn't 
 work.
 
 
 thanks
 
 Luca
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] reading csv-data

2005-06-17 Thread Spencer Graves
  I've struggled with this myself in the past.  I've recently started 
using the following:

File - pair.txt
# File name with path if different from getwd()
readLines(File, n=9)

  The function  readLines reads the first n lines as n individual 
character strings.  From this, you can identify extra headers, the 
separate characters, etc.  Then I can do something like the following:

plot(count.fields(File, sep=\t))

  The function count.fields also has arguments to specify a number of 
lines to skip before it starts to process the file, which can be helpful 
with multiple headers.  After count.fields produces a constant result 
consistent with what I want, then I'm ready to use read.table or one 
of its variants like read.csv2.

  hope this helps.
  spencer graves

Don MacQueen wrote:

 In my experience, this has always been due to the presence of 
 non-numeric values in the input.
 
 In the example you show, it is not obvious that there is any. I would 
 start by first inspecting the input file very carefully, using a text 
 editor outside of R. Since your example appears to have only one 
 column of data, you could try reading it with the scan() function. 
 This might produce additional information that would help you 
 identify any non-numeric data. Using count.fields() on the data file 
 might reveal something.
 
 If Mean1 is an element of data, then simply typing Mean1 at the 
 prompt should produce a not found message. Yet Mean1 was found. 
 Have you omitted something in your email, or is there another object 
 named Mean1?
 
 -Don
 
 At 4:50 PM +0300 6/17/05, Johanna Sundvik wrote:
 
Hi!

I have had this problem for a long time. I have tried to study the manuals and
search the mailing lists, but I can not solve this. I think there 
has to be one
simple solution to this, but I just can not find it.

I have saved the data in excel (csv-format). Then I read the data in R e.g.


data - read.csv2(example.csv, header=TRUE)

I look the data and it looks ok. E.g


data

 Mean1  
1   4.4332 
2   8.5113 
3  35.1624
4   9.1693
52.974
6  65.1578
7  43.2241
8   3.1278
9   5.3364
10  3.9767

However, this Mean1 is categorical when it should be real numbers.


 Mean1

[1] 4.4332  8.5113  35.1624 9.1693  2.974   65.1578 43.2241 3.1278  5.3364
Levels: 2.974 3.1278 35.1624 4.4332 43.2241 5.3364 65.1578 8.5113 9.1693

Why R does not understand that this should be real numbers? What am I doing
wrong here? Thanks for your help.

Regards,
Johanna Sundvik

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


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


[R] Data comparison

2005-06-17 Thread dscully




Question :  Is it possible to create a function, using a for ifelse
function, inside sapply, to compare the values in one data frame to a set
of upper and lower limits in another data frame, same number of columns.,
Take  the values which meet the requirements TRUE  and create a new data
frame or table containing the filtered data?   Can you give me a shove in
the correct direction?  Thanks

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


Re: [R] Fit values for NA's in linear regression

2005-06-17 Thread Liaw, Andy
It depends on the na.action used in lm(), which defaults to na.omit.  Here's
an example:

 x - c(1:5, NA, 7:10)
 y - rnorm(x)
 fitted(lm(y ~ x))
  1   2   3   4   5   7
8 
 0.68680104  0.47913875  0.27147646  0.06381417 -0.14384812 -0.55917271
-0.76683500 
  9  10 
-0.97449729 -1.18215958 
 fitted(lm(y ~ x, na.action=na.exclude))
  1   2   3   4   5   6
7 
 0.68680104  0.47913875  0.27147646  0.06381417 -0.14384812  NA
-0.55917271 
  8   9  10 
-0.76683500 -0.97449729 -1.18215958 

Andy 

 From: Luca Wacker
 
 Hi,
 
 To obtain estimates for some missing values in my data I fitted a 
 linear regression and then used the command fitted(model) to get the 
 fitted values from the model, but R doesn't return any values for the 
 NA's. I can calculate the fitted values from the estimates obtained 
 from the summary of model, but that's not very handy. Is 
 there a way to 
 include the missing values in the analysis and get fitted values for 
 the NA's? I tried to use with the function na.action, but that didn't 
 work.
 
 
 thanks
 
 Luca
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 
 


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


[R] vectorization

2005-06-17 Thread Dimitri Joe
Hi there,

I have a data frame (mydata) with 1 numeric variable (income) and 1 factor 
(education). I want a new column in this data with the median income for each 
education level. A obviously inneficient way to do this is

for ( k in 1: nrow(mydata) ){
l - mydata$education[k]
mydata$md[k] - median(mydata$income[mydata$education==l],na.rm=T)
}

Since mydata has nearly 30.000 rows, this will be done not untill the end of 
this month. I thus need some help for vectorizing this, please.

Thanks,

Dimitri

[[alternative HTML version deleted]]






___ 

Instale o discador agora! http://br.acesso.yahoo.com/

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


Re: [R] Fit values for NA's in linear regression

2005-06-17 Thread Liaw, Andy
I posted a bad example.  The question would only make sense if NAs are all
in the response.  Here's try #2:

I believe you can not get fitted values for cases where y is missing
directly from the model object.  You can, however, use predict(lm.object,
newdata=mydata[!complete.cases(mydata)]) to get the predictions for those
with missing y.

Andy

 From: Luca Wacker
 
 Hi,
 
 To obtain estimates for some missing values in my data I fitted a 
 linear regression and then used the command fitted(model) to get the 
 fitted values from the model, but R doesn't return any values for the 
 NA's. I can calculate the fitted values from the estimates obtained 
 from the summary of model, but that's not very handy. Is 
 there a way to 
 include the missing values in the analysis and get fitted values for 
 the NA's? I tried to use with the function na.action, but that didn't 
 work.
 
 
 thanks
 
 Luca
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 
 


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


Re: [R] logistic regression - using polys and products of features

2005-06-17 Thread ronggui
On Fri, 17 Jun 2005 07:39:30 +1000
Stephen Choularton [EMAIL PROTECTED] wrote:

 Hi
  
 I can get all my features by doing this:
  
  logistic.model = glm(similarity ~ ., family=binomial, data =
 cData[3001:3800,])
  
  
 I can get the product of all my features by this:
  
 logistic.model = glm(similarity ~ . ^ 2,  family=binomial, data =
 cData[3001:3800,])
  
 I don't seem to be able to get polys by doing this:
  
 logistic.model = glm(similarity ~ poly(.,2), family=binomial, data =
 cData[3001:3800,])
 Error in poly(., 2) : Object . not found
 
  
 How can I get polys?
  
 What do the warnings mean  when I  do this:
  
  logistic.model = glm(similarity ~ . + . ^ 2, family=binomial, data =
 cData[3001:3800,])
 Warning messages: 
 1: Algorithm did not converge in: glm.fit(x = X, y = Y, weights =
 weights, start = start, etastart = etastart,  
 2: fitted probabilities numerically 0 or 1 occurred in: glm.fit(x = X, y
 = Y, weights = weights, start = start, etastart = etastart,  

.^2 means all the 2-order and 1-order terms,so .+.^2 is meaningless.

 How can I do this?
  
 logistic.model = glm(similarity ~ . + . ^ 2 + poly(.,2),
 family=binomial, data = cData[3001:3800,])


  
 Thanks
  
 Stephen
  
  
  
 
 --
 Internal Virus Database is out-of-date.
 Checked by AVG Anti-Virus.
 
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


-- 
Department of Sociology
Fudan University,Shanghai
Blog:http://sociology.yculblog.com

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


[R] trim a string

2005-06-17 Thread Omar Lakkis
How to trim the leading and trailing white space off of a string?

 If the variable is   E   I need to convert it to E.

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


Re: [R] Mixed model question

2005-06-17 Thread ronggui
and the newest R-new in the www.r-project.org has an article about how to use 
the lmer function.

On Fri, 17 Jun 2005 08:43:41 -0700
Spencer Graves [EMAIL PROTECTED] wrote:

 Have you also tried lmer in library(lme4)?  This is newer and 
 better in many ways.  Unfortunately, I see only one example in the Help 
 file, but you might be able to figure out how to use lmer from the help 
 file and from the 125 hits on RSiteSearch(lmer).
 
 The definitive work on this subject, from my perspective, is Pinheiro 
 and Bates (2000) Mixed-Effects Models in S and S-PLUS (Springer).  This 
 book is primarily how to use lme.  I learned a lot from it (and from 
 Doug Bates' other book with Don Watts on nonlinear regression).  I 
 couldn't find Pinheiro and Bates in the catalog for the library at 
 Universidad de Sevilla (though Bates and Watts was listed).
 
 Feel free to submit other questions after you've considered this, but 
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html first.  In particular, you 
 might have gotten a more helpful reply to this question if you had 
 included one of your attempts with lme, asking what you did wrong or 
 what you don't understand about the results.
 
 Buena suerte,
 spencer graves
 
 Alfonso M Sanchez-Lafuente wrote:
  Hi,
  
  I am new to this list as a poster, but a reader for some time.
  
  I've using R for several weeks now, and I have a lot of questions about 
  certain procedures. Here I go:
  
  I want to test if there are differences in the time spent by pollinators 
  visiting flowers of a given plant species, according to a number of 
  experimental manipulations made on those flowers. All experimental 
  manipulations (factor with 5 levels) are replicated within plants (i.e. 
  plant is my sampling unit). Further, I have two populations (two level 
  factor), and a number of pollinator groups (again, two levels, the same 
  in both populations). The response variables in the numbe of seconds 
  invested in each probe. Further, I have plant floral display as a 
  covariate, as it may influence visitation rates.
  
  I think I have to analyse this desing considering population, pollinator 
  group and their interaction as fixed effects, and treatment nested 
  within plant, and its interaction with population and pollinator group, 
  as random factors.
  
  In SAS terminology, the model looks like this:
  
  proc mixed data=flwfunc.visitflower covtest method=reml;
   class site pollclass treatm plantid;
   model time = site|pollclass flwinflor / chisq;
   random treatm site*treatm pollclass*treatm / subject=plantid;
   lsmeans site pollclass site*pollclass;
  run;
  
  I've been successfully trying lm, but I think is not suitable for random 
  effects. Thus, I've tried lme, but no success when defining the random 
  part or trying to interpret the results...
  
  Any help will be welcome!
 
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


-- 
Department of Sociology
Fudan University,Shanghai
Blog:http://sociology.yculblog.com

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


[R] How to get the values of a vector having the indices?

2005-06-17 Thread Amir Safari
 
 
Hi
I want to get the values of a vector which I have its indices. How it is 
possible?
For example after clustering , I can access to the indices of the first cluster 
using:
first- which(clusters$clustering==1)
first give me the indices, but how can I access to the values?
Thanks a lot and have a fun.
Amir

__



[[alternative HTML version deleted]]

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


Re: [R] vectorization

2005-06-17 Thread Liaw, Andy
Here I go again with ave():

mydata$md - ave(mydata$income, mydata$education, FUN=median, na.rm=TRUE)

IMHO it's one of the most under-rated helper functions in R.

Andy

 From: Dimitri Joe
 
 Hi there,
 
 I have a data frame (mydata) with 1 numeric variable (income) 
 and 1 factor (education). I want a new column in this data 
 with the median income for each education level. A obviously 
 inneficient way to do this is
 
 for ( k in 1: nrow(mydata) ){
 l - mydata$education[k]
 mydata$md[k] - median(mydata$income[mydata$education==l],na.rm=T)
 }
 
 Since mydata has nearly 30.000 rows, this will be done not 
 untill the end of this month. I thus need some help for 
 vectorizing this, please.
 
 Thanks,
 
 Dimitri
 
   [[alternative HTML version deleted]]
 
 
 
   
   
   
 ___ 
 
 Instale o discador agora! http://br.acesso.yahoo.com/
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 
 


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


Re: [R] trim a string

2005-06-17 Thread Liaw, Andy
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/14493.html

Andy

 From: Omar Lakkis
 
 How to trim the leading and trailing white space off of a string?
 
  If the variable is   E   I need to convert it to E.
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 
 


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


Re: [R] vectorization

2005-06-17 Thread Huntsinger, Reid
You can use tapply() to compute the medians, as in

meds - tapply(mydata$inc,INDEX=mydata$ed,FUN=median)

then create a new column with the medians as

medianEd - meds[mydata$ed]


Reid Huntsinger

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dimitri Joe
Sent: Friday, June 17, 2005 1:01 PM
To: R-Help
Subject: [R] vectorization


Hi there,

I have a data frame (mydata) with 1 numeric variable (income) and 1 factor
(education). I want a new column in this data with the median income for
each education level. A obviously inneficient way to do this is

for ( k in 1: nrow(mydata) ){
l - mydata$education[k]
mydata$md[k] - median(mydata$income[mydata$education==l],na.rm=T)
}

Since mydata has nearly 30.000 rows, this will be done not untill the end of
this month. I thus need some help for vectorizing this, please.

Thanks,

Dimitri

[[alternative HTML version deleted]]






___ 

Instale o discador agora! http://br.acesso.yahoo.com/

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

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


Re: [R] vectorization

2005-06-17 Thread Kevin Bartz
These two lines worked for me:

rst - tapply(mydata$income, mydata$education, median)
mydata$md - rst[mydata$education]

Here's my cheesy example:

 mydata - data.frame(income= round(rnorm(3, 55000, 1)),
+  education = letters[rbinom(3, 4, 1/2)+1])
 rst - tapply(mydata$income, mydata$education, median)
 mydata$md - rst[mydata$education]
 head(mydata)
  income education  md
1  66223 e 55094.5
2  56830 c 54966.0
3  58035 b 54937.5
4  74045 a 55213.5
5  61327 b 54937.5
6  64150 b 54937.5

Is this what you wanted?

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dimitri Joe
Sent: Friday, June 17, 2005 10:01 AM
To: R-Help
Subject: [R] vectorization

Hi there,

I have a data frame (mydata) with 1 numeric variable (income) and 1
factor (education). I want a new column in this data with the median
income for each education level. A obviously inneficient way to do this
is

for ( k in 1: nrow(mydata) ){
l - mydata$education[k]
mydata$md[k] - median(mydata$income[mydata$education==l],na.rm=T)
}

Since mydata has nearly 30.000 rows, this will be done not untill the
end of this month. I thus need some help for vectorizing this, please.

Thanks,

Dimitri

[[alternative HTML version deleted]]






___ 

Instale o discador agora! http://br.acesso.yahoo.com/

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

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


Re: [R] vectorization

2005-06-17 Thread james . holtman




try this:

 x.1 - data.frame(income=runif(100)*1,
educ=sample(c('hs','col','none'),100,T))
 x.1
income educ
1   5930.30882  col
2   5528.83222   hs
3   5967.04041   hs
4   3926.30682   hs
5   2603.75924 none
...
 x.2 - tapply(x.1$income, x.1$educ, mean)
 x.2
 col   hs none
5575.310 4994.921 5481.962
 x.1$median - x.2[x.1$educ]
 x.1
income educ   median
1   5930.30882  col 5575.310
2   5528.83222   hs 4994.921
3   5967.04041   hs 4994.921
4   3926.30682   hs 4994.921
5   2603.75924 none 5481.962
6   7398.83325  col 5575.310
7265.06895   hs 4994.921
.


Jim
__
James HoltmanWhat is the problem you are trying to solve?
Executive Technical Consultant  --  Convergys Labs
[EMAIL PROTECTED]
+1 (513) 723-2929



   
  Dimitri Joe 
   
  [EMAIL PROTECTED]To:   R-Help 
r-help@stat.math.ethz.ch   
  .br cc:  
   
  Sent by: Subject:  [R] vectorization  
   
  [EMAIL PROTECTED] 
   
  ath.ethz.ch   
   

   

   
  06/17/2005 14:00  
   

   




Hi there,

I have a data frame (mydata) with 1 numeric variable (income) and 1 factor
(education). I want a new column in this data with the median income for
each education level. A obviously inneficient way to do this is

for ( k in 1: nrow(mydata) ){
l - mydata$education[k]
mydata$md[k] - median(mydata$income[mydata$education==l],na.rm=T)
}

Since mydata has nearly 30.000 rows, this will be done not untill the end
of this month. I thus need some help for vectorizing this, please.

Thanks,

Dimitri

 [[alternative HTML version deleted]]






___

Instale o discador agora! http://br.acesso.yahoo.com/

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

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


Re: [R] trim a string

2005-06-17 Thread Francisco J. Zagmutt
RSiteSearch(trim) will give you a lot of answers.  You cal also use the 
higher level function trim{R.oo} i.e.:

library(R.oo)
x=e  
trim(x)
[1] e


From: Omar Lakkis [EMAIL PROTECTED]
Reply-To: Omar Lakkis [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject: [R] trim a string
Date: Fri, 17 Jun 2005 13:34:36 -0400

How to trim the leading and trailing white space off of a string?

  If the variable is   E   I need to convert it to E.

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

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


Re: [R] trim a string

2005-06-17 Thread Prof Brian Ripley
Better code for this purpose is in example(grep).

`white space' and `a blank' are not necessarily the same thing.

On Fri, 17 Jun 2005, Liaw, Andy wrote:

 http://finzi.psych.upenn.edu/R/Rhelp02a/archive/14493.html

 Andy

 From: Omar Lakkis

 How to trim the leading and trailing white space off of a string?

  If the variable is   E   I need to convert it to E.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] vectorization

2005-06-17 Thread Rau, Roland
Hi,


 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Dimitri Joe
 Sent: Friday, June 17, 2005 7:01 PM
 To: R-Help
 Subject: [R] vectorization
 
 Hi there,
 
 I have a data frame (mydata) with 1 numeric variable (income) 
 and 1 factor (education). I want a new column in this data 
 with the median income for each education level. A obviously 
 inneficient way to do this is
 
I guess the attached code (incl. simulating your data structure) is not
the most efficient way to do this, but at least (I hope so!) it does
what you wanted it to do:


### Beginning of Example Code

income - runif(100)
education - as.factor(sample(c(high, middle, low),
size=length(income), replace=TRUE))
mydata - data.frame(inc=income, edu=education)


mymedians - tapply(X=mydata$inc, INDEX=mydata$edu, FUN=median)

mydata$medians - ifelse(mydata$edu==high, mymedians[high], 0)
mydata$medians - ifelse(mydata$edu==middle, mymedians[middle],
mydata$medians)
mydata$medians - ifelse(mydata$edu==low, mymedians[low],
mydata$medians)

head(mydata)
mymedians

### End of Example Code

Maybe one can increase the speed, but I think it is sufficient for your
case of 30,000 cases as you can see from the timing on my desktop
computer here (WinXP Pro SP2, P4, 3GHz, 512MB RAM):

 time.check - function(){
+   income - runif(3)
+   education - as.factor(sample(c(high, middle, low),
size=length(income), replace=TRUE))
+   mydata - data.frame(inc=income, edu=education)
+   
+   mymedians - tapply(X=mydata$inc, INDEX=mydata$edu, FUN=median)
+ 
+   mydata$medians - ifelse(mydata$edu==high, mymedians[high], 0)
+   mydata$medians - ifelse(mydata$edu==middle, mymedians[middle],
mydata$medians)
+   mydata$medians - ifelse(mydata$edu==low, mymedians[low],
mydata$medians)
+   return(NULL)
+ }
 system.time(time.check())
[1] 0.36 0.02 0.38   NA   NA
   
 version
 _  
platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status   beta   
major2  
minor1.0
year 2005   
month04 
day  04 
language R  


Best,
Roland


+
This mail has been sent through the MPI for Demographic Rese...{{dropped}}

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


Re: [R] trim a string

2005-06-17 Thread Mike R
 How to trim the leading and trailing white space off of a string?
 
  If the variable is   E   I need to convert it to E.

gsub('^[[:space:]]+', '',E )
gsub('[[:space:]]+$', '',E )

as in R-2.1.0/library/base/html/grep.html

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


Re: [R] Data comparison

2005-06-17 Thread Duncan Murdoch
On 6/17/2005 12:33 PM, [EMAIL PROTECTED] wrote:
 
 
 
 Question :  Is it possible to create a function, using a for ifelse
 function, inside sapply, to compare the values in one data frame to a set
 of upper and lower limits in another data frame, same number of columns.,
 Take  the values which meet the requirements TRUE  and create a new data
 frame or table containing the filtered data?   Can you give me a shove in
 the correct direction?  Thanks

I think you don't need a function within sapply.  You just want 
something like this:

  df1 - data.frame(x = runif(20))
  y - runif(20)
  df2 - data.frame(lower = y, upper = y + runif(20))
 
  df3 - cbind(df1, df2)
 
  df3[(df2$lower  df1$x)  (df1$x  df2$upper), ]
x lower upper
5  0.6688050 0.4357477 0.6786472
6  0.5608836 0.4649370 0.8596602
8  0.5109508 0.2654933 1.0573998
9  0.5966776 0.3035084 0.9834681
19 0.3787230 0.1894318 0.6783048
20 0.2826356 0.2321261 1.0913582

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


Re: [R] another aov results interpretation question

2005-06-17 Thread Spencer Graves
  I commend you to (a) the recent article by Doug Bates on Fitting 
nonlinear mixed models in R pp. 27-30 in the latest issue of R News 
available from www.r-project.org - Newsletter and (b) Doug's book 
with Pinheiro (2000) Mixed-Effects Models in S and S-PLUS (Springer).  I 
suggest you try the same analysis using in lmer, library(lme4), and 
lme, library(nlme), with method = ML, as explained in Pinheiro and 
Bates.  If you have trouble with this, please post another question on 
this, preferably using either a standard data set distributed with R or 
one of the standard packages or a very simple made-up data set with very 
few observations that you can distribute with your question in a short 
sequence of R commands illustrating something you tried that either 
didn't work or that gave results you don't understand.  I can't do much 
more with the example you've provided below, because I don't know how to 
access the your data.  (And PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html if you haven't already.)

  hope this helps.
  spencer graves

RenE J.V. Bertin wrote:

 Hello,
 
 I'm trying to understand how to interpret the differences in results between 
 two versions of a 2-factor ANOVA with (slightly?) different models, of an 
 observable y, a within-subject factor 'indep' and a grouping factor 'cond' 
 (and a subject 'factor' Snr):
 
 
summary( aov( y~cond + indep + Error(Snr/indep) ) )
 
 # example results:
 Error: Snr
   Df Sum Sq Mean Sq F value Pr(F)
 cond   1  103.1   103.1   1.425  0.248
 indep  5  159.832.0   0.442  0.813
 Residuals 18 1301.672.3   
 
 Error: Snr:indep
Df Sum Sq Mean Sq F value Pr(F)  
 indep   5  20.814.16   3.167 0.0104 *
 Residuals 111 145.891.31 
 ---
 Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
 
 Error: Within
Df Sum Sq Mean Sq F value Pr(F)
 Residuals 137 22.178   0.162   
 
 
summary( aov( y~cond * indep + Error(Snr/indep) ) )
 
 # example results:
 Error: Snr
Df Sum Sq Mean Sq F value Pr(F)
 cond1  174.6   174.6   1.689  0.213
 indep   5  201.940.4   0.391  0.848
 cond:indep  5  124.024.8   0.240  0.939
 Residuals  15 1550.8   103.4   
 
 Error: Snr:indep
 Df Sum Sq Mean Sq F value Pr(F)
 indep5  73.16   14.63   8.601  5e-07 ***
 cond:indep   5  21.324.26   2.507 0.0336 *  
 Residuals  125 212.641.70   
 ---
 Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
 
 Error: Within
Df Sum Sq Mean Sq F value Pr(F)
 Residuals 464  507.5 1.1   
 
 
 I would like to understand a bit better what the cond:indep line under the 
 second Error:Snr:indep can mean. If I understood correctly, this represents 
 some higher-order interaction, but not a real indep/cond interaction. What 
 I also do not grasp is why the indep effect's F and significance is so 
 different between the two models.
 Finally, what does it mean when significant effects are listed under the 
 Error:Within line?
 
 Is there a good resource available (web, or if not printed) which discusses 
 this kind of question in a way accessible to non statisticians? The last time 
 I checked, manuals like R for Psychologists do not really enter into this 
 level of detail...
 
 Thanks very much in advance,
 R. Bertin
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


[R] an operator for contains

2005-06-17 Thread Mike R
k = c(1:9)
if( length( which(k==3) ) ){ print(contained) }else{ print(not contained) }

is therre a simple way to test if a vector/list contains a particular value?

for example an operator, along the lines of: ==

more generally, is the a documentaion page that lists/describes all
such operators?

lastly, if you didn't know the answer to my question, how would you have
gone about searching for an answer?  I tried RSiteSearch() using various
terms, and I opened  R-2.1.0/library/base/html/00Index.html and searched
for various terms.

TIA

==
platform i686-pc-linux-gnu
arch i686 
os   linux-gnu
system   i686, linux-gnu  
status
major2
minor1.0  
year 2005 
month04   
day  18   
language R

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


Re: [R] an operator for contains

2005-06-17 Thread Huntsinger, Reid
Yes, %in% or is.element().

Reid Huntsinger

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mike R
Sent: Friday, June 17, 2005 4:32 PM
To: r-help@stat.math.ethz.ch
Subject: [R] an operator for contains


k = c(1:9)
if( length( which(k==3) ) ){ print(contained) }else{ print(not
contained) }

is therre a simple way to test if a vector/list contains a particular value?

for example an operator, along the lines of: ==

more generally, is the a documentaion page that lists/describes all
such operators?

lastly, if you didn't know the answer to my question, how would you have
gone about searching for an answer?  I tried RSiteSearch() using various
terms, and I opened  R-2.1.0/library/base/html/00Index.html and searched
for various terms.

TIA

==
platform i686-pc-linux-gnu
arch i686 
os   linux-gnu
system   i686, linux-gnu  
status
major2
minor1.0  
year 2005 
month04   
day  18   
language R

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

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


Re: [R] an operator for contains

2005-06-17 Thread Spencer Graves
  Does '?%in%' or '?match' meet your needs?

  spencer graves

Mike R wrote:

 k = c(1:9)
 if( length( which(k==3) ) ){ print(contained) }else{ print(not contained) 
 }
 
 is therre a simple way to test if a vector/list contains a particular value?
 
 for example an operator, along the lines of: ==
 
 more generally, is the a documentaion page that lists/describes all
 such operators?
 
 lastly, if you didn't know the answer to my question, how would you have
 gone about searching for an answer?  I tried RSiteSearch() using various
 terms, and I opened  R-2.1.0/library/base/html/00Index.html and searched
 for various terms.
 
 TIA
 
 ==
 platform i686-pc-linux-gnu
 arch i686 
 os   linux-gnu
 system   i686, linux-gnu  
 status
 major2
 minor1.0  
 year 2005 
 month04   
 day  18   
 language R
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] an operator for contains

2005-06-17 Thread Jonathan Baron
See match().  Also intersect().

The documentation for operators is, I think mostly at the top of
the index page for the base package, the one you searched.  The
relevant one is %in%.  I guess Value matching didn't ring the
right bell.

On 06/17/05 13:31, Mike R wrote:
 k = c(1:9)
 if( length( which(k==3) ) ){ print(contained) }else{ print(not contained) }
 
 is therre a simple way to test if a vector/list contains a particular value?
 
 for example an operator, along the lines of: ==
 
 more generally, is the a documentaion page that lists/describes all
 such operators?
 
 lastly, if you didn't know the answer to my question, how would you have
 gone about searching for an answer?  I tried RSiteSearch() using various
 terms, and I opened  R-2.1.0/library/base/html/00Index.html and searched
 for various terms.
 
 TIA
 
 ==
 platform i686-pc-linux-gnu
 arch i686
 os   linux-gnu
 system   i686, linux-gnu
 status
 major2
 minor1.0
 year 2005
 month04
 day  18
 language R
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron

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


Re: [R] an operator for contains

2005-06-17 Thread Arne Henningsen
%in%

R k - 1:9
R 3 %in% k
[1] TRUE
R 33 %in% k
[1] FALSE

Arne

On Friday 17 June 2005 22:31, Mike R wrote:
 k = c(1:9)
 if( length( which(k==3) ) ){ print(contained) }else{ print(not
 contained) }

 is therre a simple way to test if a vector/list contains a particular
 value?

 for example an operator, along the lines of: ==

 more generally, is the a documentaion page that lists/describes all
 such operators?

 lastly, if you didn't know the answer to my question, how would you have
 gone about searching for an answer?  I tried RSiteSearch() using various
 terms, and I opened  R-2.1.0/library/base/html/00Index.html and searched
 for various terms.

 TIA

 ==
 platform i686-pc-linux-gnu
 arch i686
 os   linux-gnu
 system   i686, linux-gnu
 status
 major2
 minor1.0
 year 2005
 month04
 day  18
 language R

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

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

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


Re: [R] an operator for contains

2005-06-17 Thread Sarah Goslee
On 6/17/05, Mike R [EMAIL PROTECTED] wrote:
 k = c(1:9)
 if( length( which(k==3) ) ){ print(contained) }else{ print(not contained) 
 }
 
 is therre a simple way to test if a vector/list contains a particular value?

Yes, several. Here's one:
k - 1:9
if(any(k == 3)) {
cat(is an element\n) } else {
cat(not an element\n) }

I don't recommend that for floating point numbers, though.

 more generally, is the a documentaion page that lists/describes all
 such operators?

help(==) would get you the help page for the actual binary
operators. Since any() isn't an operator, that won't help.

 lastly, if you didn't know the answer to my question, how would you have
 gone about searching for an answer? 

There are a variety of ways to find answers in R, although if you
aren't certain what your keyword should be, it may take a few tries.

help(), help.search(), and apropos() may all be useful.

Sarah

-- 
Sarah Goslee
http://www.stringpage.com

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


Re: [R] an operator for contains

2005-06-17 Thread Thomas Lumley
On Fri, 17 Jun 2005, Mike R wrote:

 k = c(1:9)
 if( length( which(k==3) ) ){ print(contained) }else{ print(not contained) 
 }

 is therre a simple way to test if a vector/list contains a particular value?

  value %in% vector

 more generally, is the a documentaion page that lists/describes all
 such operators?

No.  You can find binary operators fairly effectively by looking at the 
html help, because they have to have non-alphabetic names (either single 
characters or beginning and ending with %).

However, there are functions such as setdiff() that you might think of as 
binary operators that you wouldn't find this way.

-thomas

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


[R] adjusted R^2 vs. ordinary R^2

2005-06-17 Thread James Salsman
I thought the point of adjusting the R^2 for degrees of
freedom is to allow comparisons about goodness of fit between
similar models with different numbers of data points.  Someone
has suggested to me off-list that this might not be the case.

Is an ADJUSTED R^2 for a four-parameter, five-point model
reliably comparable to the adjusted R^2 of a four-parameter,
100-point model?  If such values can't be reliably compared
with one another, then what is the reasoning behind adjusting
R^2 for degrees of freedom?

What are the good published authorities on this topic?

Sincerely,
James Salsman

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


[R] 3D Scatter Plot

2005-06-17 Thread Lauren, Peter
Hello:

 

I would like to be able to do a 3D scatter plot from 3 variables, 2
independent and 1 dependent.  The closest R function I could find for
this is cloud.  However cloud uses, as input, a matrix where the value
of each matrix element is the dependent variable value at that matrix
coordinate.  My problem is that the independent variable values are
floating point and can be of any value.  Consequently some of the matrix
bins may not have a value assigned.  An example of the sort of data I
may have is as follows

 

Independent 1  Independent 2Dependent

0.145674 0.526482534  1.676986

0.325634 0.326385237  2.384384

0.235267 0.352653288  0.356483

 

Is there any way to do a 3D scatter plot with this sort of data?

 

Thanks very much in advance,

Peter Lauren.

 


[[alternative HTML version deleted]]

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


Re: [R] an operator for contains

2005-06-17 Thread Mike R
wow.  thanks everyone for the multitude of suggestions !

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


Re: [R] adjusted R^2 vs. ordinary R^2

2005-06-17 Thread Peter Dalgaard
James Salsman [EMAIL PROTECTED] writes:

 I thought the point of adjusting the R^2 for degrees of
 freedom is to allow comparisons about goodness of fit between
 similar models with different numbers of data points.  Someone
 has suggested to me off-list that this might not be the case.
 
 Is an ADJUSTED R^2 for a four-parameter, five-point model
 reliably comparable to the adjusted R^2 of a four-parameter,
 100-point model?  If such values can't be reliably compared
 with one another, then what is the reasoning behind adjusting
 R^2 for degrees of freedom?


Well, the adjusted R^2 is the percent variance explained by
covariates. So it compares the conditional variance (given covariates)
to the marginal variance. This is less sensitive to DF issues than the
usual R^2, but it does still require that both quantities make sense.
This is not a given, and in particular the R^2 (either one) is quite
dubious when the covariates are chosen by design.

 
 What are the good published authorities on this topic?

Dunno. Common sense should really suffice in this matter.


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

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


Re: [R] axis labels vertically

2005-06-17 Thread Mike R
  2. I wasn't aware that there is an online-help. (was using the
 tutorial on the web, which is nat at all detailed.
  
help(), help.search(), and apropos() may all be useful.(thanks Sarah !!)

and RSiteSearch()

You might find this handy too 

example(axis)(thanks Brian !!)

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


Re: [R] axis labels vertically

2005-06-17 Thread Mike R
   2. I wasn't aware that there is an online-help. (was using the
  tutorial on the web, which is nat at all detailed.
 
 help(), help.search(), and apropos() may all be useful.(thanks Sarah !!)
 
 and RSiteSearch()
 
 You might find this handy too
 
 example(axis)(thanks Brian !!)


forgot to mention .

there are a number of excellent contributed tutorials here:

   http://cran.r-project.org/other-docs.html

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


[R] one factor multiple level anova

2005-06-17 Thread Lei Jiang
I am having trouble figuring out this one.

I want to do a one way anvoa with 13 levels. mydata is in a vector with 
length 65. each level has 5 repeats. but it contains NA.

I made mygroup-gl(13, 5, 65, labels=(...))

anova(lm(mydata ~ mygroup))

it gives following error:
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
 invalid variable type

Can you please help?? Millions of thanks.

Lei Jiang

Department of Chemsitry
University of Washington
Box 351700
Seattle, WA 98195
Phone: 206-616-6882
Fax: 206-685-8665

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


[R] aggregate?

2005-06-17 Thread alex diaz
Dear all:

Here is my problem:

Example data:
dat-data.frame(x=rep(c(a,b,c,d),2),y=c(10:17))

If I wanted to aggregate each level of column dat$x I 
could use:
aggregate(dat$y,list(x=dat$x),sum)

But I just want to aggregate two levels (?c? and ?d?) 
to obtain a new level  ?e?
I am expecting something like:

  x  y
1 a 10
2 b 11
3 e 25
4 a 14
5 b 15
6 e 33


How can I make it?
Thanks in advance and best for all

A. Diaz



-
Email Enviado utilizando o servio MegaMail

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

[R] hist single block plot issue

2005-06-17 Thread ap

# CASE 1
# The following plots a single cell or block for all three location 0,1,2.
y - rep(2,8)
hist(y)# why is this a single block?
hist(y,xlim=c(0,2))# same thing
hist(y,breaks=2)   # same

# CASE 2
# adding a different value, plots as expected
y - append(y,0)
hist(y)# plots as expected


In most cases of the data I have variances in the data so this is not an
issue. In some situations case #1 appears and I would like to 
differentiate it among the other values.

Thanks

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


Re: [R] one factor multiple level anova

2005-06-17 Thread Guohui Ding
Test that:
mydata - as.numeric(mydata)
anova(lm(mydata ~ mygroup))

2005/6/18, Lei Jiang [EMAIL PROTECTED]:
 
 I am having trouble figuring out this one.
 
 I want to do a one way anvoa with 13 levels. mydata is in a vector with
 length 65. each level has 5 repeats. but it contains NA.
 
 I made mygroup-gl(13, 5, 65, labels=(...))
 
 anova(lm(mydata ~ mygroup))
 
 it gives following error:
 Error in model.frame(formula, rownames, variables, varnames, extras,
 extranames, :
 invalid variable type
 
 Can you please help?? Millions of thanks.
 
 Lei Jiang
 
 Department of Chemsitry
 University of Washington
 Box 351700
 Seattle, WA 98195
 Phone: 206-616-6882
 Fax: 206-685-8665
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 



-- 
ADDRESS: Bioinformatics Center, Shanghai Institutes for Biological Sciences, 
Chinese Academy of Sciences
320 Yueyang Road, Shanghai 200031, P.R.China
TELEPHONE: 86-21-54920086

[[alternative HTML version deleted]]

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


Re: [R] 3D Scatter Plot

2005-06-17 Thread Deepayan Sarkar
On 6/17/05, Lauren, Peter [EMAIL PROTECTED] wrote:
 Hello:
 
 
 
 I would like to be able to do a 3D scatter plot from 3 variables, 2
 independent and 1 dependent.  The closest R function I could find for
 this is cloud.  However cloud uses, as input, a matrix where the value
 of each matrix element is the dependent variable value at that matrix
 coordinate.  

What makes you think that?

 My problem is that the independent variable values are
 floating point and can be of any value.  Consequently some of the matrix
 bins may not have a value assigned.  An example of the sort of data I
 may have is as follows
 
 
 
 Independent 1  Independent 2Dependent
 
 0.145674 0.526482534  1.676986
 
 0.325634 0.326385237  2.384384
 
 0.235267 0.352653288  0.356483
 
 
 
 Is there any way to do a 3D scatter plot with this sort of data?

The following should work fine:

df - 
data.frame(x = c(0.145674, 0.325634, 0.235267),
   y = c(0.526482534, 0.326385237, 0.352653288),
   z = c(1.676986, 2.384384, 0.356483))

cloud(z ~ x * y, df)

Deepayan

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


Re: [R] hist single block plot issue

2005-06-17 Thread Guohui Ding
In case #1, the argument 'breaks' can break the histogram cells:
hist(y, breaks=c(0, 0.5, 1.0, 1.5, 2.0)) # not the same ^_^

2005/6/18, ap [EMAIL PROTECTED]:
 
 
 # CASE 1
 # The following plots a single cell or block for all three location 0,1,2.
 y - rep(2,8)
 hist(y) # why is this a single block?
 hist(y,xlim=c(0,2)) # same thing
 hist(y,breaks=2) # same
 
 # CASE 2
 # adding a different value, plots as expected
 y - append(y,0)
 hist(y) # plots as expected
 
 In most cases of the data I have variances in the data so this is not an
 issue. In some situations case #1 appears and I would like to
 differentiate it among the other values.
 
 Thanks
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 



-- 
ADDRESS: Bioinformatics Center, Shanghai Institutes for Biological Sciences, 
Chinese Academy of Sciences
320 Yueyang Road, Shanghai 200031, P.R.China
TELEPHONE: 86-21-54920086

[[alternative HTML version deleted]]

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


Re: [R] aggregate?

2005-06-17 Thread Gabor Grothendieck
On 6/17/05, alex diaz [EMAIL PROTECTED] wrote:
 Dear all:
 
 Here is my problem:
 
 Example data:
 dat-data.frame(x=rep(c(a,b,c,d),2),y=c(10:17))
 
 If I wanted to aggregate each level of column dat$x I
 could use:
 aggregate(dat$y,list(x=dat$x),sum)
 
 But I just want to aggregate two levels (c and d)
 to obtain a new level  e
 I am expecting something like:
 
  x  y
 1 a 10
 2 b 11
 3 e 25
 4 a 14
 5 b 15
 6 e 33


In the example 
- dat$y[3:4] are summed and 
- dat$y[7:8] are summed 
so we assume that what is being requested is that d is to
be replaced by c and runs of any level are to be summed.

To do that:
- create xx such that a, b, c and d in dat$x are replaced with
  with 1, 2, 3 and 3 in xx.  
- in the second statement calculate a running sum except if the 
  last observation was the same as the current observation then 
  the Last Observation is Carried Forward (locf) so that all entries 
  in a run have the same number. e.g. in this case locf is
  c(1, 2, 3, 3, 4, 5, 6, 6)
- Finally the 'by' collapses dat using locf rbinds the
  resulting rows together to create a data frame.

xx - ifelse(dat$x == d, 3, dat$x)
locf - cumsum(c(TRUE, xx[-1] != xx[-length(xx)]))
f - function(x) data.frame(x=x[1,1], y=sum(x[,2]))
dat2 - do.call(rbind, by(dat, locf, f))

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