Re: [R] what does this err mean and how to solve it? Error in file(file, ifelse(append, a, w))

2010-10-07 Thread Prof Brian Ripley

On Wed, 6 Oct 2010, Peter Langfelder wrote:


you should close files that you do not use anymore. the maximum number
of open files is likely 4000 or so. Use close(file) before you open
the next one.


He/she said he did that, and as the limit on open connections is 128, 
that cannot be the sole cause.


Without even the 'at a mimimum information' requested in the posting 
guide let alone a reproducible example it is not possible to know the 
cause. But most OSes have utilities available to trace the 
opening/closing of files.  (We weren't told but this looks like 
Windows -- there I have used the monitors from sysinternals, now part 
of Microsoft.)


And BTW, the subject line omitted the associated warning which gives 
the underlying OS-level error -- that would have been a much better 
choice of subject.




Peter

On Wed, Oct 6, 2010 at 4:55 PM, Yong Wang wangyo...@gmail.com wrote:

Dear List
I am running a loop downloading  web pages and save the html to a
temporary file (use download.file() )
 then read (using readLines)  it in for processing;
finally write useful info from each processed page to a unique file

the problem is once the loop runs up to somewhere near  5000, it will
throw out an err like below and won't go further.


Error in file(file, ifelse(append, a, w)) :
 cannot open the connection
-

In the meantime, a request for new connection won't be successful, for
example, a request for the help page of file will trigger err below

---
 ?file
Error in gzfile(file, rb) : cannot open the connection
In addition: Warning message:
In gzfile(file, rb) :
 cannot open compressed file
'C:/PROGRA~1/R/R-211~1.1/library/stats/help/aliases.rds', probable
reason 'Too many open files'
---

I am not sure if the problem is too many connections not closed. since
I close the file connection after each readLines.
checking with showConnections(all=T) does not show excessive
connections and closeAllConnections() does not help.

Can any one help me on this?


Any answer highly appreciated.

yong

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



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



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


[R] Odp: Vector replace 0 elements without using a loop

2010-10-07 Thread Petr PIKAL
Hi


r-help-boun...@r-project.org napsal dne 07.10.2010 07:16:01:

 
 Hi,
 
 With a vector like:
 
 x = c (22, 23, 22.5, 0,0,24, 0, 23.2, 23.5, 0,0,0, 26)
 
 How can I replace the 0's with the previous last value without looping
 through the vector ?

Change your zeroes to NA values
x[x==0]-NA

use na.locf function from zoo package

library(zoo)

x-na.locf(x)

Regards
Petr


 
 Something tells me I am missing the obvious.
 
 Thanks,
 Chris
 -- 
 View this message in context: 
http://r.789695.n4.nabble.com/Vector-replace-0-
 elements-without-using-a-loop-tp2966191p2966191.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Quantile question

2010-10-07 Thread Henrik Bengtsson
Alternatively,

see rowQuantiles() in the matrixStats package.

/Henrik

On Wed, Oct 6, 2010 at 10:34 PM, Joshua Wiley jwiley.ps...@gmail.com wrote:
 Hi,

 This should do it, for details, see ?apply

 a - matrix(rnorm(1),100,100)
 t(apply(a, 1, quantile, probs = c(.3, .5)))

 Basically you apply() the quantile function to each row (the 1, 2
 would indicate columns) in the object 'a'.

 HTH,

 Josh

 On Wed, Oct 6, 2010 at 10:20 PM, Takos zyou...@gmail.com wrote:

 Simple Question

 I have 100x100 matrix and I want to calculte each row's 30,50% quantile

 ex)

 a=matrix(rnorm(1),100,100)
 quantile(a[1,],c(0.3,0.5))
 quantile(a[2,],c(0.3,0.5))
 .
 .
 .
 .


 I want get results at once.

 so I try quantile(a[1:100,],c(0.3,0.5)) but I can get what I exactly want.

 How can I calculte that?





 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Quantile-question-tp2966195p2966195.html
 Sent from the R help mailing list archive at Nabble.com.

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




 --
 Joshua Wiley
 Ph.D. Student, Health Psychology
 University of California, Los Angeles
 http://www.joshuawiley.com/

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


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


Re: [R] Linear Integration

2010-10-07 Thread alaios

No, because I thought something that might be easier.
If you see the image again you might notice that the proportions I am
looking for might also be found by using the hypotenuse which is the same
(as all squares are triangles) by finding the adjacent. The adjacent are
easier to be found by tracking when the x value changes.

This happens when the x value increments by one and when y also increments
by one. As I know the line equation y=a*x+b it is very easy all these
points.
Then it is straightforward to find the proportion of these vectors?

Best Regards
Alex
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Linear-Integration-tp2956145p2966318.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] what is the NOT IN operator

2010-10-07 Thread Ivan Calandra

 Hi,

I've just seen yesterday on ?plotmath the operator %notin%.
This could also work I guess.

Ivan

Le 10/7/2010 07:41, bill.venab...@csiro.au a écrit :

Try !(group %in% C(A, ...))

A slightly cuter way is to define your own operator.


`%ni%`- Negate(`%in%`)
letters[1:3] %ni% letters[3:5]

[1]  TRUE  TRUE FALSE


From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Emily Deomano [edeom...@bses.com.au]
Sent: 07 October 2010 09:17
To: r-help@r-project.org
Subject: [R] what is the NOT IN operator

Good day,
I need to subset a data by removing several rows.  I know the %in% operator, 
i.e.

sub- mydata[group %in% c(A,B,E,G), ]

What I need is the opposite, that is remove rows and/or columns.  What is the operator for 
NOT IN?  I tried  (i)! %in% and (ii) ^%in% and both resulted in a could not find 
function error.


Kind Regards

Emily Deomano  |  Biometrician
BSES Limited  |  ABN 29 103 760 005  |  PO Box 86  |  50 Meiers Road  |  
Indooroopilly Q 4068 Australia
P:  +61 7 3331 3304  |  M: +61 408 656 452  |  F: +61 7 3871 0383  |  E: 
edeom...@bses.com.aumailto:edeom...@bses.com.au   |  W: bses.com.au


 Internet e-Mail Disclaimer 

PRIVILEGED - PRIVATE AND CONFIDENTIAL: This email and any files transmitted 
with it are intended solely for the use of the addressee(s) and may contain 
information, which is confidential or privileged. If you are not the intended 
recipient, be aware that any disclosure, copying, distribution, or use of the 
contents of this information is prohibited. In such case, you should destroy 
this message and kindly notify the sender by reply e-mail. The views and 
opinions expressed in this e-mail are those of the sender and do not 
necessarily reflect the views of the company.

VIRUSES:  Email transmission cannot be guaranteed to be secure or error free, 
as information may be intercepted, corrupted, lost, destroyed, arrive late or 
incomplete or contain viruses. This email and any files attached to it have 
been checked with virus detection software before transmission. You should 
nonetheless carry out your own virus check before opening any attachment. BSES 
Limited does not represent or warrant that files attached to this email are 
free from computer viruses or other defects and accepts no liability for any 
loss or damage that may be caused by software viruses

 [[alternative HTML version deleted]]

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

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



--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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


Re: [R] Linear Integration

2010-10-07 Thread Michael Bedward
Um... if that makes sense for the analysis that you're trying to do
then that's great. I had assumed that you were using the term
integral in its usual sense, ie. area under the curve.

Michael

On 7 October 2010 18:52, alaios ala...@yahoo.com wrote:

 No, because I thought something that might be easier.
 If you see the image again you might notice that the proportions I am
 looking for might also be found by using the hypotenuse which is the same
 (as all squares are triangles) by finding the adjacent. The adjacent are
 easier to be found by tracking when the x value changes.

 This happens when the x value increments by one and when y also increments
 by one. As I know the line equation y=a*x+b it is very easy all these
 points.
 Then it is straightforward to find the proportion of these vectors?

 Best Regards
 Alex
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Linear-Integration-tp2956145p2966318.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


[R] Problem Fixed

2010-10-07 Thread ogbos okike
Hey Duncan,
Thank so much for the site. Quite helpful. Containing everything and
informing me that raster has got no older version.
I have also installed the new R version and I am fine.
Regards
Ogbos
On 5 October 2010 15:11, Duncan Murdoch murdoch.dun...@gmail.com wrote:

  On 05/10/2010 9:00 AM, ogbos okike wrote:

 Hello,
 The R version on my  system is R version 2.8.1 (2008-12-22).  I have
 previously installed all the desired packages  for my work - and they have
 been working fine. However, somebody played with my system and removed
 almost all the stuff. I am installing the packages again.

 But I am finding some packages (such as, sp, rgdal, raster, etc) hard to
 install. Some of the error messages indicate that 2.8.1 is old and that
 the
 package requires 2.10.0.

 I have tried to upgrade to 2.10.0 or to the newest release but without
 luck.
 I am now considering reinstalling R ( and then reinstall all the removed
 packages).

 Could you please advise if  this has any negative implications the R
 package
 or if I have any better option as to handle this problem?



 I would install the current release of R.  Version 2.8.1 is quite old, and
 likely nobody will support you on it.

 You can get old copies of packages from the CRAN archives 
 http://cran.r-project.org/src/contrib/Archive/ if you do decide to stick
 with an obsolete version, but I don't know a simple way to find the best
 combination of package versions for 2.8.1.

 Duncan Murdoch


[[alternative HTML version deleted]]

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


[R] filter data.frame

2010-10-07 Thread behave

hi all,

how do I filter a dataframe.

What I am looking for is something like:

data-data.frame(matrix(c(2,2,1,2,2,2,2,2,3),byrow=TRUE,ncol=3))
subset(data, subset=(X3==3  X2==2  X1==2))

thanks
 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/filter-data-frame-tp2966377p2966377.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] tapply output

2010-10-07 Thread Peter Ehlers

On 2010-10-06 13:24, Erik Iverson wrote:

Hello,

You can use ddply from the very useful plyr package to do this.
There must be a way using base R functions, but plyr is
worth looking into in my opinion.

install.packages(plyr)
library(plyr)
ddply(myData, .(class, group, name), function(x) mean(x$height))

class group name   V1
1 0 A  Tom 62.5
2 0 B Jane 58.5
3 1 A Enzo 66.5
4 1 B Mary 70.5


Or use summarize:

   ddply(myData, .(class, group, name), summarize, mht = mean(height))

  -Peter Ehlers



Geoffrey Smith wrote:

Hello, I am having trouble getting the output from the tapply function
formatted so that it can be made into a nice table.  Below is my question
written in R code.  Does anyone have any suggestions?  Thank you.  Geoff

#Input the data;
name- c('Tom', 'Tom', 'Jane', 'Jane', 'Enzo', 'Enzo', 'Mary', 'Mary');
year- c(2008, 2009, 2008, 2009, 2008, 2009, 2008, 2009);
group- c('A', 'A', 'B', 'B', 'A', 'A', 'B', 'B');
class- c(0, 0, 0, 0, 1, 1, 1, 1);
height- c(62, 63, 59, 58, 67, 66, 70, 71);

#Combine the data into a data frame;
myData- data.frame(name, year, group, class, height);
myData;

#Calculate the mean of height by class, group, and name;
tapply(myData$height, data.frame(myData$class, myData$group, myData$name),
mean);

#The raw output from the tapply function is fine, but I would;
#really like the output to look like this;
#  class   group name mean
#0   ATom62.5
#0   BJane58.5
#1   AEnzo   66.5
#1   BMary   70.5



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


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


Re: [R] filter data.frame

2010-10-07 Thread Ivan Calandra

 Hi,

Try this:
subset(data, subset=(X3==3  X2==2  X1==2))
  X1 X2 X3
3  2  2  3

First, you have numerical values, so don't quote them.
Second, take a look at ? to understand the difference between  and .

HTH,
Ivan


Le 10/7/2010 10:43, behave a écrit :

hi all,

how do I filter a dataframe.

What I am looking for is something like:

data-data.frame(matrix(c(2,2,1,2,2,2,2,2,3),byrow=TRUE,ncol=3))
subset(data, subset=(X3==3  X2==2  X1==2))

thanks




--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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


[R] Rserve config

2010-10-07 Thread Joel

Dont know if this is the right forum for this but here we go.

Trying to figure out where I should put the Rserv.conf file in windows,
anyone have any idea?

//Joel
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Rserve-config-tp2966394p2966394.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] filter data.frame

2010-10-07 Thread behave

Thanks, works perfectly
-- 
View this message in context: 
http://r.789695.n4.nabble.com/filter-data-frame-tp2966377p2966398.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] hclust with method = “ward”

2010-10-07 Thread Christian Hennig

On Wed, 6 Oct 2010, PeterB wrote:


Thanks, Christian. This is really helpful.

I was not aware of that equality, but now I can see it. I think you mean the
inner sum over all distances in the distance matrix (for that cluster),
which means that each distance is counted twice (which is why we divide by
2).


That's probably how to explain it... you can obviuously check it by 
writing the whole thing down, which is how I did it. (The formula is in 
Bock's old book on Automatische Klassifikation, but that's in German.)


Christian



Peter


Christian Hennig wrote:


The k-means/Ward criterion can be written down in terms of squared
Euclidean distances in a way that doesn't involve means. It is half the
sum (over all clusters) of the sum (over all observations in a
cluster) of all within-cluster squared dissimilarities, the inner sum
divided by the cluster size. This can also be computed for a general
dissimilarity matrix (this is for example done by cluster.stats in
package fpc).

I'd guess that hclust with method=ward uses this when run with a general
dissimilarity matrix. At least it would make sense, although I'm not sure
whether it really is what hclust does, because I didn't check the
underlying Fortran code.

Note that I may have missed postings in this thread, so sorry if this
doesn't add to what you already have worked out.

Christian

On Wed, 6 Oct 2010, PeterB wrote:



Apparently, the same issue exists in SAS, where there is an option to run
the
Ward algorithm based only on the distance matrix. Perhaps, a SAS user
could
confirm that or even check with SAS.

Peter

--
View this message in context:
http://r.789695.n4.nabble.com/hclust-with-method-ward-tp2952140p2965310.html
Sent from the R help mailing list archive at Nabble.com.

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



*** --- ***
Christian Hennig
University College London, Department of Statistical Science
Gower St., London WC1E 6BT, phone +44 207 679 1698
chr...@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche

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



--
View this message in context: 
http://r.789695.n4.nabble.com/hclust-with-method-ward-tp2952140p2966045.html
Sent from the R help mailing list archive at Nabble.com.

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



*** --- ***
Christian Hennig
University College London, Department of Statistical Science
Gower St., London WC1E 6BT, phone +44 207 679 1698
chr...@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche

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


[R] debugging

2010-10-07 Thread Maas James Dr (MED)
I'm attempting to learn how to use the debug function to find the values of 
some variables.  I've found a couple of documents describing the basics and 
they show examples that the debugger returns

Browse[1]


but for some reason when I follow the examples I get

Browse[2]


What is the 2 telling me ... why am I getting it and does it matter?

Thanks

J

===
Dr. Jim Maas
University of East Anglia


[[alternative HTML version deleted]]

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


Re: [R] what is the NOT IN operator

2010-10-07 Thread Duncan Murdoch

On 07/10/2010 4:10 AM, Ivan Calandra wrote:

  Hi,

I've just seen yesterday on ?plotmath the operator %notin%.
This could also work I guess.


No, that's just a way to encode the symbol for not an element of. 
It's not actually an operator that works outside of plotmath (though you 
could make it one, as others have shown...)


Duncan Murdoch



Ivan

Le 10/7/2010 07:41, bill.venab...@csiro.au a écrit :

Try !(group %in% C(A, ...))

A slightly cuter way is to define your own operator.


`%ni%`- Negate(`%in%`)
letters[1:3] %ni% letters[3:5]

[1]  TRUE  TRUE FALSE


From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Emily Deomano [edeom...@bses.com.au]
Sent: 07 October 2010 09:17
To: r-help@r-project.org
Subject: [R] what is the NOT IN operator

Good day,
I need to subset a data by removing several rows.  I know the %in% operator, 
i.e.

sub- mydata[group %in% c(A,B,E,G), ]

What I need is the opposite, that is remove rows and/or columns.  What is the operator for 
NOT IN?  I tried  (i)! %in% and (ii) ^%in% and both resulted in a could not find 
function error.


Kind Regards

Emily Deomano  |  Biometrician
BSES Limited  |  ABN 29 103 760 005  |  PO Box 86  |  50 Meiers Road  |  
Indooroopilly Q 4068 Australia
P:  +61 7 3331 3304  |  M: +61 408 656 452  |  F: +61 7 3871 0383  |  E: 
edeom...@bses.com.aumailto:edeom...@bses.com.au   |  W: bses.com.au


 Internet e-Mail Disclaimer 

PRIVILEGED - PRIVATE AND CONFIDENTIAL: This email and any files transmitted 
with it are intended solely for the use of the addressee(s) and may contain 
information, which is confidential or privileged. If you are not the intended 
recipient, be aware that any disclosure, copying, distribution, or use of the 
contents of this information is prohibited. In such case, you should destroy 
this message and kindly notify the sender by reply e-mail. The views and 
opinions expressed in this e-mail are those of the sender and do not 
necessarily reflect the views of the company.

VIRUSES:  Email transmission cannot be guaranteed to be secure or error free, 
as information may be intercepted, corrupted, lost, destroyed, arrive late or 
incomplete or contain viruses. This email and any files attached to it have 
been checked with virus detection software before transmission. You should 
nonetheless carry out your own virus check before opening any attachment. BSES 
Limited does not represent or warrant that files attached to this email are 
free from computer viruses or other defects and accepts no liability for any 
loss or damage that may be caused by software viruses

 [[alternative HTML version deleted]]

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

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





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


Re: [R] debugging

2010-10-07 Thread Duncan Murdoch

On 07/10/2010 6:09 AM, Maas James Dr (MED) wrote:

I'm attempting to learn how to use the debug function to find the values of 
some variables.  I've found a couple of documents describing the basics and 
they show examples that the debugger returns

Browse[1]


but for some reason when I follow the examples I get

Browse[2]


What is the 2 telling me ... why am I getting it and does it matter?


It is a measure of depth of some sort.  I think it is supposed to be how 
deep you are into nested calls to the browser, but it seems to count 
each invocation twice.  (If you call the same debugged function from 
within the browser, you'll probably see [4].)  I imagine it's a bug, but 
it's a relatively harmless one.


Duncan Murdoch

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


[R] quantile regression

2010-10-07 Thread Julia Lira

Dear all,

 

I am a new user in r and I am facing some problems with the quantile regression 
specification. I have two matrix (mresultb and mresultx) with nrow=1000 and 
ncol=nsim, where I specify (let's say) nsim=10. Hence, the columns in my matrix 
represents each simulation of a determined variable. I need to regress each 
column of mresultb on mresultx. My codes are the following:

 

set.seed(180185)
nsim - 10
mresultx - matrix(-99, nrow=1000, ncol=nsim)
mresultb - matrix(-99, nrow=1000, ncol=nsim)
for (i in 1:nsim){
# make a matrix with 5 cols of N random uniform values
N - 200
I - 5
u - replicate( 5, runif(N, 0, 1) )
# fit matrix u in another matrix of 1 column 
mu - matrix(u, nrow=1000, ncol=1)
# make auction-specific covariate
x - runif(N, 0, 1)
mx - matrix(rep(x,5), nrow=1000, ncol=1)
b0 - matrix(rep(c(1),1000), nrow=1000, ncol=1)
#function for private cost
c - b0+b0*mx+mu
#bidding strategy
b - mx+((I+1)/I)+((I-1)/I)*mu  
mresultb[,i] - b
mresultx[,i] - mx
qf05 - rq(formula = mresultb[,i] ~ mresultx[,i], tau=0.5)
M - coef(qf05)
} 


But I just can see the quantile regression coefficients for 1 simulation, not 
for each i. 

Maybe this is a stupid question, but i am not so familiar with this software 
yet.

 

Thanks in advance!

 

Julia  
  
[[alternative HTML version deleted]]

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


[R] text/mtext axis labels on graphs

2010-10-07 Thread Martin Hughes


Hello everyone

I have problem with axis labels on graphs, I have my code as below:

plot(0,0,xlim=c(1,ncol(PA)),ylim=c(1,nrow(PA)),main=Stratigraphic  
Range,xlab=Time  
Bins,ylab=Taxa,cex.axis=1.5,cex.lab=2,cex.main=2.5,mgp=c(5,1.5,0),xaxt=n)


text(1:(length(strat_name)), y=  0, adj=1,  
srt=45,labels=strat_name,xpd=TRUE, cex=1) #adds text to x axis giving  
the strat names

abline(v=(1:ncol(PA))+.5,col=grey,lty=3)

cl - rep(1,nrow(PA))
cl[DistM$kill] - 2
for (i in 1:nrow(PA)) segments(min(which(PA[i,]==1))-.5,i,  
max(which(PA[i,]==1))+.5,i,lwd=3,col=cl[i])



My problem lies with the x axis tick labels, I want my own labels  
added in so removed the one the plot function adds in normally.


I use the text function as it allows me to fit my own text tick labels  
at an angle, HOWEVER the text function is VERY sensitive to the Y  
axis, I have multiple graphs on a page, each with a different y axis,  
so the labels move up and down depending on the scale of the Y.



I tried using mtext which lets you put the text a certain distance  
from the x margin line, HOWEVER this function does not let you tilt  
the text to be an an angle



Can anyone tell me of a way I can have both - ie text that is a  
specified distance from the margin AND tilted at and angle


Thanks
Martin




--
Martin Hughes
MPhil/PhD Research in Biology
Rm 1.07,  4south
University of Bath
Department of Biology and Biochemistry
Claverton
BathBA2 7AY
Tel: 01225 385 437
m.hug...@bath.ac.uk
http://www.bath.ac.uk/bio-sci/biodiversity-lab/hughes.html

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


[R] Linux 64-bit R installation problem - Failed dependencies

2010-10-07 Thread noclue_

I am trying to install 64 bit R on Linux.  But I got the following error -  


rpm -i R-core-2.10.0-2.fc11.x86_64.rpm

warning: R-core-2.10.0-2.fc11.x86_64.rpm: Header V3 DSA signature: NOKEY,
key ID 97d3544e
error: Failed dependencies:
/bin/bash is needed by R-core-2.10.0-2.fc11.x86_64
/bin/sh is needed by R-core-2.10.0-2.fc11.x86_64
/sbin/ldconfig is needed by R-core-2.10.0-2.fc11.x86_64
/usr/bin/perl is needed by R-core-2.10.0-2.fc11.x86_64
cups is needed by R-core-2.10.0-2.fc11.x86_64
gawk is needed by R-core-2.10.0-2.fc11.x86_64
ld-linux-x86-64.so.2()(64bit) is needed by
R-core-2.10.0-2.fc11.x86_64
ld-linux-x86-64.so.2(GLIBC_2.2.5)(64bit) is needed by
R-core-2.10.0-2.fc11.x86_64
less is needed by R-core-2.10.0-2.fc11.x86_64
libICE.so.6()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libSM.so.6()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libX11.so.6()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libXmu.so.6()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libXt.so.6()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libbz2.so.1()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libc.so.6()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libc.so.6(GLIBC_2.2.5)(64bit) is needed by
R-core-2.10.0-2.fc11.x86_64
libc.so.6(GLIBC_2.3)(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libc.so.6(GLIBC_2.3.4)(64bit) is needed by
R-core-2.10.0-2.fc11.x86_64
libc.so.6(GLIBC_2.4)(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libc.so.6(GLIBC_2.7)(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libc.so.6(GLIBC_2.8)(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libcairo.so.2()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libdl.so.2()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libdl.so.2(GLIBC_2.2.5)(64bit) is needed by
R-core-2.10.0-2.fc11.x86_64
libgcc_s.so.1()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libgfortran.so.3()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libgfortran.so.3(GFORTRAN_1.0)(64bit) is needed by
R-core-2.10.0-2.fc11.x86_64
libglib-2.0.so.0()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libgmodule-2.0.so.0()(64bit) is needed by
R-core-2.10.0-2.fc11.x86_64
libgobject-2.0.so.0()(64bit) is needed by
R-core-2.10.0-2.fc11.x86_64
libicui18n.so.40()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libicuuc.so.40()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libjpeg.so.62()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libm.so.6()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libm.so.6(GLIBC_2.2.5)(64bit) is needed by
R-core-2.10.0-2.fc11.x86_64
libpango-1.0.so.0()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libpangocairo-1.0.so.0()(64bit) is needed by
R-core-2.10.0-2.fc11.x86_64
libpcre.so.0()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libpng12.so.0()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libpng12.so.0(PNG12_0)(64bit) is needed by
R-core-2.10.0-2.fc11.x86_64
libreadline.so.5()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libstdc++.so.6()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libtcl8.5.so()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libtiff.so.3()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libtk8.5.so()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libz.so.1()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
perl is needed by R-core-2.10.0-2.fc11.x86_64
perl(Carp) is needed by R-core-2.10.0-2.fc11.x86_64
perl(Cwd) is needed by R-core-2.10.0-2.fc11.x86_64
perl(Exporter) is needed by R-core-2.10.0-2.fc11.x86_64
perl(File::Basename) is needed by R-core-2.10.0-2.fc11.x86_64
perl(File::Compare) is needed by R-core-2.10.0-2.fc11.x86_64
perl(File::Copy) is needed by R-core-2.10.0-2.fc11.x86_64
perl(File::Copy::Recursive) is needed by R-core-2.10.0-2.fc11.x86_64
perl(File::Find) is needed by R-core-2.10.0-2.fc11.x86_64
perl(File::Path) is needed by R-core-2.10.0-2.fc11.x86_64
perl(File::Spec) is needed by R-core-2.10.0-2.fc11.x86_64
perl(FileHandle) is needed by R-core-2.10.0-2.fc11.x86_64
perl(Getopt::Long) is needed by R-core-2.10.0-2.fc11.x86_64
perl(IO::File) is needed by R-core-2.10.0-2.fc11.x86_64
perl(Text::Tabs) is needed by R-core-2.10.0-2.fc11.x86_64
perl(Text::Wrap) is needed by R-core-2.10.0-2.fc11.x86_64
perl(strict) is needed by R-core-2.10.0-2.fc11.x86_64
perl(vars) is needed by R-core-2.10.0-2.fc11.x86_64
perl(warnings) is needed by R-core-2.10.0-2.fc11.x86_64
rpmlib(FileDigests) = 4.6.0-1 is needed by
R-core-2.10.0-2.fc11.x86_64
rtld(GNU_HASH) is needed by 

[R] R: rulefit error on Linux

2010-10-07 Thread noclue_

R version 2.8.1 (2008-12-22) on Linux 64-bit

I am trying to run 'rulefit' function (Rule based Learning Ensembles). but I
got the following error -

 rulefit(x,y)
Warning: This program is an suid-root program or is being run by the root
user.
The full text of the error or warning message cannot be safely formatted
in this environment. You may get a more descriptive message by running the
program as a non-root user or by removing the suid bit on the executable.
xterm Xt error: Can't open display: %s
xterm:  DISPLAY is not set
Error in file(file, r) : cannot open the connection
In addition: Warning message:
In file(file, r) :
  cannot open file '/root/_rulefit/rfstatus': No such file or directory
--

On windows R 2.10, I got this run successfully. So I am wondering whether it
is due to my R older version on Linux.

Thanks!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-rulefit-error-on-Linux-tp2966391p2966391.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] text/mtext axis labels on graphs

2010-10-07 Thread Jim Lemon

On 10/07/2010 09:29 PM, Martin Hughes wrote:


Hello everyone

I have problem with axis labels on graphs, I have my code as below:

plot(0,0,xlim=c(1,ncol(PA)),ylim=c(1,nrow(PA)),main=Stratigraphic
Range,xlab=Time
Bins,ylab=Taxa,cex.axis=1.5,cex.lab=2,cex.main=2.5,mgp=c(5,1.5,0),xaxt=n)


text(1:(length(strat_name)), y= 0, adj=1,
srt=45,labels=strat_name,xpd=TRUE, cex=1) #adds text to x axis giving
the strat names
abline(v=(1:ncol(PA))+.5,col=grey,lty=3)

cl - rep(1,nrow(PA))
cl[DistM$kill] - 2
for (i in 1:nrow(PA)) segments(min(which(PA[i,]==1))-.5,i,
max(which(PA[i,]==1))+.5,i,lwd=3,col=cl[i])


My problem lies with the x axis tick labels, I want my own labels added
in so removed the one the plot function adds in normally.

I use the text function as it allows me to fit my own text tick labels
at an angle, HOWEVER the text function is VERY sensitive to the Y axis,
I have multiple graphs on a page, each with a different y axis, so the
labels move up and down depending on the scale of the Y.


I tried using mtext which lets you put the text a certain distance from
the x margin line, HOWEVER this function does not let you tilt the text
to be an an angle


Can anyone tell me of a way I can have both - ie text that is a
specified distance from the margin AND tilted at and angle


Hi Martin,
Have a look at the staxlab function in the plotrix package, particularly 
the srt argument.


Jim

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


[R] Embed R in Eclipse

2010-10-07 Thread Philipp Nagy

 Hi,

We are a group of student working on a Java project on a Windows System.
For our project, we need to embed R into Java.

We have read about Rserve, but the single threaded JRI would be enough 
for our system.
Actually we were able to install rJava in R through 
install.packages(rJava), but that doesn´t help us to much.


Trying to embed R somehow in Eclipse, we always get errors. For Example, 
that some .dll files are missing!

How can we get it working!?

Philipp

--
Philipp Nagy
Student
Hasso Plattner Institut
and
Student Assistant
HPI School of Design Thinking

Hasso-Plattner-Institut für Software-Systemtechnik GmbH
Prof.-Dr.-Helmert-Str. 2 - 3
D-14482 Potsdam/Germany

eMail: philipp.n...@student.hpi.uni-potsdam.de

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


Re: [R] quantile regression

2010-10-07 Thread Julia Lira

The problem is that I can see a matrix with the coefficients, but not with the 
coefficients of all the simulations.

 

look at the codes now:

 

set.seed(180185)
nsim - 10
mresultx - matrix(-99, nrow=1000, ncol=nsim)
mresultb - matrix(-99, nrow=1000, ncol=nsim)
for (i in 1:nsim){
# make a matrix with 5 cols of N random uniform values
N - 200
I - 5
u - replicate( 5, runif(N, 0, 1) )
# fit matrix u in another matrix of 1 column 
mu - matrix(u, nrow=1000, ncol=1)
# make auction-specific covariate
x - runif(N, 0, 1)
mx - matrix(rep(x,5), nrow=1000, ncol=1)
b0 - matrix(rep(c(1),1000), nrow=1000, ncol=1)
#function for private cost
c - b0+b0*mx+mu
#bidding strategy
b - mx+((I+1)/I)+((I-1)/I)*mu  
mresultb[,i] - b
mresultx[,i] - mx
qf05 - rq(formula = mresultb[,i] ~ mresultx[,i], tau=0.5)
M - matrix(-99, nrow=2, ncol=nsim)
M[,i] - coef(qf05) 
} 


I am quite sure there is a mistake in the code: 
qf05 - rq(formula = mresultb[,i] ~ mresultx[,i], tau=0.5)
because it is just generating the coefficients for one simulation, not for 10 
simulations.

 

best,

 

Julia 


Date: Thu, 7 Oct 2010 18:51:40 +0800
Subject: Re: [R] quantile regression
From: minhua...@gmail.com
To: julia.l...@hotmail.co.uk

You should define M as a vector or matrix depending on the length of coef(qf05) 
and let M[i] or M[,i] be coef(qf05).


On Thu, Oct 7, 2010 at 6:40 PM, Julia Lira julia.l...@hotmail.co.uk wrote:


Dear all,



I am a new user in r and I am facing some problems with the quantile regression 
specification. I have two matrix (mresultb and mresultx) with nrow=1000 and 
ncol=nsim, where I specify (let's say) nsim=10. Hence, the columns in my matrix 
represents each simulation of a determined variable. I need to regress each 
column of mresultb on mresultx. My codes are the following:



set.seed(180185)
nsim - 10
mresultx - matrix(-99, nrow=1000, ncol=nsim)
mresultb - matrix(-99, nrow=1000, ncol=nsim)
for (i in 1:nsim){
# make a matrix with 5 cols of N random uniform values
N - 200
I - 5
u - replicate( 5, runif(N, 0, 1) )
# fit matrix u in another matrix of 1 column
mu - matrix(u, nrow=1000, ncol=1)
# make auction-specific covariate
x - runif(N, 0, 1)
mx - matrix(rep(x,5), nrow=1000, ncol=1)
b0 - matrix(rep(c(1),1000), nrow=1000, ncol=1)
#function for private cost
c - b0+b0*mx+mu
#bidding strategy
b - mx+((I+1)/I)+((I-1)/I)*mu
mresultb[,i] - b
mresultx[,i] - mx
qf05 - rq(formula = mresultb[,i] ~ mresultx[,i], tau=0.5)
M - coef(qf05)
}


But I just can see the quantile regression coefficients for 1 simulation, not 
for each i.

Maybe this is a stupid question, but i am not so familiar with this software 
yet.



Thanks in advance!



Julia

   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list

PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

  
[[alternative HTML version deleted]]

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


Re: [R] quantile regression

2010-10-07 Thread Martyn Byng
Hi,

Your code is of the form

for (i in 1:nsim) {
  ## Do something that generates variable qf05

  M - coeff(qf05)
}

This means that you are overwriting the variable M at each iteration and
so when the loop has finished you only have the coefficients from the
last simulation. There are lots of ways of getting around this, the
easiest would probably be to do something like

M - matrix(0,nsim,2)
for (i in 1:nsim) {
  ## Do something that generates variable qf05

  M[i,] - coeff(qf05)
}

then M would be a nsim by 2 matrix, with each row holding the
coefficients from a different simulation. You could also look at
removing the loop by vectorising the code.

Hope this helps

Martyn


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Julia Lira
Sent: 07 October 2010 11:40
To: r-help@r-project.org
Subject: [R] quantile regression


Dear all,

 

I am a new user in r and I am facing some problems with the quantile
regression specification. I have two matrix (mresultb and mresultx) with
nrow=1000 and ncol=nsim, where I specify (let's say) nsim=10. Hence, the
columns in my matrix represents each simulation of a determined
variable. I need to regress each column of mresultb on mresultx. My
codes are the following:

 

set.seed(180185)
nsim - 10
mresultx - matrix(-99, nrow=1000, ncol=nsim)
mresultb - matrix(-99, nrow=1000, ncol=nsim)
for (i in 1:nsim){
# make a matrix with 5 cols of N random uniform values
N - 200
I - 5
u - replicate( 5, runif(N, 0, 1) )
# fit matrix u in another matrix of 1 column 
mu - matrix(u, nrow=1000, ncol=1)
# make auction-specific covariate
x - runif(N, 0, 1)
mx - matrix(rep(x,5), nrow=1000, ncol=1)
b0 - matrix(rep(c(1),1000), nrow=1000, ncol=1)
#function for private cost
c - b0+b0*mx+mu
#bidding strategy
b - mx+((I+1)/I)+((I-1)/I)*mu  
mresultb[,i] - b
mresultx[,i] - mx
qf05 - rq(formula = mresultb[,i] ~ mresultx[,i], tau=0.5)
M - coef(qf05)
} 


But I just can see the quantile regression coefficients for 1
simulation, not for each i. 

Maybe this is a stupid question, but i am not so familiar with this
software yet.

 

Thanks in advance!

 

Julia  
  
[[alternative HTML version deleted]]

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


This e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}}

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


Re: [R] quantile regression

2010-10-07 Thread David Winsemius


On Oct 7, 2010, at 6:40 AM, Julia Lira wrote:



Dear all,



I am a new user in r and I am facing some problems with the quantile  
regression specification. I have two matrix (mresultb and mresultx)  
with nrow=1000 and ncol=nsim, where I specify (let's say) nsim=10.  
Hence, the columns in my matrix represents each simulation of a  
determined variable. I need to regress each column of mresultb on  
mresultx. My codes are the following:




set.seed(180185)
nsim - 10
mresultx - matrix(-99, nrow=1000, ncol=nsim)
mresultb - matrix(-99, nrow=1000, ncol=nsim)

#Keep constants that do not vary   outside the loop.

  N - 200
  I - 5

#Create an object to hold results.

M - matrix(0, ncol=2, nrow=nsim)


for (i in 1:nsim){
  # make a matrix with 5 cols of N random uniform values

  u - replicate( 5, runif(N, 0, 1) )
  # fit matrix u in another matrix of 1 column
  mu - matrix(u, nrow=1000, ncol=1)
  # make auction-specific covariate
  x - runif(N, 0, 1)
  mx - matrix(rep(x,5), nrow=1000, ncol=1)
  b0 - matrix(rep(c(1),1000), nrow=1000, ncol=1)
  #function for private cost
  c - b0+b0*mx+mu
  #bidding strategy
  b - mx+((I+1)/I)+((I-1)/I)*mu
  mresultb[,i] - b
  mresultx[,i] - mx
  qf05 - rq(formula = mresultb[,i] ~ mresultx[,i], tau=0.5)


# Use a a method of storing result that does not overwrite prior values

  M[i, ] - coef(qf05)
}


 M
  [,1] [,2]
 [1,] 1.546023 1.060197
 [2,] 1.593085 1.012752
 [3,] 1.561060 1.039669
 [4,] 1.555189 1.080506
 [5,] 1.595738 1.030818
 [6,] 1.599211 1.004429
 [7,] 1.572492 1.066966
 [8,] 1.619282 0.964974
 [9,] 1.595431 1.028448
[10,] 1.585927 1.023855

Not sure why you created mresultb and mresultx to accept multiple  
columns, sinc ewhat your really wanted was the results of the  
regression, but if there were a reasons then they are still there to  
be examined.





But I just can see the quantile regression coefficients for 1  
simulation, not for each i.


Maybe this is a stupid question, but i am not so familiar with this  
software yet.




Thanks in advance!



Julia

[[alternative HTML version deleted]]

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] quantile regression

2010-10-07 Thread Michael Bedward
Hi Julia,

In addition to Martyn's answer and David's friendly post I'd just add
that it's not a good idea to call a variable c since the function of
that name is so often used in R.

Michael


On 7 October 2010 22:28, Martyn Byng martyn.b...@nag.co.uk wrote:
 Hi,

 Your code is of the form

 for (i in 1:nsim) {
  ## Do something that generates variable qf05

  M - coeff(qf05)
 }

 This means that you are overwriting the variable M at each iteration and
 so when the loop has finished you only have the coefficients from the
 last simulation. There are lots of ways of getting around this, the
 easiest would probably be to do something like

 M - matrix(0,nsim,2)
 for (i in 1:nsim) {
  ## Do something that generates variable qf05

  M[i,] - coeff(qf05)
 }

 then M would be a nsim by 2 matrix, with each row holding the
 coefficients from a different simulation. You could also look at
 removing the loop by vectorising the code.

 Hope this helps

 Martyn


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Julia Lira
 Sent: 07 October 2010 11:40
 To: r-help@r-project.org
 Subject: [R] quantile regression


 Dear all,



 I am a new user in r and I am facing some problems with the quantile
 regression specification. I have two matrix (mresultb and mresultx) with
 nrow=1000 and ncol=nsim, where I specify (let's say) nsim=10. Hence, the
 columns in my matrix represents each simulation of a determined
 variable. I need to regress each column of mresultb on mresultx. My
 codes are the following:



 set.seed(180185)
 nsim - 10
 mresultx - matrix(-99, nrow=1000, ncol=nsim)
 mresultb - matrix(-99, nrow=1000, ncol=nsim)
 for (i in 1:nsim){
 # make a matrix with 5 cols of N random uniform values
 N - 200
 I - 5
 u - replicate( 5, runif(N, 0, 1) )
 # fit matrix u in another matrix of 1 column
 mu - matrix(u, nrow=1000, ncol=1)
 # make auction-specific covariate
 x - runif(N, 0, 1)
 mx - matrix(rep(x,5), nrow=1000, ncol=1)
 b0 - matrix(rep(c(1),1000), nrow=1000, ncol=1)
 #function for private cost
 c - b0+b0*mx+mu
 #bidding strategy
 b - mx+((I+1)/I)+((I-1)/I)*mu
 mresultb[,i] - b
 mresultx[,i] - mx
 qf05 - rq(formula = mresultb[,i] ~ mresultx[,i], tau=0.5)
 M - coef(qf05)
 }


 But I just can see the quantile regression coefficients for 1
 simulation, not for each i.

 Maybe this is a stupid question, but i am not so familiar with this
 software yet.



 Thanks in advance!



 Julia

        [[alternative HTML version deleted]]

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

 
 This e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}}

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


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


[R] first post and bootstarpping problems

2010-10-07 Thread paulidealiste

 

 Hello to all R users,

I use R for a year now and am dealing with geometric morphometrics of deer 
skulls. Yes, I am a biologist and my math skills are just beginning to brush 
up. To cut to the chase...

I have two groups in my data (males and females) and my data is in a simple 
vector form. Now I need a bootstrap test for this value 

szc1 - ((mean(maleCent)-mean(femaCent))^ 2)/(var(maleCent)+var(femaCent)) 

which concerns two aforementioned groups. I have 39 males and 11 females 
totaling to 50 individuals. Now I don`t know how to assign this to a bootstrap 
boot() function. Any ideas?



[[alternative HTML version deleted]]

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


[R] Create 2d table with mean of entries

2010-10-07 Thread sugimoto

Hi,

I have the following problem:
I have a list of entries with vehicles going from some places to others and
the time that they need.
e.g.
Vehicle Start End Time
1A   B5
2A   C4
3A   C3
4B   A6
5B   C4
6B   C6
7C   B2
8C   B4
9A   B7

What I need is a 2d table with the average time needed from Start to End,
e.g.
A   B   C
A NA 6   3.5
B 6NA5
CNA 3   NA


Any help would be very much appreciated,
Sugi
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Create-2d-table-with-mean-of-entries-tp2966610p2966610.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] quantile regression

2010-10-07 Thread Julia Lira

Thank you all for the explanation!

 

Best,

 

Julia 
 
 Date: Thu, 7 Oct 2010 22:37:32 +1100
 Subject: Re: [R] quantile regression
 From: michael.bedw...@gmail.com
 To: martyn.b...@nag.co.uk
 CC: julia.l...@hotmail.co.uk; r-help@r-project.org
 
 Hi Julia,
 
 In addition to Martyn's answer and David's friendly post I'd just add
 that it's not a good idea to call a variable c since the function of
 that name is so often used in R.
 
 Michael
 
 
 On 7 October 2010 22:28, Martyn Byng martyn.b...@nag.co.uk wrote:
  Hi,
 
  Your code is of the form
 
  for (i in 1:nsim) {
   ## Do something that generates variable qf05
 
   M - coeff(qf05)
  }
 
  This means that you are overwriting the variable M at each iteration and
  so when the loop has finished you only have the coefficients from the
  last simulation. There are lots of ways of getting around this, the
  easiest would probably be to do something like
 
  M - matrix(0,nsim,2)
  for (i in 1:nsim) {
   ## Do something that generates variable qf05
 
   M[i,] - coeff(qf05)
  }
 
  then M would be a nsim by 2 matrix, with each row holding the
  coefficients from a different simulation. You could also look at
  removing the loop by vectorising the code.
 
  Hope this helps
 
  Martyn
 
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
  On Behalf Of Julia Lira
  Sent: 07 October 2010 11:40
  To: r-help@r-project.org
  Subject: [R] quantile regression
 
 
  Dear all,
 
 
 
  I am a new user in r and I am facing some problems with the quantile
  regression specification. I have two matrix (mresultb and mresultx) with
  nrow=1000 and ncol=nsim, where I specify (let's say) nsim=10. Hence, the
  columns in my matrix represents each simulation of a determined
  variable. I need to regress each column of mresultb on mresultx. My
  codes are the following:
 
 
 
  set.seed(180185)
  nsim - 10
  mresultx - matrix(-99, nrow=1000, ncol=nsim)
  mresultb - matrix(-99, nrow=1000, ncol=nsim)
  for (i in 1:nsim){
  # make a matrix with 5 cols of N random uniform values
  N - 200
  I - 5
  u - replicate( 5, runif(N, 0, 1) )
  # fit matrix u in another matrix of 1 column
  mu - matrix(u, nrow=1000, ncol=1)
  # make auction-specific covariate
  x - runif(N, 0, 1)
  mx - matrix(rep(x,5), nrow=1000, ncol=1)
  b0 - matrix(rep(c(1),1000), nrow=1000, ncol=1)
  #function for private cost
  c - b0+b0*mx+mu
  #bidding strategy
  b - mx+((I+1)/I)+((I-1)/I)*mu
  mresultb[,i] - b
  mresultx[,i] - mx
  qf05 - rq(formula = mresultb[,i] ~ mresultx[,i], tau=0.5)
  M - coef(qf05)
  }
 
 
  But I just can see the quantile regression coefficients for 1
  simulation, not for each i.
 
  Maybe this is a stupid question, but i am not so familiar with this
  software yet.
 
 
 
  Thanks in advance!
 
 
 
  Julia
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
  
  This e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}}
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
  
[[alternative HTML version deleted]]

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


[R] X11 is not available

2010-10-07 Thread ogbos okike
Dear All,
I have just installed a new version of R (Version R-2.11.0) and did install
other packages such as raster with ease. However, I could not start the
plotting device x11(). I remembered that somewhere at the  stage of
installation, an error occurred : 'configure: error: --with-x=yes (default)
and X11 headers/libs are not available'
 I tried avoiding this error by using ./configure --with-x=no (i.e. changing
the yes to know). Well, the error disappeared but after the installation, I
could not start x11().

I have tried to install alien and attempted to use it to install java1.4.rpm
I have also installed r-base-dev , build-dep r-base and libX11-dev
But the problem remains.

I will glad if somebody can bail me out.
Best
Ogbos

**

[[alternative HTML version deleted]]

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


Re: [R] tapply output

2010-10-07 Thread jim holtman
You can also use sqldf:


 require(sqldf)
 sqldf(select class, `group`, name, avg(height)
+ from myData
+ group by class, 'group', name)
  class group name avg(height)
1 0 B Jane58.5
2 0 A  Tom62.5
3 1 A Enzo66.5
4 1 B Mary70.5



On Thu, Oct 7, 2010 at 4:49 AM, Peter Ehlers ehl...@ucalgary.ca wrote:
 On 2010-10-06 13:24, Erik Iverson wrote:

 Hello,

 You can use ddply from the very useful plyr package to do this.
 There must be a way using base R functions, but plyr is
 worth looking into in my opinion.

    install.packages(plyr)
    library(plyr)
    ddply(myData, .(class, group, name), function(x) mean(x$height))

    class group name   V1
 1     0     A  Tom 62.5
 2     0     B Jane 58.5
 3     1     A Enzo 66.5
 4     1     B Mary 70.5

 Or use summarize:

    ddply(myData, .(class, group, name), summarize, mht = mean(height))

  -Peter Ehlers


 Geoffrey Smith wrote:

 Hello, I am having trouble getting the output from the tapply function
 formatted so that it can be made into a nice table.  Below is my question
 written in R code.  Does anyone have any suggestions?  Thank you.  Geoff

 #Input the data;
 name- c('Tom', 'Tom', 'Jane', 'Jane', 'Enzo', 'Enzo', 'Mary', 'Mary');
 year- c(2008, 2009, 2008, 2009, 2008, 2009, 2008, 2009);
 group- c('A', 'A', 'B', 'B', 'A', 'A', 'B', 'B');
 class- c(0, 0, 0, 0, 1, 1, 1, 1);
 height- c(62, 63, 59, 58, 67, 66, 70, 71);

 #Combine the data into a data frame;
 myData- data.frame(name, year, group, class, height);
 myData;

 #Calculate the mean of height by class, group, and name;
 tapply(myData$height, data.frame(myData$class, myData$group,
 myData$name),
 mean);

 #The raw output from the tapply function is fine, but I would;
 #really like the output to look like this;
 #  class   group     name     mean
 #    0       A            Tom        62.5
 #    0       B            Jane        58.5
 #    1       A            Enzo       66.5
 #    1       B            Mary       70.5


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

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




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

What is the problem that you are trying to solve?

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


Re: [R] first post and bootstarpping problems

2010-10-07 Thread David Winsemius


On Oct 7, 2010, at 7:39 AM, paulideali...@aol.com wrote:





Hello to all R users,

I use R for a year now and am dealing with geometric morphometrics  
of deer skulls. Yes, I am a biologist and my math skills are just  
beginning to brush up. To cut to the chase...


I have two groups in my data (males and females) and my data is in a  
simple vector form. Now I need a bootstrap test for this value


szc1 - ((mean(maleCent)-mean(femaCent))^ 2)/(var(maleCent) 
+var(femaCent))


which concerns two aforementioned groups. I have 39 males and 11  
females totaling to 50 individuals. Now I don`t know how to assign  
this to a bootstrap boot() function. Any ideas?


Looks like you are attempting the first part of a a two group t-test.  
Have you thought of using that function? And it would seem that you  
have not yet looked at the examples on the boot funtion's page in  
package boot.

--

David Winsemius, MD
West Hartford, CT

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


Re: [R] Create 2d table with mean of entries

2010-10-07 Thread Henrique Dallazuanna
Try this:

with(DF, tapply(Time, list(Start, End), mean))


On Thu, Oct 7, 2010 at 8:40 AM, sugimoto iey...@sugimoto.at wrote:


 Hi,

 I have the following problem:
 I have a list of entries with vehicles going from some places to others and
 the time that they need.
 e.g.
 Vehicle Start End Time
1A   B5
2A   C4
3A   C3
4B   A6
5B   C4
6B   C6
7C   B2
8C   B4
9A   B7

 What I need is a 2d table with the average time needed from Start to End,
 e.g.
A   B   C
 A NA 6   3.5
 B 6NA5
 CNA 3   NA


 Any help would be very much appreciated,
 Sugi
 --
 View this message in context:
 http://r.789695.n4.nabble.com/Create-2d-table-with-mean-of-entries-tp2966610p2966610.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

[[alternative HTML version deleted]]

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


[R] Longitudinal multivariate data analysis

2010-10-07 Thread abderrahim youssef
Dear all,

I am looking for an R package that fits multivariate gaussian or
non-gaussian longitudinal outcomes.
I am especially interested to non-gaussian outcomes  since the outcomes I've
got are discrete (some are binomial and some are count data).
Many thanks in advance,
Abderrahim

[[alternative HTML version deleted]]

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


Re: [R] X11 is not available: Problem Fixed

2010-10-07 Thread ogbos okike
Hey,
Just decided to install the latest version of R and the device is supported.
Thanks
Ogbos

On 7 October 2010 13:49, ogbos okike ogbos.ok...@gmail.com wrote:

 Dear All,
 I have just installed a new version of R (Version R-2.11.0) and did install
 other packages such as raster with ease. However, I could not start the
 plotting device x11(). I remembered that somewhere at the  stage of
 installation, an error occurred : 'configure: error: --with-x=yes (default)
 and X11 headers/libs are not available'
  I tried avoiding this error by using ./configure --with-x=no (i.e.
 changing the yes to know). Well, the error disappeared but after the
 installation, I could not start x11().

 I have tried to install alien and attempted to use it to install
 java1.4.rpm
 I have also installed r-base-dev , build-dep r-base and libX11-dev
 But the problem remains.

 I will glad if somebody can bail me out.
 Best
 Ogbos

 **



[[alternative HTML version deleted]]

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


Re: [R] Linux 64-bit R installation problem - Failed dependencies

2010-10-07 Thread Marc Schwartz
On Oct 7, 2010, at 3:50 AM, noclue_ wrote:

 
 I am trying to install 64 bit R on Linux.  But I got the following error -  
 
 
 rpm -i R-core-2.10.0-2.fc11.x86_64.rpm
 
 warning: R-core-2.10.0-2.fc11.x86_64.rpm: Header V3 DSA signature: NOKEY,
 key ID 97d3544e
 error: Failed dependencies:
/bin/bash is needed by R-core-2.10.0-2.fc11.x86_64
/bin/sh is needed by R-core-2.10.0-2.fc11.x86_64
/sbin/ldconfig is needed by R-core-2.10.0-2.fc11.x86_64
/usr/bin/perl is needed by R-core-2.10.0-2.fc11.x86_64
cups is needed by R-core-2.10.0-2.fc11.x86_64
gawk is needed by R-core-2.10.0-2.fc11.x86_64
ld-linux-x86-64.so.2()(64bit) is needed by
 R-core-2.10.0-2.fc11.x86_64
ld-linux-x86-64.so.2(GLIBC_2.2.5)(64bit) is needed by
 R-core-2.10.0-2.fc11.x86_64
less is needed by R-core-2.10.0-2.fc11.x86_64
libICE.so.6()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libSM.so.6()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libX11.so.6()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libXmu.so.6()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libXt.so.6()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libbz2.so.1()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libc.so.6()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libc.so.6(GLIBC_2.2.5)(64bit) is needed by
 R-core-2.10.0-2.fc11.x86_64
libc.so.6(GLIBC_2.3)(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libc.so.6(GLIBC_2.3.4)(64bit) is needed by
 R-core-2.10.0-2.fc11.x86_64
libc.so.6(GLIBC_2.4)(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libc.so.6(GLIBC_2.7)(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libc.so.6(GLIBC_2.8)(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libcairo.so.2()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libdl.so.2()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libdl.so.2(GLIBC_2.2.5)(64bit) is needed by
 R-core-2.10.0-2.fc11.x86_64
libgcc_s.so.1()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libgfortran.so.3()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libgfortran.so.3(GFORTRAN_1.0)(64bit) is needed by
 R-core-2.10.0-2.fc11.x86_64
libglib-2.0.so.0()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libgmodule-2.0.so.0()(64bit) is needed by
 R-core-2.10.0-2.fc11.x86_64
libgobject-2.0.so.0()(64bit) is needed by
 R-core-2.10.0-2.fc11.x86_64
libicui18n.so.40()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libicuuc.so.40()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libjpeg.so.62()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libm.so.6()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libm.so.6(GLIBC_2.2.5)(64bit) is needed by
 R-core-2.10.0-2.fc11.x86_64
libpango-1.0.so.0()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libpangocairo-1.0.so.0()(64bit) is needed by
 R-core-2.10.0-2.fc11.x86_64
libpcre.so.0()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libpng12.so.0()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libpng12.so.0(PNG12_0)(64bit) is needed by
 R-core-2.10.0-2.fc11.x86_64
libreadline.so.5()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libstdc++.so.6()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libtcl8.5.so()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libtiff.so.3()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libtk8.5.so()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
libz.so.1()(64bit) is needed by R-core-2.10.0-2.fc11.x86_64
perl is needed by R-core-2.10.0-2.fc11.x86_64
perl(Carp) is needed by R-core-2.10.0-2.fc11.x86_64
perl(Cwd) is needed by R-core-2.10.0-2.fc11.x86_64
perl(Exporter) is needed by R-core-2.10.0-2.fc11.x86_64
perl(File::Basename) is needed by R-core-2.10.0-2.fc11.x86_64
perl(File::Compare) is needed by R-core-2.10.0-2.fc11.x86_64
perl(File::Copy) is needed by R-core-2.10.0-2.fc11.x86_64
perl(File::Copy::Recursive) is needed by R-core-2.10.0-2.fc11.x86_64
perl(File::Find) is needed by R-core-2.10.0-2.fc11.x86_64
perl(File::Path) is needed by R-core-2.10.0-2.fc11.x86_64
perl(File::Spec) is needed by R-core-2.10.0-2.fc11.x86_64
perl(FileHandle) is needed by R-core-2.10.0-2.fc11.x86_64
perl(Getopt::Long) is needed by R-core-2.10.0-2.fc11.x86_64
perl(IO::File) is needed by R-core-2.10.0-2.fc11.x86_64
perl(Text::Tabs) is needed by R-core-2.10.0-2.fc11.x86_64
perl(Text::Wrap) is needed by R-core-2.10.0-2.fc11.x86_64
perl(strict) is needed by R-core-2.10.0-2.fc11.x86_64
perl(vars) is needed by R-core-2.10.0-2.fc11.x86_64
perl(warnings) is needed by R-core-2.10.0-2.fc11.x86_64
rpmlib(FileDigests) = 4.6.0-1 is needed by
 

Re: [R] is there a way to avoid traveling grid?

2010-10-07 Thread ONKELINX, Thierry
Dimitri,

1. The grid will always be on the background. You can use geom_vline() and 
geom_hline() to draw horizontal and vertical lines at the positions that you 
want them. 

2. Note that you must 'stack' the data yourself. Geom_area() just plots a 
polygon with 0 as one of the boundaries. When you have multiple categories, 
then position = identity will plot overlapping polygons. The order of the 
polygons depends on the order of the factor. The first level will be drawn 
first, then the second,... So the polygon of the last level will be on top. So 
you must figure out in what order you need the levels.

3. If you want specific colour you will need scale_fill_manual. You don't have 
to use a named value, it that case the colours will be assigned in the same 
order as the levels of your factor. I'm not sure how you would what to automate 
that? If you don't want specific colours then have a look a scale_fill_discrete 
or scale_fill_brewer(). More details on http://had.co.nz/ggplot2/

HTH,

Thierry


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie  Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics  Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

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

 -Oorspronkelijk bericht-
 Van: Dimitri Liakhovitski [mailto:dimitri.liakhovit...@gmail.com] 
 Verzonden: dinsdag 5 oktober 2010 17:49
 Aan: ONKELINX, Thierry
 CC: r-help@r-project.org
 Onderwerp: Re: [R] is there a way to avoid traveling grid?
 
 Thierry,
 your ggplot solution really looks great and very parsimonious!
 May I ask a couple of questions?
 1. Is there a way to make the grid appear on top of the 
 colored areas instead of under them - like I did in the plot solution?
 2. In your code line Molten2$variable - 
 factor(Molten2$variable, levels = c(z, y, x,a)) - how 
 did you chose the order of the levels? It's important for me 
 to know because I'll have to deal with a lot of variables and 
 would like to automate this part (you might have noticed I 
 want the variable with the smallest negatives to be first at 
 the bottom of the chart and the variable with the smallest 
 positive to be at the top).
 3. In your scale_fill_manual line of code - looks like the 
 order is manual again. Is there a way to define the colors, 
 so to say automatically - in accordance to the areas of the chart?
 
 Thanks a lot!
 
 
 On Tue, Oct 5, 2010 at 11:28 AM, ONKELINX, Thierry
 thierry.onkel...@inbo.be wrote:
  Dear Dimitri,
 
  Ggplot2 solves your problem with the gridlines and requires 
 much less 
  code. You only need to reshape your data somewhat.
 
  library(ggplot2)
  #changing the dataset
  my.data2 - my.data
  my.data2$x - my.data$x + my.data$a
  my.data2$z - my.data$y + my.data$z
  Molten2 - melt(my.data2, id.vars = date) Molten2$variable - 
  factor(Molten2$variable, levels = c(z, y, x,
  a))
 
  #basic plot
  ggplot(Molten2, aes(x = date, y = value, fill = variable)) +
         geom_area(position = identity)
 
  #changing the lay-out a bit
  ggplot(Molten2, aes(x = date, y = value, fill = variable)) +
         geom_area(position = identity) +
         scale_fill_manual(value = c(z = orange, y = green, x = 
  blue, a = yellow)) +
         scale_x_date(major = months, format=%d-%m-%Y) +
         opts(axis.text.x = theme_text(angle = 90, hjust = 1))
 
  HTH,
 
  Thierry
 
  
 --
  --
  
  ir. Thierry Onkelinx
  Instituut voor natuur- en bosonderzoek team Biometrie  
 Kwaliteitszorg 
  Gaverstraat 4 9500 Geraardsbergen Belgium
 
  Research Institute for Nature and Forest team Biometrics  Quality 
  Assurance Gaverstraat 4 9500 Geraardsbergen Belgium
 
  tel. + 32 54/436 185
  thierry.onkel...@inbo.be
  www.inbo.be
 
  To call in the statistician after the experiment is done may be no 
  more than asking him to perform a post-mortem examination: 
 he may be 
  able to say what the experiment died of.
  ~ Sir Ronald Aylmer Fisher
 
  The plural of anecdote is not data.
  ~ Roger Brinner
 
  The combination of some data and an aching desire for an 
 answer does 
  not ensure that a reasonable answer can be extracted from a 
 given body 
  of data.
  ~ John Tukey
 
 
  -Oorspronkelijk bericht-
  Van: r-help-boun...@r-project.org
  [mailto:r-help-boun...@r-project.org] Namens Dimitri Liakhovitski
  Verzonden: dinsdag 5 oktober 

[R] file.info returning NA

2010-10-07 Thread Erich Neuwirth
Windows 7, R-2.11.1 and R-2.12.0beta

When I do

file.info(list.files(getwd()))

I get what I expect, a dataframe with a lot of variables,
especially isdir, which tells me if the named object
is a file or a directory.

In the result of

file.info(list.files(paste(R.home(),library,sep=/)))

all variables have only NA values, even when I start R
in elevated mode.

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


Re: [R] Longitudinal multivariate data analysis

2010-10-07 Thread Marc Schwartz
On Oct 7, 2010, at 6:48 AM, abderrahim youssef wrote:

 Dear all,
 
 I am looking for an R package that fits multivariate gaussian or
 non-gaussian longitudinal outcomes.
 I am especially interested to non-gaussian outcomes  since the outcomes I've
 got are discrete (some are binomial and some are count data).
 Many thanks in advance,
 Abderrahim


You will want to start by looking at the lme4 package for R, within which are 
the lmer() and glmer() functions to fit such models.

More information here:

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

and:

  http://lme4.r-forge.r-project.org/

There is also a R-SIG-MIXED-MODELS e-mail list focused on this subject matter:

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

Finally, there is also a working draft FAQ, which I believe Ben Bolker is 
maintaining:

  http://glmm.wikidot.com/faq

HTH,

Marc Schwartz

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


Re: [R] file.info returning NA

2010-10-07 Thread Henrique Dallazuanna
Try with full.names = TRUE argument in list.files:

file.info(list.files(paste(R.home(),library,sep=/), full.names = TRUE))

On Thu, Oct 7, 2010 at 9:37 AM, Erich Neuwirth
erich.neuwi...@univie.ac.atwrote:

 Windows 7, R-2.11.1 and R-2.12.0beta

 When I do

 file.info(list.files(getwd()))

 I get what I expect, a dataframe with a lot of variables,
 especially isdir, which tells me if the named object
 is a file or a directory.

 In the result of

 file.info(list.files(paste(R.home(),library,sep=/)))

 all variables have only NA values, even when I start R
 in elevated mode.

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




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

[[alternative HTML version deleted]]

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


Re: [R] file.info returning NA

2010-10-07 Thread Duncan Murdoch

 On 07/10/2010 8:37 AM, Erich Neuwirth wrote:

Windows 7, R-2.11.1 and R-2.12.0beta

When I do

file.info(list.files(getwd()))

I get what I expect, a dataframe with a lot of variables,
especially isdir, which tells me if the named object
is a file or a directory.

In the result of

file.info(list.files(paste(R.home(),library,sep=/)))

all variables have only NA values, even when I start R
in elevated mode.



You should look at the result of the inner expression

list.files(paste(R.home(),library,sep=/))

It doesn't include the path, so file.info doesn't know where to find 
them.  You need full.names=TRUE in the list.files call.


Duncan Murdoch

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


[R] Lattice: Histogram in splom diagonals

2010-10-07 Thread Alejo C.S.
Dear list, I want to plot several variables with splom and in the main
diagonal, instead of the  variable names, I'd like to plot an histogram of
corresponding variables. Searching I did not find the correct syntax, only
some tips in an old post in the list, but this comments help to plot only
 density lines instead of histograms. I had some code, but it fails to plot
(I've commented the problematic lines):


splom(iris[,1:4], panel = function(x, y, ...) {
 panel.xyplot(x, y, ...)
 panel.lmline(x,y,...)
 }
#, diag.panel=function(x,...){
#  panel.histogram(x,...)
#}

)

Thanks a lot in advance!

Regards,

Alejo

[[alternative HTML version deleted]]

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


Re: [R] X11 is not available

2010-10-07 Thread Ista Zahn
HI,
It's not clear to me exactly what you did.

On Thu, Oct 7, 2010 at 7:49 AM, ogbos okike ogbos.ok...@gmail.com wrote:
 Dear All,
 I have just installed a new version of R (Version R-2.11.0) and did install
 other packages such as raster with ease. However, I could not start the
 plotting device x11(). I remembered that somewhere at the  stage of
 installation, an error occurred : 'configure: error: --with-x=yes (default)
 and X11 headers/libs are not available'

This makes it sound like you compiled R from source yourself,

  I tried avoiding this error by using ./configure --with-x=no (i.e. changing
 the yes to know). Well, the error disappeared but after the installation, I
 could not start x11().

without X11 support.


 I have tried to install alien and attempted to use it to install java1.4.rpm

Why? Most linux distributions (you never say which one you are using.
We need this information in order to help you.) have a standard way to
install java...

 I have also installed r-base-dev , build-dep r-base and libX11-dev
 But the problem remains.


This sounds like you installed R using your package manager. So which is it?

-Ista

 I will glad if somebody can bail me out.
 Best
 Ogbos

 **

        [[alternative HTML version deleted]]

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




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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


Re: [R] X11 is not available

2010-10-07 Thread ogbos okike
Hey Ista,

I am just learning a bit of installation. Trying my hands on various things
I see on the web. Some proved helpful whereas I am not sure of others.
I didn't compile R from source. Just downloaded R-2.10.0 and tried to
install. The error message I referred to was there when I did $./configure.
And somebody suggested I should do $./configure --with-x=no to avoid the
error. Other things I installed were in  a bid to solve the problem of x11()
not being available (following what others who said they have encountered
the same problem suggested). But as I said , none helped.

I decided to downloaded another version R-2.11.1 and installed as well. It
was indicated that the version supports X11.
This has solved my problem at least for now.
Thanks for your concern
Ogbos

On 7 October 2010 15:51, Ista Zahn iz...@psych.rochester.edu wrote:

 HI,
 It's not clear to me exactly what you did.

 On Thu, Oct 7, 2010 at 7:49 AM, ogbos okike ogbos.ok...@gmail.com wrote:
  Dear All,
  I have just installed a new version of R (Version R-2.11.0) and did
 install
  other packages such as raster with ease. However, I could not start the
  plotting device x11(). I remembered that somewhere at the  stage of
  installation, an error occurred : 'configure: error: --with-x=yes
 (default)
  and X11 headers/libs are not available'

 This makes it sound like you compiled R from source yourself,

   I tried avoiding this error by using ./configure --with-x=no (i.e.
 changing
  the yes to know). Well, the error disappeared but after the installation,
 I
  could not start x11().

 without X11 support.

 
  I have tried to install alien and attempted to use it to install
 java1.4.rpm

 Why? Most linux distributions (you never say which one you are using.
 We need this information in order to help you.) have a standard way to
 install java...

  I have also installed r-base-dev , build-dep r-base and libX11-dev
  But the problem remains.
 

 This sounds like you installed R using your package manager. So which is
 it?

 -Ista

  I will glad if somebody can bail me out.
  Best
  Ogbos
 
  **
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



 --
 Ista Zahn
 Graduate student
 University of Rochester
 Department of Clinical and Social Psychology
 http://yourpsyche.org


[[alternative HTML version deleted]]

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


[R] packaging my function

2010-10-07 Thread Mipam Bruining
Dear all,

I write to you because there seems to be something I'm just not 'getting' in
the way R lets you construct a new package. Google and this mailing list's
archive don't seem to have the answer to my specific case so I signed up and
mailed the question myself.

So I've written this function that I wan't to make a package out of. Here is
what I've done so far:

1) I've used package.skeleton(MyFunction) on it  (with no futher
arguments) to create the package.
2) I edited the DESCRIPTION file and the manual page in the man folder
according to the specifications in the R tutorial
3) I opened a command window to run the commands Rcmd build and Rcmd
check on my package  (my OS is windows Vista)
4) I corrected the warnings and errors given in the log file and repeated
step3 until there were no more warnings
5) I started the RGui (version 2.10.1) to check if the package was working.
I used the menu option Install packages from local zip file'

This is were the problem occured. Namely, when trying to install my package
from local zip file, I get the error message:
 utils:::menuInstallLocal()
Error in gzfile(file, r) : cannot open the connection
In addition: Warning messages:
1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file
2: In gzfile(file, r) :
  cannot open compressed file 'pggui_2.1.tar.gz/DESCRIPTION', probable
reason 'No such file or directory'


By checking the file manually, I can confirm that the DESCRIPTION file is in
fact in the right location,  that it's content has the correct structure as
dictated by the R tutorial, and that the file has all the right permissions
granted.

What could it be, and how can I find the answer to this problem?

My thanks in advance,
Mipam Bruining

[[alternative HTML version deleted]]

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


Re: [R] Lattice: Histogram in splom diagonals

2010-10-07 Thread David Winsemius


On Oct 7, 2010, at 9:04 AM, Alejo C.S. wrote:


Dear list, I want to plot several variables with splom and in the main
diagonal, instead of the  variable names, I'd like to plot an  
histogram of
corresponding variables. Searching I did not find the correct  
syntax, only
some tips in an old post in the list, but this comments help to plot  
only
density lines instead of histograms. I had some code, but it fails  
to plot

(I've commented the problematic lines):


splom(iris[,1:4], panel = function(x, y, ...) {
panel.xyplot(x, y, ...)
panel.lmline(x,y,...)
}
#, diag.panel=function(x,...){
#  panel.histogram(x,...)
#}

)

Thanks a lot in advance!



From 2007 posting by Barnes (only return from RSiteSearch with  
modified Targets for splom diag.panel histogram:


panel.hist.splom-function(x, ...)
 {
 yrng - current.panel.limits()$ylim
 h - hist(x, plot = FALSE)
 breaks - h$breaks; nB - length(breaks)
 y - h$counts; y - yrng[1] + 0.95 * diff(yrng) * y / max(y)
 panel.rect(breaks[-nB], yrng[1], breaks[-1], y,  
col=cyan, ...)

 }
my.plot = function(data) {
  splom( ~data,
   lower.panel=function(x, y, ...) {
 panel.xyplot(x, y, ...)
 panel.lmline(x,y,...)},
   upper.panel=function(x, y, ...) {
 panel.xyplot(x, y, ...)
 panel.lmline(x,y,...)},
   diag.panel = panel.hist.splom)
}

my.plot(iris[,1:4])


David Winsemius, MD
West Hartford, CT

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


[R] Truncating leading zeros in strings

2010-10-07 Thread E. Paul Wileyto


I am new to R.  I thing this will be simple, but I don't yet know my way 
around.


I am generating character strings from the system clock that represent 
integers, and I want to convert them to integer values.  Strtoi works 
well, except when there are leading zeros on the string.  Could anyone 
suggest a way to remove those leading zeros?


Thanks

Paul






--
E. Paul Wileyto, Ph.D.
Assistant Professor of Biostatistics
Tobacco Use Research Center
School of Medicine, U. of Pennsylvania
3535 Market Street, Suite 4100
Philadelphia, PA  19104-3309

215-746-7147
Fax: 215-746-7140
e...@upenn.edu

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


[R] how to convert list to language object

2010-10-07 Thread lord12

If I have a list:

list = c(~garch(1,1), ~arma(1,1)) and I run
typeof(list[1]), the output is a list object. But I want each element in the
list to be a language object. How do I transform these list objects to
language objects? 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-convert-list-to-language-object-tp2966813p2966813.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] packaging my function

2010-10-07 Thread Duncan Murdoch

 On 07/10/2010 10:06 AM, Mipam Bruining wrote:

Dear all,

I write to you because there seems to be something I'm just not 'getting' in
the way R lets you construct a new package. Google and this mailing list's
archive don't seem to have the answer to my specific case so I signed up and
mailed the question myself.

So I've written this function that I wan't to make a package out of. Here is
what I've done so far:

1) I've used package.skeleton(MyFunction) on it  (with no futher
arguments) to create the package.
2) I edited the DESCRIPTION file and the manual page in the man folder
according to the specifications in the R tutorial
3) I opened a command window to run the commands Rcmd build and Rcmd
check on my package  (my OS is windows Vista)
4) I corrected the warnings and errors given in the log file and repeated
step3 until there were no more warnings
5) I started the RGui (version 2.10.1) to check if the package was working.
I used the menu option Install packages from local zip file'


R uses the following conventions:

*.tar.gz   -- a source package, as produced by R CMD build pkg
*.zip-- a Windows binary package.  There are a couple of ways to 
produce one of these, usually the best is

   R CMD INSTALL --build pkg

You didn't produce a zip file, so when you tried to install a tar.gz 
file, it failed.


For your own file, you can skip producing the .zip.  The easiest way is 
to use


R CMD INSTALL pkg

but you can also do it within R using

install.packages(pkg, repos=NULL, type=source)

In the examples above, pkg can be the directory where the package is 
stored, or (except for R CMD build) the name of a *.tar.gz file.


Duncan Murdoch


This is were the problem occured. Namely, when trying to install my package
from local zip file, I get the error message:
  utils:::menuInstallLocal()
Error in gzfile(file, r) : cannot open the connection
In addition: Warning messages:
1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file
2: In gzfile(file, r) :
   cannot open compressed file 'pggui_2.1.tar.gz/DESCRIPTION', probable
reason 'No such file or directory'


By checking the file manually, I can confirm that the DESCRIPTION file is in
fact in the right location,  that it's content has the correct structure as
dictated by the R tutorial, and that the file has all the right permissions
granted.

What could it be, and how can I find the answer to this problem?

My thanks in advance,
Mipam Bruining

[[alternative HTML version deleted]]

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


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


Re: [R] how to convert list to language object

2010-10-07 Thread Henrique Dallazuanna
obj - c(~garch(1,1), ~arma(1,1))
typeof(obj[[1]])

Use doble '[' indeed of '['

On Thu, Oct 7, 2010 at 10:50 AM, lord12 trexi...@yahoo.com wrote:


 If I have a list:

 list = c(~garch(1,1), ~arma(1,1)) and I run
 typeof(list[1]), the output is a list object. But I want each element in
 the
 list to be a language object. How do I transform these list objects to
 language objects?
 --
 View this message in context:
 http://r.789695.n4.nabble.com/how-to-convert-list-to-language-object-tp2966813p2966813.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

[[alternative HTML version deleted]]

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


Re: [R] Truncating leading zeros in strings

2010-10-07 Thread David Winsemius


On Oct 7, 2010, at 9:57 AM, E. Paul Wileyto wrote:



I am new to R.  I thing this will be simple, but I don't yet know my  
way around.


I am generating character strings from the system clock that  
represent integers, and I want to convert them to integer values.   
Strtoi works well, except when there are leading zeros on the  
string.  Could anyone suggest a way to remove those leading zeros?


as.integer doesn't work? (If you are dealing in different base than  
10, then you really should say so.)


 as.integer(123)
[1] 123

Or pass through sub(^[0]+, , vals)
 sub(^[0]+, , 123)
[1] 123

An example is expected in such situations. Please do now read the  
Posting Guide.

--

David Winsemius, MD
West Hartford, CT

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


Re: [R] Truncating leading zeros in strings

2010-10-07 Thread Martyn Byng
Hi,

Think I might be misunderstanding what you want, because ...

 t = 123
 as.integer(t)
[1] 123


anyway

 t = 123
 substr(t,regexpr([^0],t),nchar(t))
[1] 123

seems to trim the leading 0's

Martyn

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of E. Paul Wileyto
Sent: 07 October 2010 14:58
To: r-help@r-project.org
Subject: [R] Truncating leading zeros in strings


I am new to R.  I thing this will be simple, but I don't yet know my way

around.

I am generating character strings from the system clock that represent 
integers, and I want to convert them to integer values.  Strtoi works 
well, except when there are leading zeros on the string.  Could anyone 
suggest a way to remove those leading zeros?

Thanks

Paul






-- 
E. Paul Wileyto, Ph.D.
Assistant Professor of Biostatistics
Tobacco Use Research Center
School of Medicine, U. of Pennsylvania
3535 Market Street, Suite 4100
Philadelphia, PA  19104-3309

215-746-7147
Fax: 215-746-7140
e...@upenn.edu

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


This e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}}

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


[R] auto.arima fit error

2010-10-07 Thread Vangani, Ruchi
I am trying to use auto.arima to fit a univariate time series and do forecast.

This is an imaginary data on monthly outcomes of 2 years and I want to forecast 
the outcome for next 12 months of next year.

data Data1;
input RR;
datalines;
12
14
17
15
13
15
15
14
15
14
16
15
15
18
16
16
15
14
15
16
16
14
13
12
;
run;

I successfully took this data into R and used the auto.arima codes but am 
getting the following error:
fit - auto.arima(Data1)

Error in model.frame.default(formula = x ~ 1, drop.unused.levels = TRUE) :
  invalid type (list) for variable 'x'



Please help.

Thanks,
Ruchi


The information contained in this communication is highl...{{dropped:18}}

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


[R] Tinn-R and DDE

2010-10-07 Thread Al.x

Hi folks,

I'm trying to get these call-tip things to work in Tinn-R. I expect them
to be somewhat like Microsoft's Intellisense? Anyways, I copy-pasted the
recommended Rprofile.site and adjusted it to fit the location of my
Tinn-R.exe... It looks like this:

##===
## Tinn-R: necessary packages and functions
## Tinn-R: = 2.2.0.2 with TinnR package = 1.0.3
##===
## Set the URL of the preferred repository, below some examples:
options(repos='http://software.rc.fas.harvard.edu/mirrors/R/') # USA
#options(repos='http://cran.ma.imperial.ac.uk/') # UK
#options(repos='http://brieger.esalq.usp.br/CRAN/') # Brazil

library(utils)

## Check necessary packages
necessary - c('TinnR', 'svSocket')
installed - necessary %in% installed.packages()[, 'Package']
if (length(necessary[!installed]) =1)
install.packages(necessary[!installed])

## Load packages
library(TinnR)
library(svSocket)

## Uncoment the two lines below if you want Tinn-R starts always R starts
## (Observation: check the path of Tinn-R.exe)
options(IDE='C:/Programs/Tinn-R/bin/Tinn-R.exe')
trStartIDE()

## Set options
options(use.DDE=T)

## Start DDE
trDDEInstall()

.trPaths - paste(paste(Sys.getenv('APPDATA'), '\\Tinn-R\\tmp\\', sep=''),
c('', 'search.txt', 'objects.txt', 'file.r', 'selection.r', 'block.r',
'lines.r'), sep='')


---
When opening R, Tinn-R opens as expected, so at least that's working
correctly. The help file in Tinn-R now recommends that I try the call-tip
by making a little function in R and then testing it in Tinn-R to see if the
call-tip pops up. 

What am I doing wrong? Do I need to assign a hot-key (like ctrl+space in
eclipse) or something?

Cheers,
Alex




-- 
View this message in context: 
http://r.789695.n4.nabble.com/Tinn-R-and-DDE-tp2966894p2966894.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Looking for a book/tutorial with the following context:

2010-10-07 Thread alaios

I would like to thank you for spending your time to reply to my post.
So far I checked the links provided. 

What is still missing is to find some information how local and global
variables work in R. Do you know any link for that? (checked the book but
from the table of contents is not clear if are included or not).


Best Regards
Alex
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Looking-for-a-book-tutorial-with-the-following-context-tp2965206p2966951.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Lattice: Histogram in splom diagonals

2010-10-07 Thread Alejo C.S.
Dear David, it works just perfect. Thanks a lot for the help

Sincerely,

Alejo

2010/10/7 David Winsemius dwinsem...@comcast.net


 On Oct 7, 2010, at 9:04 AM, Alejo C.S. wrote:

  Dear list, I want to plot several variables with splom and in the main
 diagonal, instead of the  variable names, I'd like to plot an histogram of
 corresponding variables. Searching I did not find the correct syntax, only
 some tips in an old post in the list, but this comments help to plot only
 density lines instead of histograms. I had some code, but it fails to plot
 (I've commented the problematic lines):


 splom(iris[,1:4], panel = function(x, y, ...) {
panel.xyplot(x, y, ...)
 panel.lmline(x,y,...)
 }
 #, diag.panel=function(x,...){
 #  panel.histogram(x,...)
 #}

 )

 Thanks a lot in advance!


 From 2007 posting by Barnes (only return from RSiteSearch with modified
 Targets for splom diag.panel histogram:

 panel.hist.splom-function(x, ...)
 {
 yrng - current.panel.limits()$ylim
 h - hist(x, plot = FALSE)
 breaks - h$breaks; nB - length(breaks)
 y - h$counts; y - yrng[1] + 0.95 * diff(yrng) * y / max(y)
 panel.rect(breaks[-nB], yrng[1], breaks[-1], y, col=cyan, ...)
 }
 my.plot = function(data) {
  splom( ~data,
   lower.panel=function(x, y, ...) {
 panel.xyplot(x, y, ...)
 panel.lmline(x,y,...)},
   upper.panel=function(x, y, ...) {

 panel.xyplot(x, y, ...)
 panel.lmline(x,y,...)},
   diag.panel = panel.hist.splom)
 }

 my.plot(iris[,1:4])


 David Winsemius, MD
 West Hartford, CT



[[alternative HTML version deleted]]

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


[R] auto.arima error

2010-10-07 Thread Vangani, Ruchi
I am trying to use auto.arima to fit a univariate time series and do forecast.

This is an imaginary data on monthly outcomes of 2 years and I want to forecast 
the outcome for next 12 months of next year.

data Data1;
input RR;
datalines;
12
14
17
15
13
15
15
14
15
14
16
15
15
18
16
16
15
14
15
16
16
14
13
12
;
run;

I successfully took this data into R and used the auto.arima codes but am 
getting the following error:
fit - auto.arima(Data1)

Error in model.frame.default(formula = x ~ 1, drop.unused.levels = TRUE) :
  invalid type (list) for variable 'x'



Please help.

Thanks,
Ruchi



The information contained in this communication is highl...{{dropped:18}}

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


Re: [R] Looking for a book/tutorial with the following context:

2010-10-07 Thread David Winsemius


On Oct 7, 2010, at 11:00 AM, alaios wrote:



I would like to thank you for spending your time to reply to my post.
So far I checked the links provided.

What is still missing is to find some information how local and global
variables work in R. Do you know any link for that? (checked the  
book but

from the table of contents is not clear if are included or not).


http://cran.r-project.org/doc/manuals/R-intro.html#Scope




Best Regards
Alex
--
View this message in context: 
http://r.789695.n4.nabble.com/Looking-for-a-book-tutorial-with-the-following-context-tp2965206p2966951.html


(You might consider including context in future postings. See the  
little [  ] icon on the Nabble web interface.)


--
David Winsemius, MD
West Hartford, CT

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


Re: [R] Truncating leading zeros in strings

2010-10-07 Thread E. Paul Wileyto
 Thanks...  As I mentioned, I am new to R, and as.integer was not 
what I stumbled onto.  I looked up string conversion in the reference 
manual, and strtoi is what came up.


P

On 10/7/2010 10:35 AM, David Winsemius wrote:


On Oct 7, 2010, at 9:57 AM, E. Paul Wileyto wrote:



I am new to R.  I thing this will be simple, but I don't yet know my 
way around.


I am generating character strings from the system clock that 
represent integers, and I want to convert them to integer values.  
Strtoi works well, except when there are leading zeros on the 
string.  Could anyone suggest a way to remove those leading zeros?


as.integer doesn't work? (If you are dealing in different base than 
10, then you really should say so.)


 as.integer(123)
[1] 123

Or pass through sub(^[0]+, , vals)
 sub(^[0]+, , 123)
[1] 123

An example is expected in such situations. Please do now read the 
Posting Guide.


--
E. Paul Wileyto, Ph.D.
Assistant Professor of Biostatistics
Tobacco Use Research Center
School of Medicine, U. of Pennsylvania
3535 Market Street, Suite 4100
Philadelphia, PA  19104-3309

215-746-7147
Fax: 215-746-7140
e...@upenn.edu

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


Re: [R] How to run own R functions in JRI

2010-10-07 Thread lord12

So I copy and pasted my function to the R startup file. However, in my
function, I change directories. When I run the function in Eclipse, I get a
message in the console, Cannot change working directory. Why is this?

-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-run-own-R-functions-in-JRI-tp2965288p2966910.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] subtraction based on two groups in a dataframe

2010-10-07 Thread 1Rnwb

Hi The reshape suggestions works great on my previous data, but I am unable
to make is work on the new dataset. It actually works but only gives me the
output of single row, instead of 96 rows.
The dataset has two control groups control 1 and control 2, two disease
groups viz disease 1 and disease 2 a total of 384 values
plate.idwell.id Group   HYB rlt1
P1  A1  control1SKOV3hyb0.19
P1  A2  disease1SKOV3hyb0.21
P1  A3  control1SKOV3hyb0.205
P1  A4  disease1SKOV3hyb0.206
P1  B1  disease2SKOV3hyb0.217
P1  B2  control2SKOV3hyb0.646
P1  B3  disease2SKOV3hyb0.371
P1  B4  control2SKOV3hyb0.56

when I use
ydat - reshape(ydat, idvar = c('plate.id','HYB'), timevar
='Group',direction = 'wide')

I get

plate.idwell.id.control1HYB.control1rlt1.control1   
well.id.disease1
HYB.disease1rlt1.disease1   well.id.disease2HYB.disease2
rlt1.disease2
well.id.control2HYB.control2rlt1.control2
P1  A1  SKOV3hyb0.19A2  SKOV3hyb0.21B1  
SKOV3hyb0.217   B2  SKOV3hyb0.646


instead of 96 rows of data, only one row comes, i tried new.row.names but
that is not working.
I would appreciate the help.
Thanks

-- 
View this message in context: 
http://r.789695.n4.nabble.com/subtraction-based-on-two-groups-in-a-dataframe-tp2716104p2966918.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] using a package function inside another function

2010-10-07 Thread Alison Callahan
Hello all,

I am trying to use the micEcon 'insertRow' function inside a function
I have written. For example:

insert_row_test - function(m){

  insertRow(m,nrow(m)+1,v=0,rName=test)

}

However, when I try to call the 'insert_row_test' function (after
loading the micEcon package), it does not insert a row into the matrix
I pass in. When I call the insertRow function exactly as above in the
R console, it works with no problem.

Can anyone tell me why this is, and how to fix this problem?

Thank you!

Alison Callahan
PhD candidate
Department of Biology
Carleton University

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


[R] aggregate text column by a few rows

2010-10-07 Thread Tan, Richard
Hi, R function aggregate can only take summary stats functions, can I
aggregate text columns?  For example, for the dataframe below, 

 

 a - rbind(data.frame(id=1, name='Tom',
hobby='fishing'),data.frame(id=1, name='Tom',
hobby='reading'),data.frame(id=2, name='Mary',
hobby='reading'),data.frame(id=3, name='John',
hobby='boating'),data.frame(id=2, name='Mary', hobby='running'))

 a

  id name   hobby

1  1  Tom fishing

2  1  Tom reading

3  2 Mary reading

4  3 John boating

5  2 Mary running

 

 

I want output as 

b

id name hobbies

1 Tomfishing reading

2 Mary reading running

3 John boating

 

 

 

Thanks,

Richard

 


[[alternative HTML version deleted]]

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


[R] venneuler() - customize a few things.

2010-10-07 Thread Karl Brand

Esteemed UseRs and DevelopeRs,

Just coming to terms with the very attractive proportional venn 
gernator, venneuler(), but would like to customize a few things.


Is it possible to-

-suppress all circle labels?
-suppress only certain circle labels?
-print specific text strings at specified locations within the circles? 
and unions?

-specify circle colors?
-specify label font, size  color?

All thoughts and response's greatly appreciated, cheers,

Karl

--
Karl Brand k.br...@erasmusmc.nl
Department of Genetics
Erasmus MC
Dr Molewaterplein 50
3015 GE Rotterdam
P +31 (0)10 704 3409 | F +31 (0)10 704 4743 | M +31 (0)642 777 268

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


Re: [R] aggregate text column by a few rows

2010-10-07 Thread jim holtman
try this using sqldf:

 a
  id name   hobby
1  1  Tom fishing
2  1  Tom reading
3  2 Mary reading
4  3 John boating
5  2 Mary running
 require(sqldf)
 sqldf('select name, group_concat(hobby) hobby from a group by id', 
 method='raw')
  name   hobby
1  Tom fishing,reading
2 Mary reading,running
3 John boating


On Thu, Oct 7, 2010 at 11:52 AM, Tan, Richard r...@panagora.com wrote:
 Hi, R function aggregate can only take summary stats functions, can I
 aggregate text columns?  For example, for the dataframe below,



 a - rbind(data.frame(id=1, name='Tom',
 hobby='fishing'),data.frame(id=1, name='Tom',
 hobby='reading'),data.frame(id=2, name='Mary',
 hobby='reading'),data.frame(id=3, name='John',
 hobby='boating'),data.frame(id=2, name='Mary', hobby='running'))

 a

  id name   hobby

 1  1  Tom fishing

 2  1  Tom reading

 3  2 Mary reading

 4  3 John boating

 5  2 Mary running





 I want output as

b

 id name hobbies

 1 Tom    fishing reading

 2 Mary reading running

 3 John boating







 Thanks,

 Richard




        [[alternative HTML version deleted]]

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




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

What is the problem that you are trying to solve?

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


Re: [R] using a package function inside another function

2010-10-07 Thread Andrew Miles

Try adding a statement at the beginning of your function:

require(micEcon)

See if that helps.

Andrew Miles
Department of Sociology
Duke University

On Oct 7, 2010, at 11:47 AM, Alison Callahan wrote:


Hello all,

I am trying to use the micEcon 'insertRow' function inside a function
I have written. For example:

insert_row_test - function(m){

 insertRow(m,nrow(m)+1,v=0,rName=test)

}

However, when I try to call the 'insert_row_test' function (after
loading the micEcon package), it does not insert a row into the matrix
I pass in. When I call the insertRow function exactly as above in the
R console, it works with no problem.

Can anyone tell me why this is, and how to fix this problem?

Thank you!

Alison Callahan
PhD candidate
Department of Biology
Carleton University

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


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


Re: [R] using a package function inside another function

2010-10-07 Thread Ethan Brown
Hi Alison,

By default, a function in R creates a copy of the variable that you
pass into it. insertRow() looks to be unusual in that it actually
changes the variable you pass into the function.

So if you run your insert_row_test(x), the function will create a copy
of x, insert a row into it using insertRow(), and then return that new
matrix.  So all you need to do is assign the output of your function
to the original object, like so:

 x - matrix(1:9, 3, 3)

 x
 [,1] [,2] [,3]
[1,]147
[2,]258
[3,]369

 x - insert_row_test(x)

 x
 [,1] [,2] [,3]
147
258
369
test000


See 
http://cran.r-project.org/doc/manuals/R-intro.html#Writing-your-own-functions
for more on this topic.

HTH,
Ethan Brown


On Thu, Oct 7, 2010 at 9:47 AM, Alison Callahan
alison.calla...@gmail.com wrote:
 Hello all,

 I am trying to use the micEcon 'insertRow' function inside a function
 I have written. For example:

 insert_row_test - function(m){

  insertRow(m,nrow(m)+1,v=0,rName=test)

 }

 However, when I try to call the 'insert_row_test' function (after
 loading the micEcon package), it does not insert a row into the matrix
 I pass in. When I call the insertRow function exactly as above in the
 R console, it works with no problem.

 Can anyone tell me why this is, and how to fix this problem?

 Thank you!

 Alison Callahan
 PhD candidate
 Department of Biology
 Carleton University

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


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


Re: [R] Counting unique items in a list of matrices

2010-10-07 Thread Jim Silverton
Hello,
I gave  a list of 2 x 2 matrices called matlist. I have about 5000 2 x 2
matrices. I would like to count how many of each 2 x 2 unique matrix I have.
So I am thinking that I need a list of the unique 2 x 2 matrices and their
counts. Can anyone help.

-- 
Thanks,
Jim.

[[alternative HTML version deleted]]

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


Re: [R] Odp: Vector replace 0 elements without using a loop

2010-10-07 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Petr PIKAL
 Sent: Thursday, October 07, 2010 12:13 AM
 To: rivercode
 Cc: r-help@r-project.org
 Subject: [R] Odp: Vector replace 0 elements without using a loop
 
 Hi
 
 
 r-help-boun...@r-project.org napsal dne 07.10.2010 07:16:01:
 
  
  Hi,
  
  With a vector like:
  
  x = c (22, 23, 22.5, 0,0,24, 0, 23.2, 23.5, 0,0,0, 26)
  
  How can I replace the 0's with the previous last value 
 without looping
  through the vector ?
 
 Change your zeroes to NA values
 x[x==0]-NA
 
 use na.locf function from zoo package
 
 library(zoo)
 
 x-na.locf(x)
 
 Regards
 Petr

Or if you want to do it from scratch try defining the
following function.  For each element of the logical
vector x it returns the index of the last TRUE
entry up to that point.

indexOfMostRecentTrueEntry - function (x) 
{
stopifnot(is.logical(x))
x - x  !is.na(x) # treat NA's as FALSE's
retval - cummax(seq_along(x) * x)
retval[retval == 0] - NA # in case x starts with FALSE
retval
}

and get your result with

  x[indexOfMostRecentTrueEntry(x!=0)] 

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 
 
  
  Something tells me I am missing the obvious.
  
  Thanks,
  Chris
  -- 
  View this message in context: 
 http://r.789695.n4.nabble.com/Vector-replace-0-
  elements-without-using-a-loop-tp2966191p2966191.html
  Sent from the R help mailing list archive at Nabble.com.
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


Re: [R] aggregate text column by a few rows

2010-10-07 Thread David Winsemius

Or:

 data.frame( hobs= tapply(a$hobby, list( a$name), c))
 hobs
Tom  fishing, reading
Mary reading, running
John  boating

Note Jim's gives you the names as columns while this has them as  
rownames. Further differences : my version has the column as lists  
whereas Jim's returns them as concatenated strings. Each result may  
have it advantages depending on your applications.


 dfrm[1,1][[1]][1]
[1] fishing
 fishing %in% dfrm[1,1][[1]]
[1] TRUE

With Jim's you could not individually access the hobby items:

 dfrm2[1,2]
[1] fishing,reading
# But you could grep them
 grepl(fishing , dfrm2[1,2])
[1] TRUE
--
David

On Oct 7, 2010, at 12:08 PM, jim holtman wrote:


try this using sqldf:


a

 id name   hobby
1  1  Tom fishing
2  1  Tom reading
3  2 Mary reading
4  3 John boating
5  2 Mary running

require(sqldf)
sqldf('select name, group_concat(hobby) hobby from a group by id',  
method='raw')

 name   hobby
1  Tom fishing,reading
2 Mary reading,running
3 John boating


On Thu, Oct 7, 2010 at 11:52 AM, Tan, Richard r...@panagora.com  
wrote:

Hi, R function aggregate can only take summary stats functions, can I
aggregate text columns?  For example, for the dataframe below,




a - rbind(data.frame(id=1, name='Tom',

hobby='fishing'),data.frame(id=1, name='Tom',
hobby='reading'),data.frame(id=2, name='Mary',
hobby='reading'),data.frame(id=3, name='John',
hobby='boating'),data.frame(id=2, name='Mary', hobby='running'))


a


 id name   hobby

1  1  Tom fishing

2  1  Tom reading

3  2 Mary reading

4  3 John boating

5  2 Mary running





I want output as


b


id name hobbies

1 Tomfishing reading

2 Mary reading running

3 John boating







Thanks,

Richard




   [[alternative HTML version deleted]]

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





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

What is the problem that you are trying to solve?

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] How to run own R functions in JRI

2010-10-07 Thread jcress410

I guess the best answer to your question depends on the specifics of the
implementation, but, i think if I were in your situation and I wanted to be
able to call a function foo found in file foo.R  every time a user
clicked a button, i'd just 

source(path to foo.R)  

which just parses the contents of the file as if they were included in the
script.  So, foo.R could be sourced from any of your other scripts.  

Just make sure to rm(list = loaded files) so that you dont try to read the
same function twice, or you could wrap your source() call in something like 

if (!grepl(FOO,ls())) { source(path too foo.R) }  
which will only load if the function isn't already loaded. 

I guess that could be cause problems if you don't know absolute directory
structure, but ?source() may help you figure out if you can use relative
paths.. 

if not, off the top of my head you might be able to discover the path using
file.path() 

I guess if your program installs files to directories in some predictable
way, this won't be a problem. 


-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-run-own-R-functions-in-JRI-tp2965288p2967140.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Lottery with Data Frame Rows

2010-10-07 Thread Rodrigo Aluizio
Hi List.

I've to perform a sequence of conditional sampling without repetition from a
very simple data frame.

It contains the samples and people names (which picked the sample).
Something like this (but much more longer):

 


Sample

Picker


4ME1B2 B

Ana


4ME1C1 B

Ana


4ME1D2 C

Ana


4ME1E2 C

Ana


4ME1E3 A

Ana


4ME2A1 C

Ana


4ME2D2 B

Ana


4CME3 B

Ingrid


4CME7 C

Ana


4ME1B1 C

Elis


4ME1B2 C

Elis


4ME1C1 C

Elis


4ME1D2 A

Elis


4ME2B2 B

Elis


4ME2B3 A

Ingrid


4ME2B4 A

Elis


4ME2C1 B

Elis


4ME2C4 C

Elis


4ME2D3 C

Ingrid


4ME2C2 C

Ingrid


4ME2D1 B

Ingrid


4ME2D2 C

Ingrid

 

Well then, these samples must be reviewed. To do so I've to create random
sets of samples for each person that not include the person's own samples
and, obviously, can't repeat samples at the next set (of the next person).
Each person will have to review the same number of samples he/she picked.

 

I've tried sample() function, but it doesn't do well with data frames, so
it's getting tricky to work around.

 

Any suggestions or ideas?

 

Thank you for your attention and sorry for the silly question.

 

---

MSc.  mailto:r.alui...@gmail.com Rodrigo Aluizio


[[alternative HTML version deleted]]

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


Re: [R] Counting unique items in a list of matrices

2010-10-07 Thread jcress410

I may or may not have the most elegant solution to this problem, but if it
were me, I would probably put them all in a list and then   

unique_matrix_list - unique(list_of_matrix)

# number of unique matricies: 
length(unique_matrix_list) 

# count the number of each matrix, 
for (m in unique_matrix_list) {
count_m - which(list_of_matrix == m) 
}

but, i havent done this myself. 

see 

?unique  

and maybe that'll help. 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Re-Counting-unique-items-in-a-list-of-matrices-tp2967112p2967151.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] How do I set the dispersion parameter in poisson glm?

2010-10-07 Thread Huso, Manuela
Dear R users,

I would like to fit a glm with Poisson distribution and log link with a known 
dispersion parameter.  I do not want to estimate the dispersion parameter.  I 
know what it is, so I simply want to fix it at a constant for this and other 
models to follow.  My simple, no covariate model is:

Tall.glm-glm(Seedling~1, 
family=poisson, 
offset(log(area)),
data=tallPSME.df)

I want to fix the dispersion parameter at 2.5.  How can I do this, please?

Many thanks in advance for your help,

Manuela
 
::
Manuela Huso
Consulting Statistician
201H Richardson Hall
Department of Forest Ecosystems and Society
Oregon State University
Corvallis, OR   97331
ph: 541-737-6232
fx: 541-737-1393

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


Re: [R] How do I set the dispersion parameter in poisson glm?

2010-10-07 Thread Achim Zeileis

On Thu, 7 Oct 2010, Huso, Manuela wrote:


Dear R users,

I would like to fit a glm with Poisson distribution and log link with a known 
dispersion parameter.  I do not want to estimate the dispersion parameter.  I 
know what it is, so I simply want to fix it at a constant for this and other 
models to follow.  My simple, no covariate model is:

Tall.glm-glm(Seedling~1,
family=poisson,
offset(log(area)),
data=tallPSME.df)

I want to fix the dispersion parameter at 2.5.  How can I do this, please?


The parameter estimation is invariant to the choice of dispersion 
parameter, hence you don't have to change anything in the glm() call 
above.


Only for the inference you have to set the dispersion, e.g.

summary(Tall.glm, dispersion = 2.5)

hth,
Z


Many thanks in advance for your help,

Manuela


::

Manuela Huso
Consulting Statistician
201H Richardson Hall
Department of Forest Ecosystems and Society
Oregon State University
Corvallis, OR   97331
ph: 541-737-6232
fx: 541-737-1393

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



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


Re: [R] R: Tools for thinking about data analysis and graphics

2010-10-07 Thread Greg Snow
I think that R/S's biggest advantage is in the ways you can store data.  It 
does not force you to fit your data to a single spreadsheet like table, but 
rather encourages you to think about your data and find the correct way to 
store it.  Lists and objects are a great advantage for keeping related things 
combined together.  I can have multiple data sets available all at the same 
time, but still in separate objects.

Also the results of routines can be kept in a way that makes working with them 
easy.  I remember working with programs that just had one big spreadsheet and 
ending up with 3 different columns of residuals from 3 different models, but 
then forgot which residuals matched which model.  With R/S each lm object has 
the residuals stored with it including the call to remind us what model and 
options were used.  One plot that I like to make when exploring different 
models is:

 plot( fitted(model1), fitted(model2) ); abline(0,1)

That is simple and straight forward in R/S, but much more difficult in other 
programs.


I also like the fact that the graphics system will let me create anything I 
want.  There are tools to create the standard plots (and I really like the 
simplicity of calling plot on an lm object and getting a standard set of 
diagnostics), but there are also the tools to create any plot I can imagine, or 
add any information I feel useful to an existing plot.

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


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Michael Friendly
 Sent: Wednesday, October 06, 2010 3:06 PM
 To: R-help
 Subject: [R] R: Tools for thinking about data analysis and graphics
 
   I'm giving a talk about some aspects of language and conceptual tools
 for thinking about how
 to solve problems in several programming languages for statistical
 computing and graphics. I'm particularly
 interested in language features that relate to:
 
 o expressive power: ease of translating what you want to do into the
 results you want
 o elegance: how well does the code provide a simple human-readable
 description of what is done?
 o extensibility: ease of generalizing a method to wider scope
 o learnability: your learning curve (rate, asymptote)
 
 For R, some things to cite are (a) data and function objects, (b)
 object-oriented methods (S3  S4); (c) function mapping over data with
 *apply methods and plyr.
 
 What other language features of R should be on this list?  I would
 welcome suggestions (and brief illustrative examples).
 
 -Michael
 
 
 --
 Michael Friendly Email: friendly AT yorku DOT ca
 Professor, Psychology Dept.
 York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
 4700 Keele StreetWeb:   http://www.datavis.ca
 Toronto, ONT  M3J 1P3 CANADA
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] reshape from wide to long, ordering of varying

2010-10-07 Thread stefan.d...@gmail.com
Hello,
I have data in the following form

  age sex Int.Prev.Est.1 Int.Prev.Est.2 Int.Prev.Est.3
Int.Prev.Est.4 Int.Prev.Est.5
93110  93   0   23.75482   57.86592   9.755003
4.343534   4.280714
93610  93   1   53.36475   39.47247   4.381618
1.622119   1.159044
94110  94   0   23.47514   58.23936  10.789339
3.690415   3.805741
94610  94   1   53.34524   39.32675   4.602774
1.520247   1.204988
95110  95   0   23.76256   58.18757   9.583178
4.186825   4.279866
95610  95   1   53.14037   39.55376   4.313944
1.632805   1.359124

and want to get it in the form:

age sex cat  Int.Prev.Est
93   0 1   23.75482
93   0 2   57.86592
93   0 3   9.755003
93   0 4   4.343534
()
95   141.632805
95   1   5  1.359124


I am getting close with reshape, but somehow the categorie varialbe is
orderd 1...1, 2...2,3...3,4...4,55 instad as 1,2,3,4,5,1,2,3

reshape(UK.INT,  idvar=1:2,times=1:5, varying=c(Int.Prev.Est.1,
Int.Prev.Est.2, Int.Prev.Est.3, Int.Prev.Est.4,
Int.Prev.Est.5),v.names='cat', direction=long) #


Here is some example data

dput(tail(UK.INT))

structure(list(age = c(93, 93, 94, 94, 95, 95), sex = c(0, 1,
0, 1, 0, 1), Int.Prev.Est.1 = c(2647L, 19706L, 1832L, 15229L,
1277L, 11456L), Int.Prev.Est.2 = c(6448L, 14576L, 4545L, 11227L,
3127L, 8527L), Int.Prev.Est.3 = c(1087L, 1618L, 842L, 1314L,
515L, 930L), Int.Prev.Est.4 = c(484L, 599L, 288L, 434L, 225L,
352L), Int.Prev.Est.5 = c(477L, 428L, 297L, 344L, 230L, 293L)), .Names
= c(age,
sex, Int.Prev.Est.1, Int.Prev.Est.2, Int.Prev.Est.3,
Int.Prev.Est.4, Int.Prev.Est.5), row.names = c(93110, 93610,
94110, 94610, 95110, 95610), class = data.frame)

I am wondering whether this is really feasible with reshape. Thanks
for any hint.
Best,
stefan

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


Re: [R] aggregate text column by a few rows

2010-10-07 Thread Henrique Dallazuanna
Try this:

aggregate(hobby ~ id + name, a, FUN = toString)


On Thu, Oct 7, 2010 at 12:52 PM, Tan, Richard r...@panagora.com wrote:

 Hi, R function aggregate can only take summary stats functions, can I
 aggregate text columns?  For example, for the dataframe below,



  a - rbind(data.frame(id=1, name='Tom',
 hobby='fishing'),data.frame(id=1, name='Tom',
 hobby='reading'),data.frame(id=2, name='Mary',
 hobby='reading'),data.frame(id=3, name='John',
 hobby='boating'),data.frame(id=2, name='Mary', hobby='running'))

  a

  id name   hobby

 1  1  Tom fishing

 2  1  Tom reading

 3  2 Mary reading

 4  3 John boating

 5  2 Mary running





 I want output as

 b

 id name hobbies

 1 Tomfishing reading

 2 Mary reading running

 3 John boating







 Thanks,

 Richard




[[alternative HTML version deleted]]

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




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

[[alternative HTML version deleted]]

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


Re: [R] text/mtext axis labels on graphs

2010-10-07 Thread Greg Snow
For your specific question, Jim's answer of staxlab is the best, but for 
general placing of text or other graphics elements relative to figure, plot, or 
device look at the grconvertX and grconvertY functions.

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


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Martin Hughes
 Sent: Thursday, October 07, 2010 4:30 AM
 To: r-help@r-project.org
 Subject: [R] text/mtext axis labels on graphs
 
 
 Hello everyone
 
 I have problem with axis labels on graphs, I have my code as below:
 
 plot(0,0,xlim=c(1,ncol(PA)),ylim=c(1,nrow(PA)),main=Stratigraphic
 Range,xlab=Time
 Bins,ylab=Taxa,cex.axis=1.5,cex.lab=2,cex.main=2.5,mgp=c(5,1.5,0),xa
 xt=n)
 
 text(1:(length(strat_name)), y=  0, adj=1,
 srt=45,labels=strat_name,xpd=TRUE, cex=1) #adds text to x axis giving
 the strat names
 abline(v=(1:ncol(PA))+.5,col=grey,lty=3)
 
 cl - rep(1,nrow(PA))
 cl[DistM$kill] - 2
 for (i in 1:nrow(PA)) segments(min(which(PA[i,]==1))-.5,i,
 max(which(PA[i,]==1))+.5,i,lwd=3,col=cl[i])
 
 
 My problem lies with the x axis tick labels, I want my own labels
 added in so removed the one the plot function adds in normally.
 
 I use the text function as it allows me to fit my own text tick labels
 at an angle, HOWEVER the text function is VERY sensitive to the Y
 axis, I have multiple graphs on a page, each with a different y axis,
 so the labels move up and down depending on the scale of the Y.
 
 
 I tried using mtext which lets you put the text a certain distance
 from the x margin line, HOWEVER this function does not let you tilt
 the text to be an an angle
 
 
 Can anyone tell me of a way I can have both - ie text that is a
 specified distance from the margin AND tilted at and angle
 
 Thanks
 Martin
 
 
 
 
 --
 Martin Hughes
 MPhil/PhD Research in Biology
 Rm 1.07,  4south
 University of Bath
 Department of Biology and Biochemistry
 Claverton
 BathBA2 7AY
 Tel: 01225 385 437
 m.hug...@bath.ac.uk
 http://www.bath.ac.uk/bio-sci/biodiversity-lab/hughes.html
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] RE : RE : R getting slower until it breaks...

2010-10-07 Thread Bastien Ferland-Raymond
Actually, I rechecked the paging and thought about it more, and realized the 
windows was French and therefore, the , was the decimal separator and not the 
thousand separator.  So the paging was staying around 6 (not 6000) most of 
the time and hitting the 100 other times. It looks a little bit more normal.

About the I/O.  I'm really not familiar with this concept.  I really want to 
answer your questions and test all of that, but I don't know how.  Can you 
check the I/O in R, or are you suppose to do it in Windows?  What 
function/program should I use?


Thanks
Bastien

  

De : jim holtman [jholt...@gmail.com]
Date d'envoi : 6 octobre 2010 20:09
À : Bastien Ferland-Raymond
Cc : r-help@R-project.org
Objet : Re: RE : [R] R getting slower until it breaks...

6000 pages/sec sounds very high, but if your CPU utilization is
decreasing over time, this is one of the causes.  The system is paging
memory out and having to wait for I/O to complete and therefore is not
using the CPU.  What other I/O is your system doing?  When you are
partitioning the image, are you doing a lot of I/O to write it out?
So I would assume that you are somehow blocking on I/O and that is why
your utilization (and throughput) is decreasing.  You might want to
look at what your application is doing in this area.  Paging is also
contributed to reading in some data.

When are are breaking apart the data, are you starting the read from
the front of the file each time, or picking up where you left off?  So
you might want to take a closer look around how you are doing your
I/O.

On Wed, Oct 6, 2010 at 3:06 PM, Bastien Ferland-Raymond
bastien.ferland-raymon...@ulaval.ca wrote:
 Thanks a lot for your quick answer.  Here is my answer to your questions:

 Have you looked to see how fast your memory might be growing?
 BFR- Yes I did, it's not to bad, it's starts around 60 000ko, rise up to 120 
 000 at the most, so not too scary.

 Are you leaving around any large objects that should be removed?
 BFR- I was carefull making sure the function doesn't create anything that 
 would be visible with objects().  Could it be creating other type (hidden) 
 objects?  Maybe, but I'm not very familliar with that stuff.

 Have you looked to see if you are paging?
 BFR- I just red the wiki about paging, didn't know that term before.  If I 
 look at perfmon, its looks like keeping steady at 6000 pages/s with rare 
 peaks as high as 900 000. Does it sounds normal?  How can it affect R?

 Is it your CPU time that is increasing, or your wall clock time?
 BFR- If I go to the task manager - performance.  R is initially using around 
 40% of the processor (so around 80% of 1 core) but with (real) time passing, 
 it gets lower and lower to get as low as 6% (12% of one core).  I was 
 surprized to see that as usually my simulation in R use one whole core.

 It sounds like there might be some memory leak that might be causing your 
 process size to grow and possibly causing paging.  You will need to gather 
 some of the performance data that perfmon can provide and look at the memory 
 usage, CPU time and I/O rates over time to see if there are any changes.
 BFR- The term Memory leak feels right with my problem.  Is there ways I can 
 control/detect/prevent this kind of problem in R.  Also, how can I check the 
 I/O, i never looked at that before.

 Thanks again

 Bastien



 On Wed, Oct 6, 2010 at 2:11 PM, Bastien Ferland-Raymond
 bastien.ferland-raymon...@ulaval.ca wrote:
 Hello R-users,

 I'm currently facing a pretty hard problem which I'm hopping you'll be able 
 to help me with.  I'm using R to create images.  That alone is not the 
 problem, the problem is that I'm using R to create 168 000 images...  My 
 code (which is given below) use different package (raster and rgdal) to 
 import a image (size 20gig) and divide it into 168 000 pictures that are 100 
 pixel x 100 pixel.  The code works fine for making the images, but if I ask 
 it to run all 168 000, it always breaks around 15 000.

 It starts with the code being able to make around 2 pictures per second, but 
 then it slows down and after around 2000 pictures it's only 1 picture per 
 second.  Later on it's getting closer to 1 pictures every 3 seconds etc.  
 until it bugs.  I have no error message, only Windows that tells me that R 
 encounter a problem and most be close...  Initially I though it was a 
 Windows problem, that I couldn't put too many file into a folder and it was 
 slowering it down.  Then I divided my batch process into smaller (5000 
 files) folder but it didn't help, still breaks at 15 000.  I also try to do 
 gc() after each 5000 pictures to save memory but it didn't help either.  I 
 removed every loops from the code because I thought it was the problem, but 
 it was just faster at bugging... After the bug, I need to restart the 
 computer if I want to go back to the initial speed.

 I'm pretty much running out of options.  It's there limitation 

Re: [R] aggregate text column by a few rows

2010-10-07 Thread Phil Spector

Richard -
  Yes, you certainly can use aggregate to acheive what you want:


aggregate(a$hobby,a['name'],paste,collapse=' ')

  name   x
1  Tom fishing reading
2 Mary reading running
3 John boating

- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu


On Thu, 7 Oct 2010, Tan, Richard wrote:


Hi, R function aggregate can only take summary stats functions, can I
aggregate text columns?  For example, for the dataframe below,




a - rbind(data.frame(id=1, name='Tom',

hobby='fishing'),data.frame(id=1, name='Tom',
hobby='reading'),data.frame(id=2, name='Mary',
hobby='reading'),data.frame(id=3, name='John',
hobby='boating'),data.frame(id=2, name='Mary', hobby='running'))


a


 id name   hobby

1  1  Tom fishing

2  1  Tom reading

3  2 Mary reading

4  3 John boating

5  2 Mary running





I want output as


b


id name hobbies

1 Tomfishing reading

2 Mary reading running

3 John boating







Thanks,

Richard




[[alternative HTML version deleted]]

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



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


Re: [R] venneuler() - customize a few things.

2010-10-07 Thread Ista Zahn
Hi Kari,

On Thu, Oct 7, 2010 at 12:05 PM, Karl Brand k.br...@erasmusmc.nl wrote:
 Esteemed UseRs and DevelopeRs,

 Just coming to terms with the very attractive proportional venn gernator,
 venneuler(), but would like to customize a few things.

 Is it possible to-

Say v is a VennDiagram:

 -suppress all circle labels?

v$labels - rep(, length(v$labels)

 -suppress only certain circle labels?

v$labels - c(A, , C) ## don't print label for B

 -print specific text strings at specified locations within the circles? and
 unions?

text(.5, .5, my text here) will print my text here right in the
middle of the graph. Adjusting the coordinates will adjust the
location. You can use v$centers and v$diameters to position text
relative to the center of the circles, but I'm not sure how to
automatically find the unions. You could do it by trial and error.

 -specify circle colors?

v$colors - c(.1, .5, .9)

 -specify label font, size  color?


see ?text

Best,
Ista

 All thoughts and response's greatly appreciated, cheers,

 Karl

 --
 Karl Brand k.br...@erasmusmc.nl
 Department of Genetics
 Erasmus MC
 Dr Molewaterplein 50
 3015 GE Rotterdam
 P +31 (0)10 704 3409 | F +31 (0)10 704 4743 | M +31 (0)642 777 268

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




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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


Re: [R] aggregate text column by a few rows

2010-10-07 Thread Tan, Richard
Thank you!
Richard


-Original Message-
From: jim holtman [mailto:jholt...@gmail.com] 
Sent: Thursday, October 07, 2010 12:08 PM
To: Tan, Richard
Cc: r-help@r-project.org
Subject: Re: [R] aggregate text column by a few rows

try this using sqldf:

 a
  id name   hobby
1  1  Tom fishing
2  1  Tom reading
3  2 Mary reading
4  3 John boating
5  2 Mary running
 require(sqldf)
 sqldf('select name, group_concat(hobby) hobby from a group by id', 
 method='raw')
  name   hobby
1  Tom fishing,reading
2 Mary reading,running
3 John boating


On Thu, Oct 7, 2010 at 11:52 AM, Tan, Richard r...@panagora.com wrote:
 Hi, R function aggregate can only take summary stats functions, can I
 aggregate text columns?  For example, for the dataframe below,



 a - rbind(data.frame(id=1, name='Tom',
 hobby='fishing'),data.frame(id=1, name='Tom',
 hobby='reading'),data.frame(id=2, name='Mary',
 hobby='reading'),data.frame(id=3, name='John',
 hobby='boating'),data.frame(id=2, name='Mary', hobby='running'))

 a

  id name   hobby

 1  1  Tom fishing

 2  1  Tom reading

 3  2 Mary reading

 4  3 John boating

 5  2 Mary running





 I want output as

b

 id name hobbies

 1 Tom    fishing reading

 2 Mary reading running

 3 John boating







 Thanks,

 Richard




        [[alternative HTML version deleted]]

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




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

What is the problem that you are trying to solve?

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


[R] FDR

2010-10-07 Thread will . eagle
Dear R users,

I am wondering about the following results:
 p.adjust(c(0.05,0.05,0.05),fdr)
[1] 0.05 0.05 0.05
 p.adjust(c(0.05,0.04,0.03),fdr)
[1] 0.05 0.05 0.05

Why does p.adjust(..., fdr) not adjust p-values, if they are constant? 
Does somebody have an explanation or can point to a reference?

Thanks in advance,

Will

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


[R] Need help for loop code, thanks

2010-10-07 Thread wangguojie2006

Dear fellows,

I've been working this problem for a day and still can't see where the
problem is. I really appreciate if anyone can help me out. 

My data is like:

V1V2 v3
1  a   1.3
1  a   1.5
1  b   2.0
1  a   2.3
1  a   3.4
1  c   5.5
1  d   6.0
1  a   7.0
2  f1.5
2  g1.6
2  f 3.4
2  f 4.0
2  g4.6
2  c5.0
2  a5.3

What I want to do is to get the max value of V3 for each unique V2 in each
V1. For example, when V1=1, unique V2 is (a, b, c, d), and corresponding max
value of V3 is (7.0, 2.0, 5.5, 6.0). And V1=2, unique V2 is (f, g, c, a) and
max value of V3 is (4.0, 4.6, 5.0, 5.3). Then combinne these max values.

My code is like:

z-NULL
x-NULL;y-NULL
for (j in 1:2)
{ 
  x-unique(V2[V1==j])
   for (i in 1:length(x))
{
 y[i]-max(V3[V2==x[i]  V1==j])
}
  z-c(z,y)
}
length(z)

My problem is the length of z is much bigger than the length of I'm supposed
to get, like above data, I should only get 8 max values. But the code will
return me a number bigger than 8. I'm thinking there might be some
overlapping problem. Can someone help?

Thank you for your time.

Best,





-- 
View this message in context: 
http://r.789695.n4.nabble.com/Need-help-for-loop-code-thanks-tp2967036p2967036.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to run own R functions in JRI

2010-10-07 Thread lord12

Nevermind about the previous post. However, I in the retest sample code, I
can run my own function in the command line. But, say I am creating a GUI
and I want the user to enter the model parameters. How do I, within the java
code, explicity call my unique function without going to the console? 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-run-own-R-functions-in-JRI-tp2965288p2967038.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] R - Confidence Intervals

2010-10-07 Thread Christian Goelz
Dear Sirs,

I was hoping you can help me, I am quite desperate in finding a  
solution for my problem! I have looked everywhere on the net and tried  
hundreds of codes, but I am still not anywhere close to the solution.  
I am quite new to R, so please excuse if this seems simple:

I am trying to use R to analyse some stocks, but I can't get the  
theoretical confidence interval (95%) for my sample:

e.g. IBM:

library('tseries')
data-get.hist.quote(instrument=IBM, start=2000-01-01,  
end=2010-10-04, quote=c(O,H,L,C,A,V),  
compression='d',provider=yahoo, retclass=zoo)
names(IBM)

I have defined the parameters as follows:

Pt=IBM$Adj.Close
r=diff(log(Pt))
l=length(Pt)
mu=mean(r)
t=2:l

Given the formula for confidence intervals E(logPt)=logP0+μ*t 
+1.96*sqrt(t)*s^2, I tried to define a formula in R:

  logP1=numeric()
  logP1[1]=log(Pt[1])
  logP1[2:l]=logP1[1]+cumsum(logP1+mu*t+c(-1.96,1.96)*sqrt(t)*sd(Pt))
  P1=exp(logP1)

However, although I don't receive an error message, I cannot show the  
result!

Many thanks in advance for your assistance with this!

Yours sincerely

Christian


[[alternative HTML version deleted]]

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


Re: [R] reshape from wide to long, ordering of varying

2010-10-07 Thread Henrique Dallazuanna
Try this:

reshape(UK.INT, direction = 'long', varying = list(grep(Int.Prev.Est,
names(UK.INT


On Thu, Oct 7, 2010 at 2:05 PM, stefan.d...@gmail.com stefan.d...@gmail.com
 wrote:

 Hello,
 I have data in the following form

  age sex Int.Prev.Est.1 Int.Prev.Est.2 Int.Prev.Est.3
 Int.Prev.Est.4 Int.Prev.Est.5
 93110  93   0   23.75482   57.86592   9.755003
 4.343534   4.280714
 93610  93   1   53.36475   39.47247   4.381618
 1.622119   1.159044
 94110  94   0   23.47514   58.23936  10.789339
 3.690415   3.805741
 94610  94   1   53.34524   39.32675   4.602774
 1.520247   1.204988
 95110  95   0   23.76256   58.18757   9.583178
 4.186825   4.279866
 95610  95   1   53.14037   39.55376   4.313944
 1.632805   1.359124

 and want to get it in the form:

 age sex cat  Int.Prev.Est
 93   0 1   23.75482
 93   0 2   57.86592
 93   0 3   9.755003
 93   0 4   4.343534
 ()
 95   141.632805
 95   1   5  1.359124


 I am getting close with reshape, but somehow the categorie varialbe is
 orderd 1...1, 2...2,3...3,4...4,55 instad as 1,2,3,4,5,1,2,3

 reshape(UK.INT,  idvar=1:2,times=1:5, varying=c(Int.Prev.Est.1,
 Int.Prev.Est.2, Int.Prev.Est.3, Int.Prev.Est.4,
 Int.Prev.Est.5),v.names='cat', direction=long) #


 Here is some example data

 dput(tail(UK.INT))

 structure(list(age = c(93, 93, 94, 94, 95, 95), sex = c(0, 1,
 0, 1, 0, 1), Int.Prev.Est.1 = c(2647L, 19706L, 1832L, 15229L,
 1277L, 11456L), Int.Prev.Est.2 = c(6448L, 14576L, 4545L, 11227L,
 3127L, 8527L), Int.Prev.Est.3 = c(1087L, 1618L, 842L, 1314L,
 515L, 930L), Int.Prev.Est.4 = c(484L, 599L, 288L, 434L, 225L,
 352L), Int.Prev.Est.5 = c(477L, 428L, 297L, 344L, 230L, 293L)), .Names
 = c(age,
 sex, Int.Prev.Est.1, Int.Prev.Est.2, Int.Prev.Est.3,
 Int.Prev.Est.4, Int.Prev.Est.5), row.names = c(93110, 93610,
 94110, 94610, 95110, 95610), class = data.frame)

 I am wondering whether this is really feasible with reshape. Thanks
 for any hint.
 Best,
 stefan

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




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

[[alternative HTML version deleted]]

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


Re: [R] reshape from wide to long, ordering of varying

2010-10-07 Thread Gabor Grothendieck
On Thu, Oct 7, 2010 at 1:05 PM, stefan.d...@gmail.com
stefan.d...@gmail.com wrote:
 Hello,
 I have data in the following form

      age sex Int.Prev.Est.1 Int.Prev.Est.2 Int.Prev.Est.3
 Int.Prev.Est.4 Int.Prev.Est.5
 93110  93   0       23.75482       57.86592       9.755003
 4.343534       4.280714
 93610  93   1       53.36475       39.47247       4.381618

 and want to get it in the form:

 age sex cat  Int.Prev.Est
 93   0     1   23.75482
 93   0     2   57.86592
 93   0     3   9.755003
 93   0     4   4.343534
 ()

Try this:

reshape(UK.INT, dir = long, idvar = 1:2, varying = list(3:7),
v.names = Int.Prev.Est, timevar = cat)


-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] Does R have function/package works similar to SAS's 'PROC REG'?

2010-10-07 Thread CZ

Hi, Josh, 

What we are doing is, we have a microarray data set with 2000 genes and
roughly 60 samples split 2:1 cancer:normal.  So we essentially have one
binary response and 2000 continuous predictors. We want to use this to
develop an ensemble-based classifier method in which the members of the
ensemble are all gene pairs.  To this end, we want to use the Leaps and
Bounds algorithm to obtain the K=200, 500, or 1000 best-performing subsets
of Size=2 Genes to feed into our ensemble.  We had partial success doing
this in SAS, as follows:

1.  the SAS Logistic Procedure (the natural choice for our binary outcome,
because it does logistic regression) would include only the first 60 genes
into the Leaps and Bounds search, and print for each of the remaining genes
a message saying it was a linear combination of the first 60 genes  was
therefore being excluded.   

2.  However, the SAS Reg Procedure (not the natural choice for our binary
outcome, because it does linear regression) would include all 2000 genes
into the Leaps and Bounds search, and not be bothered by the linear
dependencies.  And it gave results that held up quite well in subsequent
analyses.

So, first we want to replicate in R what we did in SAS with the linear
regression, i.e., use the Leaps and Bounds algorithm to obtain the K=200,
500, or 1000 best-performing linear-regression models of Size=2 Genes from
our list of 2000 genes, and not have it exclude genes for being a linear
combination of the basis set.  Then we want to use R to try and do what SAS
could not: get logistic regression to do the same thing and not have it
exclude genes for being a linear combination of the basis set.  

Thanks. 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Does-R-have-function-package-works-similar-to-SAS-s-PROC-REG-tp2965657p2967295.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] FDR

2010-10-07 Thread Jeremy Miles
This is correct.  Wikipedia is not bad, and provides some references.
 Another web page:
http://courses.ttu.edu/isqs6348-westfall/images/6348/BonHolmBenHoch.htm



http://courses.ttu.edu/isqs6348-westfall/images/6348/BonHolmBenHoch.htm
Jeremy





On 7 October 2010 10:37, will.ea...@gmx.net wrote:

 Dear R users,

 I am wondering about the following results:
  p.adjust(c(0.05,0.05,0.05),fdr)
 [1] 0.05 0.05 0.05
  p.adjust(c(0.05,0.04,0.03),fdr)
 [1] 0.05 0.05 0.05

 Why does p.adjust(..., fdr) not adjust p-values, if they are constant?
 Does somebody have an explanation or can point to a reference?

 Thanks in advance,

 Will

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




-- 
Jeremy Miles
Psychology Research Methods Wiki: www.researchmethodsinpsychology.com

[[alternative HTML version deleted]]

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


[R] problem with colors

2010-10-07 Thread ANJAN PURKAYASTHA
Hi,
I have a data set of 47 columns. I would like to create a boxplot for each
column, each boxplot of a different colour.
So I created a vector col1. This vector has a subset of the colors
returned by color()- red, cyan, green etc.
Now I use the command: boxplot(dataset, col= col1) expecting to see 47
boxplots, each of a different colour.
Here is the problem: the boxplots are drawn correctly but it seems that only
the first few colours in col1 are being used in a repeated pattern.
Anybody has any ideas on how to tackle this?
Thanks in advance,
Anjan

-- 
===
anjan purkayastha, phd.
research associate
fas center for systems biology,
harvard university
52 oxford street
cambridge ma 02138
phone-703.740.6939
===

[[alternative HTML version deleted]]

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


Re: [R] Computing a Mantel-Haenszel chi-square using a continuous variable as the matching criterion

2010-10-07 Thread David Winsemius


On Oct 7, 2010, at 2:21 PM, Barth B. Riley wrote:


Dear list

I would like to compute a Mantel-Haenszel chi-square in which the  
matching variable is a continuous variable. The MH chi-square is  
used to assess the relationship between two categorical variables at  
each level or strata defined by a third variable. Specifically I  
would like to know if there is a straightforward way to divide the  
matching variable into levels, in which each level has a minimum of  
20 cases. Any information would be greatly appreciated.


Why? What makes you think matching would be valuable? (...or even  
valid, for that matter.)





Thanks in advance

Barth


--

David Winsemius, MD
West Hartford, CT

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


Re: [R] problem with colors

2010-10-07 Thread Phil Spector

Anjan -
   I think you'll need to give us more information -- I can't
reproduce the problem.  For example,


dat = data.frame(matrix(rnorm(47000),100,47))
cols = sample(colors(),47)
boxplot(dat,col=cols)


doesn't repeat any of the colors in cols.
- Phil


On Thu, 7 Oct 2010, ANJAN PURKAYASTHA wrote:


Hi,
I have a data set of 47 columns. I would like to create a boxplot for each
column, each boxplot of a different colour.
So I created a vector col1. This vector has a subset of the colors
returned by color()- red, cyan, green etc.
Now I use the command: boxplot(dataset, col= col1) expecting to see 47
boxplots, each of a different colour.
Here is the problem: the boxplots are drawn correctly but it seems that only
the first few colours in col1 are being used in a repeated pattern.
Anybody has any ideas on how to tackle this?
Thanks in advance,
Anjan

--
===
anjan purkayastha, phd.
research associate
fas center for systems biology,
harvard university
52 oxford street
cambridge ma 02138
phone-703.740.6939
===

[[alternative HTML version deleted]]

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



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


Re: [R] How do I set the dispersion parameter in poisson glm?

2010-10-07 Thread Huso, Manuela
Thank you so much for your reply, Z.  Of course, you are correct about the 
overdispersion not affecting parameter estimation.  But my goal is comparison 
of several models using QAIC and the dispersion parameter enters the QAIC 
calculation.  I suppose I could calculate the QAIC of all models using my fixed 
dispersion parameter, but I was hoping I could just set it in the glm call and 
let the software calculate QAIC appropriately for me.

Manuela 

::
Manuela Huso
Consulting Statistician
201H Richardson Hall
Department of Forest Ecosystems and Society
Oregon State University
Corvallis, OR   97331
ph: 541-737-6232
fx: 541-737-1393

-Original Message-
From: Achim Zeileis [mailto:achim.zeil...@uibk.ac.at] 
Sent: Thursday, October 07, 2010 9:48 AM
To: Huso, Manuela
Cc: r-help@r-project.org
Subject: Re: [R] How do I set the dispersion parameter in poisson glm?

On Thu, 7 Oct 2010, Huso, Manuela wrote:

 Dear R users,

 I would like to fit a glm with Poisson distribution and log link with a known 
 dispersion parameter.  I do not want to estimate the dispersion parameter.  I 
 know what it is, so I simply want to fix it at a constant for this and other 
 models to follow.  My simple, no covariate model is:

 Tall.glm-glm(Seedling~1,
   family=poisson,
   offset(log(area)),
   data=tallPSME.df)

 I want to fix the dispersion parameter at 2.5.  How can I do this, please?

The parameter estimation is invariant to the choice of dispersion 
parameter, hence you don't have to change anything in the glm() call 
above.

Only for the inference you have to set the dispersion, e.g.

summary(Tall.glm, dispersion = 2.5)

hth,
Z

 Many thanks in advance for your help,

 Manuela

 ::
 Manuela Huso
 Consulting Statistician
 201H Richardson Hall
 Department of Forest Ecosystems and Society
 Oregon State University
 Corvallis, OR   97331
 ph: 541-737-6232
 fx: 541-737-1393

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


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


[R] confusion matrix

2010-10-07 Thread Gregory Ryslik
Hi Everyone, 

In follow up to my previous question, I wrote some code that correctly makes a 
confusion matrix as I need it. However, it only works when the numbers are 
between 1 and n. If the possible outcomes are between 0 and n, then I can't 
reference row 0 of the matrix and the code breaks. Does anyone have any easy 
fixes for this? I've attached the entire code to this email.


As always, thank you for your help!

Greg

Code:

answers-matrix(c(4,2,1,3,2,1),nrow =6)
mat1- matrix(c(3,3,4,NA,4,2),nrow = 6)
mat2-matrix(c(3,2,1,4,2,3),nrow = 6)
mat3-matrix(c(4,2,2,2,1,1),nrow = 6)
mat4-matrix(c(4,2,1,3,1,4),nrow = 6)
mat5-matrix(c(2,3,1,4,2,3),nrow = 6)

matrixlist- list(mat1,mat2,mat3,mat4,mat5)
predicted.values- matrix(unlist(matrixlist),nrow = dim(mat1)[1])
 
confusion.matrix-matrix(0, nrow = length(as.vector(unique(answers))),ncol = 
length(as.vector(unique(answers

for(i in 1:dim(predicted.values)[1]){
for(j in 1: dim(predicted.values)[2]){

predicted.value- predicted.values[i,j]
if(!is.na(predicted.value)){
true.value- answers[i,]
confusion.matrix[true.value, predicted.value] - 
confusion.matrix[true.value,predicted.value]+1
}
}
}

class.error- diag(1- prop.table(confusion.matrix,1))
confusion.matrix-cbind(confusion.matrix,class.error)
confusion.data.frame-as.data.frame(confusion.matrix)
names(confusion.data.frame)[1:length(as.vector(unique(answers)))]- 
1:length(as.vector(unique(answers)))
names(confusion.data.frame)[length(as.vector(unique(answers)))+1]- 
class.error
[[alternative HTML version deleted]]

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


Re: [R] R - Confidence Intervals

2010-10-07 Thread David Winsemius


On Oct 7, 2010, at 12:01 PM, Christian Goelz wrote:


Dear Sirs,

I was hoping you can help me, I am quite desperate in finding a
solution for my problem! I have looked everywhere on the net and tried
hundreds of codes, but I am still not anywhere close to the solution.
I am quite new to R, so please excuse if this seems simple:

I am trying to use R to analyse some stocks, but I can't get the
theoretical confidence interval (95%) for my sample:

e.g. IBM:

library('tseries')
data-get.hist.quote(instrument=IBM, start=2000-01-01,
end=2010-10-04, quote=c(O,H,L,C,A,V),
compression='d',provider=yahoo, retclass=zoo)
names(IBM)


Problem 1: You name your data data and now you are referring to it  
by IBM


I have defined the parameters as follows:

Pt=IBM$Adj.Close


Problem 2... there is no column named Adj.Close


r=diff(log(Pt))
l=length(Pt)
mu=mean(r)
t=2:l

Given the formula for confidence intervals E(logPt)=logP0+μ*t
+1.96*sqrt(t)*s^2, I tried to define a formula in R:

 logP1=numeric()

logP1[1]=log(Pt[1])
logP1[2:l]=logP1[1]+cumsum(logP1+mu*t+c(-1.96,1.96)*sqrt(t)*sd(Pt))


Is it really true that s^2 is well estimated by that cusum?


P1=exp(logP1)


I ask that because P1 (after correction of the errors noted above)  
blows up , i.e. increases to Inf.


However, although I don't receive an error message, I cannot show the
result!


Did you type:

P1   # ??? and then watch the stream of 2075 mostly Inf values?

Really? I got all sorts of cascading errors.
--
David.




Many thanks in advance for your assistance with this!

Yours sincerely

Christian



--
David Winsemius, MD
West Hartford, CT

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


Re: [R] How do I set the dispersion parameter in poisson glm?

2010-10-07 Thread Ben Bolker
Huso, Manuela manuela.huso at oregonstate.edu writes:

 
 Thank you so much for your reply, Z.  Of course, you are correct about
  the overdispersion not affecting
 parameter estimation.  But my goal is comparison of several models 
 using QAIC and the dispersion
 parameter enters the QAIC calculation.  I suppose I could calculate 
 the QAIC of all models using my fixed
 dispersion parameter, but I was hoping I could just set it in the 
 glm call and let the software calculate
 QAIC appropriately for me.

  [snip]

   Which QAIC() function are you using?
  The ones in the MuMIn,AICcmodavg, and bbmle packages all
have parameters that should allow you to set the dispersion
parameter when you calculate QAIC.

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


Re: [R] Need help for loop code, thanks

2010-10-07 Thread Peter Ehlers

On 2010-10-07 12:09, Phil Spector wrote:

Is this what you're looking for?


dat = read.table(textConnection('V1V2 v3

+ 1  a   1.3
+ 1  a   1.5
+ 1  b   2.0
+ 1  a   2.3
+ 1  a   3.4
+ 1  c   5.5
+ 1  d   6.0
+ 1  a   7.0
+ 2  f1.5
+ 2  g1.6
+ 2  f 3.4
+ 2  f 4.0
+ 2  g4.6
+ 2  c5.0
+ 2  a5.3'),header=TRUE)

aggregate(dat$v3,dat[c('V1','V2')],max)

V1 V2   x
1  1  a 7.0
2  2  a 5.3
3  1  b 2.0
4  1  c 5.5
5  2  c 5.0
6  1  d 6.0
7  2  f 4.0
8  2  g 4.6

- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu



Or with plyr:

 require(plyr)
 result - ddply(dat, .(V1,V2), summarize, MAX=max(v3))

  -Peter Ehlers




On Thu, 7 Oct 2010, wangguojie2006 wrote:



Dear fellows,

I've been working this problem for a day and still can't see where the
problem is. I really appreciate if anyone can help me out.

My data is like:

V1V2 v3
1  a   1.3
1  a   1.5
1  b   2.0
1  a   2.3
1  a   3.4
1  c   5.5
1  d   6.0
1  a   7.0
2  f1.5
2  g1.6
2  f 3.4
2  f 4.0
2  g4.6
2  c5.0
2  a5.3

What I want to do is to get the max value of V3 for each unique V2 in each
V1. For example, when V1=1, unique V2 is (a, b, c, d), and corresponding max
value of V3 is (7.0, 2.0, 5.5, 6.0). And V1=2, unique V2 is (f, g, c, a) and
max value of V3 is (4.0, 4.6, 5.0, 5.3). Then combinne these max values.

My code is like:

z-NULL
x-NULL;y-NULL
for (j in 1:2)
{
  x-unique(V2[V1==j])
   for (i in 1:length(x))
{
 y[i]-max(V3[V2==x[i]  V1==j])
}
  z-c(z,y)
}
length(z)

My problem is the length of z is much bigger than the length of I'm supposed
to get, like above data, I should only get 8 max values. But the code will
return me a number bigger than 8. I'm thinking there might be some
overlapping problem. Can someone help?

Thank you for your time.

Best,





--
View this message in context: 
http://r.789695.n4.nabble.com/Need-help-for-loop-code-thanks-tp2967036p2967036.html
Sent from the R help mailing list archive at Nabble.com.

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



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


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


Re: [R] R - Confidence Intervals

2010-10-07 Thread Christian Goelz
Dear David,

Thank you for your prompt response. 

I understand that this may seem like an simple problem to you, but I have never 
done this before, so please excuse the mistakes along the line!

May I revise the code according to your suggestion and, should I have further 
problems, ask you for your help again?

Many thanks!

Best regards

Christian

Sent from my wireless smartphone device

On 7 Oct 2010, at 20:50, David Winsemius dwinsem...@comcast.net wrote:

 
 On Oct 7, 2010, at 12:01 PM, Christian Goelz wrote:
 
 Dear Sirs,
 
 I was hoping you can help me, I am quite desperate in finding a
 solution for my problem! I have looked everywhere on the net and tried
 hundreds of codes, but I am still not anywhere close to the solution.
 I am quite new to R, so please excuse if this seems simple:
 
 I am trying to use R to analyse some stocks, but I can't get the
 theoretical confidence interval (95%) for my sample:
 
 e.g. IBM:
 
 library('tseries')
 data-get.hist.quote(instrument=IBM, start=2000-01-01,
 end=2010-10-04, quote=c(O,H,L,C,A,V),
 compression='d',provider=yahoo, retclass=zoo)
 names(IBM)
 
 Problem 1: You name your data data and now you are referring to it by IBM
 
 I have defined the parameters as follows:
 
 Pt=IBM$Adj.Close
 
 Problem 2... there is no column named Adj.Close
 
 r=diff(log(Pt))
 l=length(Pt)
 mu=mean(r)
 t=2:l
 
 Given the formula for confidence intervals E(logPt)=logP0+μ*t
 +1.96*sqrt(t)*s^2, I tried to define a formula in R:
 
 logP1=numeric()
 logP1[1]=log(Pt[1])
 logP1[2:l]=logP1[1]+cumsum(logP1+mu*t+c(-1.96,1.96)*sqrt(t)*sd(Pt))
 
 Is it really true that s^2 is well estimated by that cusum?
 
 P1=exp(logP1)
 
 I ask that because P1 (after correction of the errors noted above) blows up 
 , i.e. increases to Inf.
 
 However, although I don't receive an error message, I cannot show the
 result!
 
 Did you type:
 
 P1   # ??? and then watch the stream of 2075 mostly Inf values?
 
 Really? I got all sorts of cascading errors.
 -- 
 David.
 
 
 
 Many thanks in advance for your assistance with this!
 
 Yours sincerely
 
 Christian
 
 
 -- 
 David Winsemius, MD
 West Hartford, CT
 

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


  1   2   >