Re: [R] sorting a data.frame by mean values of grouped data

2008-03-13 Thread sjbarry
Thanks Mark,

I see that I made an error in my original request for help. I got my 
labels and groups mixed up (see below). Nonetheless, your code has been 
a good pointer in the direction of a solution. I'll post it up when I 
have it working.

Thanks again,
Stephen Barry.

I should have written it more like this:
Given data.frame:
   Value Group Label
 55 D Small
 33 D Small
 11 D Small
 55 D Small
 66 D Small
 11 D Small
 19 A   Big
 29 A   Big
 39 A   Big
 3 B Small
 2 B Small
 5 B Small
 6 B Small
 5 B Small
 6 B Small
 2 C   Big
 3 C   Big
 3 C   Big
 3 C   Big
 3 C   Big
 3 C   Big
 3 C   Big
end up with:
   Value Group Label
19 A   Big
29 A   Big
39 A   Big
 2 C   Big
 3 C   Big
 3 C   Big
 3 C   Big
 3 C   Big
 3 C   Big
 3 C   Big
55 D Small
33 D Small
11 D Small
55 D Small
66 D Small
11 D Small
 3 B Small
 2 B Small
 5 B Small
 6 B Small
 5 B Small
 6 B Small


 

Mark W Kimpel wrote:
 Stephen,

 I am sure someone will have a more elegant solution, but the following 
 works. Mark

 d.lst - split(x = d, f = as.factor(d$Group), drop = FALSE)
 d.lst.mn - sapply(d.lst, FUN = 
 function(x){mean(as.numeric(as.character(x$Value)))})
 o - order(d.lst.mn, decreasing = TRUE)
 d.lst.mn - d.lst.mn[o]

 e - NULL
 for (i in 1:length(d.lst.mn)){
   if (i == 1){
 e - d[d$Group == names(d.lst.mn)[i],]
   } else {
 e - rbind(e, d[as.character(d$Group) == names(d.lst.mn)[i],])
   }
 }
 e

 Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
 Indiana University School of Medicine

 15032 Hunter Court, Westfield, IN  46074

 (317) 490-5129 Work,  Mobile  VoiceMail
 (317) 204-4202 Home (no voice mail please)

 mwkimpelatgmaildotcom

 **


 sjbarry wrote:
 Hi,

 I have what I think is a fairly straightforward problem. I've looked 
 through the FAQ's and mailing lists but have been unable to identify 
 a solution, probably because I don't understand the language well 
 enough.

 I have a set of data d, with 3 columns as shown,
 I want to sort the data Group, mean(Value by Label). I know that this 
 can be done for one level, say Label, using factor() but I cannot see 
 how to extend that. I have included the code to create the data.frame 
 below and would greatly appreciate a solution or a link to a similar 
 problem that has already been solved in the mailing list.
Value Label Group
  19   Big A
  29   Big A
  39   Big A
  55 Small D
  33 Small D
  11 Small D
  55 Small D
  66 Small D
  11 Small D
  2   Big C
  3   Big C
  3   Big C
  3   Big C
  3   Big C
  3   Big C
  3   Big C
  3 Small B
  2 Small B
  5 Small B
  6 Small B
  5 Small B
  6 Small B

 Value - c(19,29,39,55,33,11,55,66,11,2,3,3,3,3,3,3,3,2,5,6,5,6)
 Group - c(A,A,A,D,D,D,D,D,D,
 C,C,C,C,C,C,C,B,B,B,B,B,B)
 Label - c(Big,Big,Big,
 Small,Small,Small,Small,Small,Small,
 Big,Big,Big,Big,Big,Big,Big,
 Small,Small,Small,Small,Small,Small)
 d - as.data.frame(cbind(Value, Label, Group))


 Thanks

 Stephen Barry


-- 
Stephen Barry
School of Earth and Environmental Sciences
University of Wollongong
Northfields Ave.
Wollongong, NSW. 2522
Australia

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] use bootstrap to get MLE of lamda from the exp model

2008-03-13 Thread jinjin

the data are 3,5,7,18,43,85,91,98,100,130,230,487, it follows an exp(lamda)
model, how to use bootstrap to obtain MLE of lamda, bias, sd.  Thanks a lot

so far my code is 
  obj-boot(data,statistic,R=2000)
here statistic should call a function to get an estimate of lamda I think,
anyone can help ?I am new to bootstrap:)
-- 
View this message in context: 
http://www.nabble.com/use-bootstrap-to-get-MLE-of-lamda-from-the-exp-model-tp16021176p16021176.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] survival curve for only certain values of a factor

2008-03-13 Thread Dieter Menne
Chang Liu changisme at hotmail.com writes:

 
 data(aml)
 If I use instead dummy variables:
 
 aml$x1 = (aml$x==maintained)aml$x2 = (aml$x==unmaintained)
 and I want to plot the survival curve using x1, x2, and I just want the 2
levels, rather than 4 curves from:

I don's understand what you want, but the first step is definitively incorrect
apart from the missint line break. The levels of aml are

Maintained,Nonmaintained

so both your == lead to all-false levels.

Dieter

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


Re: [R] Bessel functions of complex argument

2008-03-13 Thread baptiste Auguié
Many thanks for this information!

I'm pretty sure Matlab can handle complex argument in besselj,  
although i haven't checked myself,
 http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/ 
access/helpdesk/help/techdoc/ref/besselj.html 

After some more thinking, it turns out my code doesn't need a complex  
argument at the moment, i can live with the simplest case where it is  
real. Good to know where to go if this is to change in the future,  
though.

Thanks again,

baptiste


On 10 Mar 2008, at 08:49, Robin Hankin wrote:

 Hello Baptiste

 Bessel functions with complex arguments
 are not supported in R.

 Neither  matlab nor the  Gnu Scientific Library support them either.

 . . . but . . .

 the pari/gp system (released on the GPL) does:


 ? besselj(1+I,3)
 %3 = 0.6919067491368555819808728680 + 0.4484268613977010268818252591*I
 ?


 You can access some pari/gp functionality from within R
 by using the elliptic package, although unfortunately
 its wrapper function, P.pari(),  is not quite flexible enough
 to deal with besselj().

 I'd be happy to discuss this offline; P.pari() will need only
 minor changes to accommodate besselj().



 HTH


 Robin




 On 9 Mar 2008, at 13:44, baptiste Auguié wrote:

 Dear R users,


 I'm porting a piece of Matlab code to R, but I'm now stuck with the
 following: I need an equivalent of besselJ(x, nu) that can handle a
 complex argument x. I couldn't find any R implementation. I did find
 a possible fortran solution in SLATEC ( http://www.netlib.org/ 
 slatec/
 , CBESJ-C), however I've never tried to use external C or Fortran
 code together with my R code, so I'm not sure where to go for a
 simple solution.

 Any advice welcome,

 Best regards

 baptiste

 _

 Baptiste Auguié

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

 Phone: +44 1392 264187

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

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

 --
 Robin Hankin
 Uncertainty Analyst and Neutral Theorist,
 National Oceanography Centre, Southampton
 European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743


_

Baptiste Auguié

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

Phone: +44 1392 264187

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

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

2008-03-13 Thread Dai Nishikawa
Dear everyone

 

I tried reading my own Excel spreadsheet data in R, but kept getting an
warning message 'incomplete final line by readTableHeader'F:\mm1data.xls'.
On viewing its rows and columns, only 'NA's were returned. Having difficult
time with this problem for too long, any solution would be greatly
appreciated. 

 

Thank you in advance

 

Dai Nishikawa (PhD candidate)

 

Biomechanics Laboratory

Tamaki Campus, University of Auckland

(0)9 373 7599 ext 82560

Mobile: 0212144873

 


[[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] Spatially Lagged Predictor Variable Models

2008-03-13 Thread Thibaut Jombart
ArunPrasad wrote:
 Hi Everyone,
  I am doing a project based on Spatially Lagged Predictor
 Variable Models, I would like to know which package in R would execute this
 model. Also, I am new to this field of spatial statistics. Any suggestions
 for a good book on spatial regression analysis would be appreciated. Thanks
 Again.

 Cheers
 Arun

   
Hi,

you may have a look at lag.listw in the package 'spdep' by R Bivand, 
which computes a lag vector given a variable and a list of spatial 
weights. There is a nice review of spatial methods in ecology, already 
mentioned on this list I think:

Carsten F. Dormann, Jana M. McPherson, Miguel B. Araújo, Roger Bivand, 
Janine Bolliger, Gudrun Carl, Richard G. Davies, Alexandre Hirzel, 
Walter Jetz, W. Daniel Kissling, Ingolf Kühn, Ralf Ohlemüller, Pedro R. 
Peres-Neto, Björn Reineking, Boris Schröder, Frank M. Schurr and Robert 
Wilson,. (2007) Methods to account for spatial autocorrelation in the 
analysis of species distributional data: a review. /Ecography/ 30:5, 609–628

This may be a good starting point.

Cheers,

Thibaut.

-- 
##
Thibaut JOMBART
CNRS UMR 5558 - Laboratoire de Biométrie et Biologie Evolutive
Universite Lyon 1
43 bd du 11 novembre 1918
69622 Villeurbanne Cedex
Tél. : 04.72.43.29.35
Fax : 04.72.43.13.88
[EMAIL PROTECTED]
http://lbbe.univ-lyon1.fr/-Jombart-Thibaut-.html?lang=en
http://adegenet.r-forge.r-project.org/

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


[R] Sealed for setGeneric

2008-03-13 Thread Christophe Genolini
Hi the list

When two setGeneric occurs on the same function, the second erage the 
first and erase all the function previously define.
Is it possible to prevent that ? Is it possible to declare a setGeneric 
that can not be erased later ?
Something like the |sealed for setMethod...|
||
|Thanks|
||
Christophe

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 set type of censored data in coxph regression

2008-03-13 Thread Hung-Hsuan Chen (Sean)
Dear R users,
I tried to analysis the hazard function of some data by coxph function
in survival package.
The type of the data include left-censored, right-censored, both
right-censored and
left-censored (btw, does this has a technical term?), and complete ones.

I noticed that event (one parameter in Surv()) might be an indicator
for the censored
type. However, whenever I set event to 2 or 3, the Surv() function
always returns error msg.

Take the following code segment for example,
 state = c(0, 0, 1, 1, 2, 2, 3, 3, 0, 1)
 begin = c(0, 0, 1, 1, 1, 2, 2, 1, 0, 1)
 end   = c(8, 8, 9, 7, 8, 6, 9, 8, 8, 9)
 Surv(begin, end, state)
will get err msg: Surv(begin, end, state) : Invalid status value

When trying the following code segment:
 state = c(0, 0, 1, 1, 0, 1, 0, 1, 0, 1)
 Surv(begin, end, state)
will get [1] (0,8+] (0,8+] (1,9 ] (1,7 ] (1,8+] (2,6 ] (2,9+] (1,8 ]
(0,8+] (1,9 ]

I can understand the second code segment, but I cannot understand why
the first code
segments failed.

Can anyone give me some examples or suggestions? Thanks a lot.

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


Re: [R] howto find corresponding values in datasource?

2008-03-13 Thread bartjoosen

The x coordinate of the max y value:

x[which.max(mydiff$y)]




Jonas Stein wrote:
 
 Hi,
 
 
 i am sure, that this is a noob-question, but i have searched for 
 hours without any good result. 
 
 I want to draw a vertical line through the maximum of the first
 derivation.
 
 Here is a small example. 
 
 --8-[mydata.csv]
 HM
 115
 222
 323
 417
 510
 --8-[myquestion.R]--
 mydata - read.table(mydata.csv, header=TRUE, sep=\t)
 
 attach(mydata)
 # make a smooth fit through the points and calculate the first derivation
 d/dx
 myspl - smooth.spline(H, M, all.knots = FALSE, nknots = 10, spar=0.5) 
 mydiff - predict(myspl, 0:max(H), deriv=1)
 
 
 # find the maximum peak max(y)
 y1=y2= max(mydiff$y)
 
 # now i want to plot a line through the maximum of the derivation
 # how can i get the x-coordinate?
 # segments(x1,y1,x2,y2)
 
 detach()
 --8-
 
 Thank you,
 
 -- 
 Jonas Stein
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/howto-find-corresponding-values-in-datasource--tp16016130p16023738.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] Specifying relative position of text in a plot

2008-03-13 Thread Prof Brian Ripley
On Thu, 13 Mar 2008, Tom La Bone wrote:

 Thanks for all of the suggestions. The key key here seems to be using the
 par function to change the coordinate system like so

 plot(rnorm(100), rnorm(100))
 op - par(usr)
 par(usr = c(0, 1, 0, 1))
 text(0.5,0.5,TEST)
 par(usr = op)

 Prof Ripley commented that this approach will also work on log plots, but I
 don't think I completely understand what is going on because this does not
 work for me

 plot(rlnorm(100), rlnorm(100),log=xy)
 op - par(usr)
 par(usr = c(0, 1, 0, 1))
 text(0.5,0.5,TEST)
 par(usr = op)

 Any hints on what I am doing wrong with the log plots? Thanks again for the
 help.

You need

par(usr = c(0, 1, 0, 1), xlog=FALSE, ylog=FALSE)

to set up a non-log coordinate system.

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

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


Re: [R] Specifying relative position of text in a plot

2008-03-13 Thread Tom La Bone

Thanks for all of the suggestions. The key key here seems to be using the
par function to change the coordinate system like so 

plot(rnorm(100), rnorm(100))
op - par(usr)
par(usr = c(0, 1, 0, 1))
text(0.5,0.5,TEST)
par(usr = op)

Prof Ripley commented that this approach will also work on log plots, but I
don't think I completely understand what is going on because this does not
work for me

plot(rlnorm(100), rlnorm(100),log=xy)
op - par(usr)
par(usr = c(0, 1, 0, 1))
text(0.5,0.5,TEST)
par(usr = op)

Any hints on what I am doing wrong with the log plots? Thanks again for the
help.

Tom


-- 
View this message in context: 
http://www.nabble.com/Specifying-relative-position-of-text-in-a-plot-tp16002549p16024549.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] recover masked functions?

2008-03-13 Thread Duncan Murdoch
Werner Wernersen wrote:
 Hi,

 I have loaded the packages car, memisc, Hmisc and all
 of these implement the function recode. The order in
 which the packages are loaded depends on the order I
 execute my scripts and thus is not always the same and
 the syntax of the recode function changes with the
 package.

 Is there any way to call specificly the memisc recode
 function?
 Or maybe it's better to detach all packages first and
 then load the required once in each script. Is there a
 way to detach all non-standard packages with a single
 line of code?

 This is my first larger project in R and I see there
 is a lot to learn about how to manage the pieces.
You can specify the package in which to find the function in by using 
pkgname::recode.

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] Compare two correlations matrices

2008-03-13 Thread Martin Kaffanke
Hi there,

When I make two correlations matrices of the same size from

a - cor(el[1:20])
b - cor(fl[1:20])

how can I compare if this matrices are equal?

Thanks,
Martin

-- 
Ihr Partner für Webdesign, Webapplikationen und Webspace.
http://www.roomandspace.com/
Martin Kaffanke +43 650 4514224


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


Re: [R] recover masked functions?

2008-03-13 Thread Henrique Dallazuanna
Use:

memisc::recode()
car::recode()
Hmisc::recode()

On 13/03/2008, Werner Wernersen [EMAIL PROTECTED] wrote:
 Hi,

  I have loaded the packages car, memisc, Hmisc and all
  of these implement the function recode. The order in
  which the packages are loaded depends on the order I
  execute my scripts and thus is not always the same and
  the syntax of the recode function changes with the
  package.

  Is there any way to call specificly the memisc recode
  function?
  Or maybe it's better to detach all packages first and
  then load the required once in each script. Is there a
  way to detach all non-standard packages with a single
  line of code?

  This is my first larger project in R and I see there
  is a lot to learn about how to manage the pieces.

  Thanks a million,
   Werner


   E-Mails jetzt auf Ihrem Handy.

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



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

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


Re: [R] Sealed for setGeneric

2008-03-13 Thread Charilaos Skiadas
On Mar 13, 2008, at 5:04 AM, Christophe Genolini wrote:

 Hi the list

 When two setGeneric occurs on the same function, the second erage the
 first and erase all the function previously define.
 Is it possible to prevent that ? Is it possible to declare a  
 setGeneric
 that can not be erased later ?
 Something like the |sealed for setMethod...|
 ||
 |Thanks|
 ||
 Christophe

Does this answer your questions?
http://www1.maths.lth.se/help/R/setGenericS3/

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College

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


[R] R Finance

2008-03-13 Thread Ruby
Hi,

I am an R novice working with financial data. I am developing a
portfolio strategy evaluation technique to back-test the performance
of our screens; checking how the screened stock would've performed
over the period in question.

I am using quantmod in R to download the historical data from yahoo
and then analyzing it using PerformanceAnalytics. My problem is that,
as our screens are done using Bloomberg, my list of screened stocks
only has Bloomberg tickers and ISINs. Does anybody know of a method
which could convert ISINs to yahoo tickers/symbols?? Or a method of
accessing yahoo historical data from an ISIN (instead of a symbol
call)? I would prefer not to use RBloomberg to download the data as
the data calls would be extensive in testing.

Thank you!!

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


Re: [R] internet proxy settings (win)

2008-03-13 Thread Thomas Steiner
Thank you Philipp for your suggestions.
In Rprofile.site every line is commented out and I could not find any
.Rprofile. I even tried starting R with additional cmdline arguments
--no-environ and --no-init-file.
Still
 update.packages(ask='graphics')
--- Please select a CRAN mirror for use in this session ---
Fehler: Indizierung außerhalb der Grenzen
Zusätzlich: Warning messages:
1: In read.dcf(file = tmpf) : Line starting 'html ...' is malformed!
2: In read.dcf(file = tmpf) : Line starting '   head ...' is malformed!
3: In read.dcf(file = tmpf) : Line starting '/html ...' is malformed!


This is as far as I allready have been - or not?
Thomas

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


Re: [R] Compare two correlations matrices

2008-03-13 Thread Henrique Dallazuanna
Try:


all.equal(cor(d), cor(e))
identical(cor(d), cor(e))
cor(d) == cor(e)

On 13/03/2008, Martin Kaffanke [EMAIL PROTECTED] wrote:
 Hi there,

  When I make two correlations matrices of the same size from

  a - cor(el[1:20])
  b - cor(fl[1:20])

  how can I compare if this matrices are equal?

  Thanks,
  Martin


  --
  Ihr Partner für Webdesign, Webapplikationen und Webspace.
  http://www.roomandspace.com/
  Martin Kaffanke +43 650 4514224

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





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

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


[R] cumsum list..

2008-03-13 Thread yoooooo

Hi all, i have the following.. 

a - data.frame(data = seq(1,10))

i have indices:
x - c(1, 5, 3, 9)
y - c(2, 7, 4, 10)

I want the cumsum of a[1:2], a[5:7], a[3:4]... 

is there an elegant way to do it without any loop? Thanks!

-- 
View this message in context: 
http://www.nabble.com/cumsum-list..-tp16025202p16025202.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] cumsum list..

2008-03-13 Thread Gabor Csardi
cumsum( mapply(function(i,j) sum(a$data[i:j]), x, y) )

Is this what you want?
Gabor

On Thu, Mar 13, 2008 at 06:02:13AM -0700, yoo wrote:
 
 Hi all, i have the following.. 
 
 a - data.frame(data = seq(1,10))
 
 i have indices:
 x - c(1, 5, 3, 9)
 y - c(2, 7, 4, 10)
 
 I want the cumsum of a[1:2], a[5:7], a[3:4]... 
 
 is there an elegant way to do it without any loop? Thanks!
 
 -- 
 View this message in context: 
 http://www.nabble.com/cumsum-list..-tp16025202p16025202.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.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

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


Re: [R] R Finance

2008-03-13 Thread davidr
I guess I would create a mapping table to convert between the symbols
from Bloomberg and from Yahoo.
You should be able to just create it once and add to it as new symbols
appear on your screens. Most of the symbols should be the same so you
could omit those. If it all has to be automated, you could use
RBloomberg to get the tickers from the ISINs in one call, but there may
still be other transformations needed, such as XYZ/A to XYZA or
whatever.
HTH,

David L. Reiner, PhD
Head Quant
Rho Trading Securities, LLC


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Ruby
Sent: Thursday, March 13, 2008 6:44 AM
To: r-help@r-project.org
Subject: [R] R Finance

Hi,

I am an R novice working with financial data. I am developing a
portfolio strategy evaluation technique to back-test the performance
of our screens; checking how the screened stock would've performed
over the period in question.

I am using quantmod in R to download the historical data from yahoo
and then analyzing it using PerformanceAnalytics. My problem is that,
as our screens are done using Bloomberg, my list of screened stocks
only has Bloomberg tickers and ISINs. Does anybody know of a method
which could convert ISINs to yahoo tickers/symbols?? Or a method of
accessing yahoo historical data from an ISIN (instead of a symbol
call)? I would prefer not to use RBloomberg to download the data as
the data calls would be extensive in testing.

Thank you!!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] joining matrices, vectors, scalars in one object

2008-03-13 Thread Gonçalo Ferraz
Hi,

I have:

a - matrix(c(0,1,0,1),nrow=2)
b - matrix(c(1,1,1,0,0,0),nrow=3)
c - 1
d - c(1,0,1)

And I would like to join them in an object 'thing' so that I can  
access a, b, c, or d through an index in a for loop.

For example:
thing[4]
would return
[1]  1  0  1

Note however, that I have many of these 'thing' components. So many  
that  a command like

thing - list(a = matrix(c(0,1,0,1),nrow=2), b = matrix(c 
(1,1,1,0,0,0),nrow=3), c = 1, d = c(1,0,1))

would become long and awkward.

Is there a way of declaring an empty 'thing' of a given length and  
then assigning its elements from a for loop? I need to allow elements  
a, b, c... that can be scalars, vectors or matrices with varying  
dimensions.

Thanks!

Gonçalo


[[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] joining matrices, vectors, scalars in one object

2008-03-13 Thread Gabor Csardi
You want to do 

thing - list()# empty thing
for ( i in 1:100 ) { 
  thing[[i]] - ?
}

But where is ? coming from? If you can index it with an integer
then it is exactly coming from the kind of object you want to create. 
Chicken-egg problem. No?

G.

On Thu, Mar 13, 2008 at 09:04:11AM -0400, Gonçalo Ferraz wrote:
 Hi,
 
 I have:
 
 a - matrix(c(0,1,0,1),nrow=2)
 b - matrix(c(1,1,1,0,0,0),nrow=3)
 c - 1
 d - c(1,0,1)
 
 And I would like to join them in an object 'thing' so that I can  
 access a, b, c, or d through an index in a for loop.
 
 For example:
 thing[4]
 would return
 [1]  1  0  1
 
 Note however, that I have many of these 'thing' components. So many  
 that  a command like
 
 thing - list(a = matrix(c(0,1,0,1),nrow=2), b = matrix(c 
 (1,1,1,0,0,0),nrow=3), c = 1, d = c(1,0,1))
 
 would become long and awkward.
 
 Is there a way of declaring an empty 'thing' of a given length and  
 then assigning its elements from a for loop? I need to allow elements  
 a, b, c... that can be scalars, vectors or matrices with varying  
 dimensions.
 
 Thanks!
 
 Gon?alo
 
 
   [[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.


-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

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


Re: [R] type of object of a variable in a data frame

2008-03-13 Thread David Winsemius
Chang Liu [EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]: 

 3. The reason I want it to be a list or vector, is that I want to
 fill in some blank values, i can't seem to do things like: 
 data$V1[1] = 3 Is it because these variables are pointers? Is there
 a better way to do this? 
 

You have not given reproducible code, so it is difficult to know why that 
does not succeed. I have a data.frame with a similar name left over from 
another problem. When I enter DATA$V1[1] = -.5 , it has the desired 
effect. Although it is not the source of the error,  you should learn to 
use - rather than =. You should also learn to post questions with 
reproducible code.

-- 
David Winsemius

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


[R] a more elegant way to get percentages?

2008-03-13 Thread Monica Pisica

Hi,

I am trying to get percentages in a more elegant way. I have a data.frame with 
locations and values (counts) of species at that location. Each location is 
repeated for each species i have values for and i would like to get percentages 
of each species at that location. I am not sure if i am clear in my 
explanations so i will paste my code below:

#

 x
   locat val
1  a   5
2  b   5
3  b  15
4  c   5
5  c  20
6  c   5
7  c  10
8  d   5
9  d  15
10 d  10
 loc1 - x$locat
 n - length(loc1)
 locuniq1 - unique(loc1)
 m - length(locuniq1)
 counts - seq(1:m)
 
 for (i in 1:m) {
+ count - 0
+ for (j in 1:n) {
+ if (loc1[j]==locuniq1[i]) count - count+1 
+ counts[i] - count
+ }
+ }
 
 percent1 - rep(0,n)
 j - 0
 for (i in 1:m) {
+ 
+ b - x[(j+1):(j+counts[i]),]
+ total - sum(b$val)
+ percent1[(j+1):(j+counts[i])] - round(apply(as.matrix(b$val), 1, function(x) 
{x*100/total}),2)
+ j = j+counts[i]
+ }
 x1 - cbind(x, percent1)# this is the result i want 
 x1
   locat val percent1
1  a   5   100.00
2  b   525.00
3  b  1575.00
4  c   512.50
5  c  2050.00
6  c   512.50
7  c  1025.00
8  d   516.67
9  d  1550.00
10 d  1033.33
 


I am wondering if there is any way to do it more efficiently, much more that 
the first loop which gives how many times each location is present in the 
data.frame is slow if you have a larger data.frame and not only 10 rows.

Thanks for any input and sorry if the email is on the long side,

Monica


_
[[elided Hotmail spam]]

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


Re: [R] joining matrices, vectors, scalars in one object

2008-03-13 Thread Dimitris Rizopoulos
I think you need:

thing - vector(list, 4)
for (i in seq_along(thing)) {
thing[[i]] - # what you want to put here
}


Best,
Dimitris


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

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


- Original Message - 
From: Gonçalo Ferraz [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, March 13, 2008 2:04 PM
Subject: [R] joining matrices, vectors, scalars in one object


Hi,

I have:

a - matrix(c(0,1,0,1),nrow=2)
b - matrix(c(1,1,1,0,0,0),nrow=3)
c - 1
d - c(1,0,1)

And I would like to join them in an object 'thing' so that I can
access a, b, c, or d through an index in a for loop.

For example:
thing[4]
would return
[1]  1  0  1

Note however, that I have many of these 'thing' components. So many
that  a command like

thing - list(a = matrix(c(0,1,0,1),nrow=2), b = matrix(c
(1,1,1,0,0,0),nrow=3), c = 1, d = c(1,0,1))

would become long and awkward.

Is there a way of declaring an empty 'thing' of a given length and
then assigning its elements from a for loop? I need to allow elements
a, b, c... that can be scalars, vectors or matrices with varying
dimensions.

Thanks!

Gonçalo


[[alternative HTML version deleted]]







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


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

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


[R] lmer and correlation

2008-03-13 Thread R Help
Hello list,
 I've been reading through the archives and it seems as though, as
of right now, there is no way to specify the correlation structure in
lmer.  I was wondering if anyone knows if this is going to be
implemented?  I'm using mixed-effects models within a tree structure,
so I make a lot of calls to lme to get the resulting deviance, and
lmer2 is almost 5 times faster than lme on my test data, so if it may
be implemented later I'd be willing to wait, otherwise I might look
into trying to hack it myself.

Sam Stewart

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


Re: [R] a more elegant way to get percentages?

2008-03-13 Thread Dimitris Rizopoulos
try the following:

x - read.table(textConnection(locat val
1  a   5
2  b   5
3  b  15
4  c   5
5  c  20
6  c   5
7  c  10
8  d   5
9  d  15
10 d  10), header = TRUE)

x$percent1 - unlist(tapply(x$val, x$locat, function(x){
round(100 * x / sum(x), 2)
}))
x


however, check whether the levels of the factor 'x$locat' are 
appropriately ordered.

I hope it helps.

Best,
Dimitris


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

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

- Original Message - 
From: Monica Pisica [EMAIL PROTECTED]
To: r-help@r-project.org
Sent: Thursday, March 13, 2008 2:36 PM
Subject: [R] a more elegant way to get percentages?



 Hi,

 I am trying to get percentages in a more elegant way. I have a 
 data.frame with locations and values (counts) of species at that 
 location. Each location is repeated for each species i have values 
 for and i would like to get percentages of each species at that 
 location. I am not sure if i am clear in my explanations so i will 
 paste my code below:

 #

 x
   locat val
 1  a   5
 2  b   5
 3  b  15
 4  c   5
 5  c  20
 6  c   5
 7  c  10
 8  d   5
 9  d  15
 10 d  10
 loc1 - x$locat
 n - length(loc1)
 locuniq1 - unique(loc1)
 m - length(locuniq1)
 counts - seq(1:m)

 for (i in 1:m) {
 + count - 0
 + for (j in 1:n) {
 + if (loc1[j]==locuniq1[i]) count - count+1
 + counts[i] - count
 + }
 + }

 percent1 - rep(0,n)
 j - 0
 for (i in 1:m) {
 +
 + b - x[(j+1):(j+counts[i]),]
 + total - sum(b$val)
 + percent1[(j+1):(j+counts[i])] - round(apply(as.matrix(b$val), 1, 
 function(x) {x*100/total}),2)
 + j = j+counts[i]
 + }
 x1 - cbind(x, percent1)# this is the result i want
 x1
   locat val percent1
 1  a   5   100.00
 2  b   525.00
 3  b  1575.00
 4  c   512.50
 5  c  2050.00
 6  c   512.50
 7  c  1025.00
 8  d   516.67
 9  d  1550.00
 10 d  1033.33

 

 I am wondering if there is any way to do it more efficiently, much 
 more that the first loop which gives how many times each location is 
 present in the data.frame is slow if you have a larger data.frame 
 and not only 10 rows.

 Thanks for any input and sorry if the email is on the long side,

 Monica


 _
 [[elided Hotmail spam]]

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


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

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


Re: [R] a more elegant way to get percentages?

2008-03-13 Thread Gabor Grothendieck
Assuming your x is as follows:

x - data.frame(locat = c(a, b, b, c, c, c, c, d, d, d),
 val = c(5, 5, 15, 5, 20, 5, 10, 5, 15, 10))

Try this:

x$percent1 - ave(x$val, x$locat, FUN = function(x) 100*x/sum(x))

On Thu, Mar 13, 2008 at 9:36 AM, Monica Pisica [EMAIL PROTECTED] wrote:

 Hi,

 I am trying to get percentages in a more elegant way. I have a data.frame 
 with locations and values (counts) of species at that location. Each location 
 is repeated for each species i have values for and i would like to get 
 percentages of each species at that location. I am not sure if i am clear in 
 my explanations so i will paste my code below:

 #

  x
   locat val
 1  a   5
 2  b   5
 3  b  15
 4  c   5
 5  c  20
 6  c   5
 7  c  10
 8  d   5
 9  d  15
 10 d  10
  loc1 - x$locat
  n - length(loc1)
  locuniq1 - unique(loc1)
  m - length(locuniq1)
  counts - seq(1:m)
 
  for (i in 1:m) {
 + count - 0
 + for (j in 1:n) {
 + if (loc1[j]==locuniq1[i]) count - count+1
 + counts[i] - count
 + }
 + }
 
  percent1 - rep(0,n)
  j - 0
  for (i in 1:m) {
 +
 + b - x[(j+1):(j+counts[i]),]
 + total - sum(b$val)
 + percent1[(j+1):(j+counts[i])] - round(apply(as.matrix(b$val), 1, 
 function(x) {x*100/total}),2)
 + j = j+counts[i]
 + }
  x1 - cbind(x, percent1)# this is the result i want
  x1
   locat val percent1
 1  a   5   100.00
 2  b   525.00
 3  b  1575.00
 4  c   512.50
 5  c  2050.00
 6  c   512.50
 7  c  1025.00
 8  d   516.67
 9  d  1550.00
 10 d  1033.33
 
 

 I am wondering if there is any way to do it more efficiently, much more that 
 the first loop which gives how many times each location is present in the 
 data.frame is slow if you have a larger data.frame and not only 10 rows.

 Thanks for any input and sorry if the email is on the long side,

 Monica


 _
 [[elided Hotmail spam]]

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


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


Re: [R] a more elegant way to get percentages?

2008-03-13 Thread Christos Hatzis
Monica,

You can try the following:

 x.tot - aggregate(x$val, by=list(total=x$locat), 'sum')
 x.tot
  total  x
1 a  5
2 b 20
3 c 40
4 d 30
 cbind(x, perc=x$val/rep(x.tot$x, table(x$locat)) * 100)
   locat val  perc
1  a   5 100.0
2  b   5  25.0
3  b  15  75.0
4  c   5  12.5
5  c  20  50.0
6  c   5  12.5
7  c  10  25.0
8  d   5  16.7
9  d  15  50.0
10 d  10  33.3

-Christos

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Monica Pisica
 Sent: Thursday, March 13, 2008 9:36 AM
 To: r-help@r-project.org
 Subject: [R] a more elegant way to get percentages?
 
 
 Hi,
 
 I am trying to get percentages in a more elegant way. I have 
 a data.frame with locations and values (counts) of species at 
 that location. Each location is repeated for each species i 
 have values for and i would like to get percentages of each 
 species at that location. I am not sure if i am clear in my 
 explanations so i will paste my code below:
 
 #
 
  x
locat val
 1  a   5
 2  b   5
 3  b  15
 4  c   5
 5  c  20
 6  c   5
 7  c  10
 8  d   5
 9  d  15
 10 d  10
  loc1 - x$locat
  n - length(loc1)
  locuniq1 - unique(loc1)
  m - length(locuniq1)
  counts - seq(1:m)
  
  for (i in 1:m) {
 + count - 0
 + for (j in 1:n) {
 + if (loc1[j]==locuniq1[i]) count - count+1 counts[i] - count } }
  
  percent1 - rep(0,n)
  j - 0
  for (i in 1:m) {
 + 
 + b - x[(j+1):(j+counts[i]),]
 + total - sum(b$val)
 + percent1[(j+1):(j+counts[i])] - round(apply(as.matrix(b$val), 1, 
 + function(x) {x*100/total}),2) j = j+counts[i] }
  x1 - cbind(x, percent1)# this is the result i want 
  x1
locat val percent1
 1  a   5   100.00
 2  b   525.00
 3  b  1575.00
 4  c   512.50
 5  c  2050.00
 6  c   512.50
 7  c  1025.00
 8  d   516.67
 9  d  1550.00
 10 d  1033.33
  
 
 
 I am wondering if there is any way to do it more efficiently, 
 much more that the first loop which gives how many times each 
 location is present in the data.frame is slow if you have a 
 larger data.frame and not only 10 rows.
 
 Thanks for any input and sorry if the email is on the long side,
 
 Monica
 
 
 _
 [[elided Hotmail spam]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 


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


Re: [R] Negative/ positive rolling correlation

2008-03-13 Thread David Winsemius
Rthoughts [EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]: 

 
 There is one question I have though. I can see that worksheets and
 history can be saved, however I am beat as to exactly what they
 save? Do they save the command lines and associated data sheets and
 graphs? 

There is no datasheet but the R objects defined and saved in the last 
session will automatically be loaded into the workspace from the .Rdata 
file when a new session begins. It is also possible to save named .Rdata 
files and reload them under user control. If you look at an .Rdata file 
with a text editor, it is pretty much meaningless. On the other hand, if 
you look at .Rhistory, you will see a text file that is simply a 
sequential listing of the commands of earlier saved sessions.
 
 Oh, I'm using Rcmdr. In my case it is an excellent software that
 cuts hours off my progamming work freeing up time for other parts of
 the project and breaks, lol!
 
 The other, I want to do a correlation to highlight matching patterns
 between two columns of radon levels (96 lines each) divided by the
 hour they were recorded in the two machines. A scattergraph is
 similar but I want to produce visualtisations for negative/ positive
 correlation against time. Can anyone suggest anything? Thanks.

You need to investigate time series analyses methods. I am assuming that 
the radon levels are ordered and associated with times, rather than 
mathematically divided by them. There are extensive capabilities for 
analyzing and displaying such information in R.

See for instance:
http://cran.r-project.org/doc/contrib/Ricci-refcard-ts.pdf

-- 
David Winsemius

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


[R] How to set type of censored data in coxph regression

2008-03-13 Thread Terry Therneau
 Dear R users,
 I tried to analysis the hazard function of some data by coxph function in
 survival package.
The type of the data include left-censored, right-censored, both
 right-censored and
 left-censored (btw, does this has a technical term?), and complete ones.

  The coxph function is only defined for right-censored data.  That is why you 
get an error when you include left and interval censored observations.
  
Terry Therneau

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


Re: [R] a more elegant way to get percentages?

2008-03-13 Thread Monica Pisica


Hi everybody,


I am amazed how quick i got my answer ;-) I have to recognize that Gabor's code 
really puts to shame my skills in doing any programming in R. Is there any book 
or documentation which really explains in details all these neat tricks from 
{stats} like ave (i even didn't know this function existed), apply and all its 
friends (sapply, tapply, etc) ? To be honest it took me quite a while to come 
up with the fancy subscripting to get my persantages ;-))

thank you so much, i really appreciate your help,

Monica

 Date: Thu, 13 Mar 2008 09:45:05 -0400
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: Re: [R] a more elegant way to get percentages?
 CC: r-help@r-project.org

 Assuming your x is as follows:

 x - data.frame(locat = c(a, b, b, c, c, c, c, d, d, d),
 val = c(5, 5, 15, 5, 20, 5, 10, 5, 15, 10))

 Try this:

 x$percent1 - ave(x$val, x$locat, FUN = function(x) 100*x/sum(x))

 On Thu, Mar 13, 2008 at 9:36 AM, Monica Pisica  wrote:

 Hi,

 I am trying to get percentages in a more elegant way. I have a data.frame 
 with locations and values (counts) of species at that location. Each 
 location is repeated for each species i have values for and i would like to 
 get percentages of each species at that location. I am not sure if i am 
 clear in my explanations so i will paste my code below:

 #

 x
 locat val
 1 a 5
 2 b 5
 3 b 15
 4 c 5
 5 c 20
 6 c 5
 7 c 10
 8 d 5
 9 d 15
 10 d 10
 loc1 - x$locat
 n - length(loc1)
 locuniq1 - unique(loc1)
 m - length(locuniq1)
 counts - seq(1:m)

 for (i in 1:m) {
 + count - 0
 + for (j in 1:n) {
 + if (loc1[j]==locuniq1[i]) count - count+1
 + counts[i] - count
 + }
 + }

 percent1 - rep(0,n)
 j - 0
 for (i in 1:m) {
 +
 + b - x[(j+1):(j+counts[i]),]
 + total - sum(b$val)
 + percent1[(j+1):(j+counts[i])] - round(apply(as.matrix(b$val), 1, 
 function(x) {x*100/total}),2)
 + j = j+counts[i]
 + }
 x1 - cbind(x, percent1) # this is the result i want
 x1
 locat val percent1
 1 a 5 100.00
 2 b 5 25.00
 3 b 15 75.00
 4 c 5 12.50
 5 c 20 50.00
 6 c 5 12.50
 7 c 10 25.00
 8 d 5 16.67
 9 d 15 50.00
 10 d 10 33.33

 

 I am wondering if there is any way to do it more efficiently, much more that 
 the first loop which gives how many times each location is present in the 
 data.frame is slow if you have a larger data.frame and not only 10 rows.

 Thanks for any input and sorry if the email is on the long side,

 Monica


 _
 [[elided Hotmail spam]]

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


_


08
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 cbind or rbind different lengths vectors/arrays without repeating the elements of the shorter vectors/arrays ?

2008-03-13 Thread Ng Stanley
Hi,

How to cbind or rbind different lengths vectors/arrays without repeating the
elements of the shorter vectors/arrays ?

 cbind(1:2, 1:10)
  [,1] [,2]
 [1,]11
 [2,]22
 [3,]13
 [4,]24
 [5,]15
 [6,]26
 [7,]17
 [8,]28
 [9,]19
[10,]2   10

[[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] Sealed for setGeneric

2008-03-13 Thread Martin Morgan
Christophe Genolini [EMAIL PROTECTED] writes:

 Hi the list

 When two setGeneric occurs on the same function, the second erage the 
 first and erase all the function previously define.

'erase' is only true if you attempt to define the generic in the same
name space (e.g., in the global environment, as occurs from the
command line, or in a single package).

 Is it possible to prevent that ? Is it possible to declare a setGeneric 
 that can not be erased later ?

Generics defined in different name spaces are not 'erased', but the
name space occuring earlier in the search path is 'masked' by generics
occuring later in the search path.

 getGeneric(show)
standardGeneric for show defined from package methods

function (object) 
standardGeneric(show)
environment: 0x16b8b40
Methods may be defined for arguments: object
Use  showMethods(show)  for currently available ones.
 show(1:10)
 [1]  1  2  3  4  5  6  7  8  9 10
 setGeneric(show, function(object) standardGeneric(show))
[1] show
 setMethod(show, numeric, function(object) oops)
[1] show
 show(1:10)
[1] oops
 methods::show(1:10)
 [1]  1  2  3  4  5  6  7  8  9 10
 removeGeneric(show)
[1] TRUE
 show(1:10)
 [1]  1  2  3  4  5  6  7  8  9 10

 Something like the |sealed for setMethod...|

an unusual strategy would be to use lockBinding to make the symbol
associated with the generic unchangeable.

 setGeneric(show, function(object) standardGeneric(show))
[1] show
 lockBinding(show, .GlobalEnv)
NULL
 setGeneric(show, function(object) standardGeneric(show))
Error in assign(name, fdef, where) : 
  cannot change value of locked binding for 'show'
 unlockBinding(show, .GlobalEnv)
NULL
 setGeneric(show, function(object) standardGeneric(show))
[1] show

Martin

 ||
 |Thanks|
 ||
 Christophe

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

-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M2 B169
Phone: (206) 667-2793

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


Re: [R] [PS] Re: a more elegant way to get percentages? (now R books)

2008-03-13 Thread Ben Fairbank
Monica --

There has been a virtual population explosion of R books in recent years
and we all have our favorites.  You may wish to pick one oriented toward
your specialty, but the absolute minimum lowest common denominator (by
which I mean that it has the ground zero essential information that all
users must share, not that it is minimal or incomplete) is the manual
An Introduction to R, available by download from the Cran website.
Beyond that, my favorite introduction is Peter Dalgaard's Introductory
Statistics with R.  He has an elegance and clarity of style, as well as
a feel for what is necessary to include in an introduction, that some
others lack.  Others may disagree, but I find myself returning to
Dalgaard again and again. 

Ben 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Monica Pisica
Sent: Thursday, March 13, 2008 9:05 AM
To: Gabor Grothendieck; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Cc: r-help@r-project.org
Subject: [PS] Re: [R] a more elegant way to get percentages?



Hi everybody,


I am amazed how quick i got my answer ;-) I have to recognize that
Gabor's code really puts to shame my skills in doing any programming in
R. Is there any book or documentation which really explains in details
all these neat tricks from {stats} like ave (i even didn't know this
function existed), apply and all its friends (sapply, tapply, etc) ? To
be honest it took me quite a while to come up with the fancy
subscripting to get my persantages ;-))

thank you so much, i really appreciate your help,

Monica

 Date: Thu, 13 Mar 2008 09:45:05 -0400
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: Re: [R] a more elegant way to get percentages?
 CC: r-help@r-project.org

 Assuming your x is as follows:

 x - data.frame(locat = c(a, b, b, c, c, c, c, d, d,
d),
 val = c(5, 5, 15, 5, 20, 5, 10, 5, 15, 10))

 Try this:

 x$percent1 - ave(x$val, x$locat, FUN = function(x) 100*x/sum(x))

 On Thu, Mar 13, 2008 at 9:36 AM, Monica Pisica  wrote:

 Hi,

 I am trying to get percentages in a more elegant way. I have a
data.frame with locations and values (counts) of species at that
location. Each location is repeated for each species i have values for
and i would like to get percentages of each species at that location. I
am not sure if i am clear in my explanations so i will paste my code
below:

 #

 x
 locat val
 1 a 5
 2 b 5
 3 b 15
 4 c 5
 5 c 20
 6 c 5
 7 c 10
 8 d 5
 9 d 15
 10 d 10
 loc1 - x$locat
 n - length(loc1)
 locuniq1 - unique(loc1)
 m - length(locuniq1)
 counts - seq(1:m)

 for (i in 1:m) {
 + count - 0
 + for (j in 1:n) {
 + if (loc1[j]==locuniq1[i]) count - count+1
 + counts[i] - count
 + }
 + }

 percent1 - rep(0,n)
 j - 0
 for (i in 1:m) {
 +
 + b - x[(j+1):(j+counts[i]),]
 + total - sum(b$val)
 + percent1[(j+1):(j+counts[i])] - round(apply(as.matrix(b$val), 1,
function(x) {x*100/total}),2)
 + j = j+counts[i]
 + }
 x1 - cbind(x, percent1) # this is the result i want
 x1
 locat val percent1
 1 a 5 100.00
 2 b 5 25.00
 3 b 15 75.00
 4 c 5 12.50
 5 c 20 50.00
 6 c 5 12.50
 7 c 10 25.00
 8 d 5 16.67
 9 d 15 50.00
 10 d 10 33.33

 

 I am wondering if there is any way to do it more efficiently, much
more that the first loop which gives how many times each location is
present in the data.frame is slow if you have a larger data.frame and
not only 10 rows.

 Thanks for any input and sorry if the email is on the long side,

 Monica


 _
 [[elided Hotmail spam]]

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


_


08
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] How to manipulate data according to groups ?

2008-03-13 Thread Ng Stanley
Hi,

I have a two columns data, the first column are values, and second column
are the groups. For this example, there are 3 groups 1,2,3.

How can I manipulate the values in the first column according to groups, say
I would like to find mean, sum, and standard deviation for the different
groups ? How do I plot data according to groups ?

 t - matrix(c(rnorm(10), 1,1,2,2,1,3,3,3,3,2), ncol=2)

[[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] how to generate bar charts with the standard deviation

2008-03-13 Thread Ng Stanley
Hi,

I have the two vectors mean and sd of individual columns, but I am unsure
how to generate bar charts with the standard deviation, even after looking
the help of barplot and barplot.2.

[[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] [PS] How to manipulate data according to groups ?

2008-03-13 Thread Ben Fairbank
Look at ?tapply, based on your description, it is what you want.

Ben 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Ng Stanley
Sent: Thursday, March 13, 2008 9:25 AM
To: r-help
Subject: [PS] [R] How to manipulate data according to groups ?

Hi,

I have a two columns data, the first column are values, and second
column
are the groups. For this example, there are 3 groups 1,2,3.

How can I manipulate the values in the first column according to groups,
say
I would like to find mean, sum, and standard deviation for the different
groups ? How do I plot data according to groups ?

 t - matrix(c(rnorm(10), 1,1,2,2,1,3,3,3,3,2), ncol=2)

[[alternative HTML version deleted]]

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

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


Re: [R] a more elegant way to get percentages?

2008-03-13 Thread Liaw, Andy
From: [EMAIL PROTECTED]
 
 Now that people have answered Monica's query, can someone help me?!!
 See below.
 
 On 13-Mar-08 13:36:03, Monica Pisica wrote:
  
  Hi,
  
  I am trying to get percentages in a more elegant way. I have a
  data.frame with locations and values (counts) of species at that
  location. Each location is repeated for each species i have 
 values for
  and i would like to get percentages of each species at that 
 location. I
  am not sure if i am clear in my explanations so i will paste my code
  below:
  
 #
  
  x
 locat val
  1  a   5
  2  b   5
  3  b  15
  4  c   5
  5  c  20
  6  c   5
  7  c  10
  8  d   5
  9  d  15
  10 d  10
 
 With Monica's dataframe as above, the answer would be 100*x[,1]/z
 where we want z to be c(5,20,20,40,40,40,40,30,30,30).
 
 So, intending to give Monica a helpful answer, I tried
 
  apply(x,1,function(y) sum(x[x[,1]==y,2]))
  1  2  3  4  5  6  7  8  9 10 
  5 15 15 30 30 30 30 15 15 15 
 
 and similarly
 
  apply(x,1,function(y) sum(x$val[x$locat==y]))
  1  2  3  4  5  6  7  8  9 10 
  5 15 15 30 30 30 30 15 15 15
 
 
 So why didn't this work? Where's my blind spot? Indeed, why
 did it gives the results it did?

One strategy is similar to what the piano teacher ask my son to try:
break it into small pieces.

apply() works on slices of the data, so take a slice where the answer
wasn't what you expected; e.g., the last row of x.  What gets passed
into the anonymous function is the 10th row of x, namely c(4, 10) (note
that apply() converts its first argument to a matrix or array).  so what
would you get when you test for equality to that?

Andy

 
 With thanks,
 Ted.
 
 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 13-Mar-08   Time: 14:15:34
 -- XFMail --
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 


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

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


Re: [R] a more elegant way to get percentages?

2008-03-13 Thread Ted Harding
Now that people have answered Monica's query, can someone help me?!!
See below.

On 13-Mar-08 13:36:03, Monica Pisica wrote:
 
 Hi,
 
 I am trying to get percentages in a more elegant way. I have a
 data.frame with locations and values (counts) of species at that
 location. Each location is repeated for each species i have values for
 and i would like to get percentages of each species at that location. I
 am not sure if i am clear in my explanations so i will paste my code
 below:
 
#
 
 x
locat val
 1  a   5
 2  b   5
 3  b  15
 4  c   5
 5  c  20
 6  c   5
 7  c  10
 8  d   5
 9  d  15
 10 d  10

With Monica's dataframe as above, the answer would be 100*x[,1]/z
where we want z to be c(5,20,20,40,40,40,40,30,30,30).

So, intending to give Monica a helpful answer, I tried

 apply(x,1,function(y) sum(x[x[,1]==y,2]))
 1  2  3  4  5  6  7  8  9 10 
 5 15 15 30 30 30 30 15 15 15 

and similarly

 apply(x,1,function(y) sum(x$val[x$locat==y]))
 1  2  3  4  5  6  7  8  9 10 
 5 15 15 30 30 30 30 15 15 15


So why didn't this work? Where's my blind spot? Indeed, why
did it gives the results it did?

With thanks,
Ted.


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

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


Re: [R] How to cbind or rbind different lengths vectors/arrays without repeating the elements of the shorter vectors/arrays ?

2008-03-13 Thread Gabor Grothendieck
Try converting them to time series, cbinding and unconverting:

cbind(x = ts(x), y = ts(y))[TRUE, ]


On Thu, Mar 13, 2008 at 10:13 AM, Ng Stanley [EMAIL PROTECTED] wrote:
 Hi,

 How to cbind or rbind different lengths vectors/arrays without repeating the
 elements of the shorter vectors/arrays ?

  cbind(1:2, 1:10)
  [,1] [,2]
  [1,]11
  [2,]22
  [3,]13
  [4,]24
  [5,]15
  [6,]26
  [7,]17
  [8,]28
  [9,]19
 [10,]2   10

[[alternative HTML version deleted]]

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


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


Re: [R] a more elegant way to get percentages?

2008-03-13 Thread Dimitris Rizopoulos
well, check what the apply() gives for each row of 'x', i.e.,

x - read.table(textConnection(locat val
1  a   5
2  b   5
3  b  15
4  c   5
5  c  20
6  c   5
7  c  10
8  d   5
9  d  15
10 d  10), header = TRUE)

# apply() uses as.matrix() for data frames

# 1st row of 'x'
y - as.matrix(x)[1, ]
x$val[x$locat == y]

# 2nd row of 'x'
y - as.matrix(x)[2, ]
x$val[x$locat == y]

# 3rd row of 'x'
y - as.matrix(x)[3, ]
x$val[x$locat == y]

# 4th row of 'x'
y - as.matrix(x)[4, ]
x$val[x$locat == y]

in which 'y' is auto-replicated to match the length of 'x$locat' each 
time.


Best,
Dimitris


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

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


- Original Message - 
From: Ted Harding [EMAIL PROTECTED]
To: r-help@r-project.org
Sent: Thursday, March 13, 2008 3:15 PM
Subject: Re: [R] a more elegant way to get percentages?


 Now that people have answered Monica's query, can someone help me?!!
 See below.

 On 13-Mar-08 13:36:03, Monica Pisica wrote:

 Hi,

 I am trying to get percentages in a more elegant way. I have a
 data.frame with locations and values (counts) of species at that
 location. Each location is repeated for each species i have values 
 for
 and i would like to get percentages of each species at that 
 location. I
 am not sure if i am clear in my explanations so i will paste my 
 code
 below:

#

 x
locat val
 1  a   5
 2  b   5
 3  b  15
 4  c   5
 5  c  20
 6  c   5
 7  c  10
 8  d   5
 9  d  15
 10 d  10

 With Monica's dataframe as above, the answer would be 100*x[,1]/z
 where we want z to be c(5,20,20,40,40,40,40,30,30,30).

 So, intending to give Monica a helpful answer, I tried

 apply(x,1,function(y) sum(x[x[,1]==y,2]))
 1  2  3  4  5  6  7  8  9 10
 5 15 15 30 30 30 30 15 15 15

 and similarly

 apply(x,1,function(y) sum(x$val[x$locat==y]))
 1  2  3  4  5  6  7  8  9 10
 5 15 15 30 30 30 30 15 15 15


 So why didn't this work? Where's my blind spot? Indeed, why
 did it gives the results it did?

 With thanks,
 Ted.

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

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


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

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


Re: [R] need automake/autoconf help to build RnetCDF and ncdf packages

2008-03-13 Thread Adam Wilson
Greetings all,

I recently tried to install RNetCDF from within R (install.packages)
on Fedora Core 8 (with netcdf 3.6.2 and netcdf-devel 3.6.2 already
installed).  This resulted in an error because the netcdf header files
are installed in  /usr/include/netcdf-3 rather than /usr/include which
is where RNetCDF looks for them.  This problem was described in a 2006
post (see below), but no satisfactory resolution was posted.

For the benefit of Fedora users that run into this problem and search
the R-help archives, I am posting a  solution.  The command is
actually quite simple:

install.packages(RNetCDF,configure.args=--with-netcdf-include=/usr/include/netcdf-3)

If this does not work, check RnetCDF's configure.ac file for the line
that points to something like /usr/include/...  and change the
netcdf-include to the name of the new variable.  This will only be
necessary if the RNetCDF folks change the name of this variable (which
they did between the time of Paul's post below and yesterday).

As an aside, I've found netcdf extractions run much faster under
(64-bit) linux than (32-bit) windows xp.

Good luck!

Adam



[R] need automake/autoconf help to build RnetCDF and ncdf packages
Paul Johnson pauljohn32 at gmail.com
 Tue Apr 25 22:46:26 CEST 2006
 I imagine this where are your header files problem comes up in other
packages, so I'm asking this as a general R question. How should
configure scripts be re-written so they look in more places?

Briefly, the problem is that Fedora-Extras installs the header files
in a subdirectory /usr/include/netcdf-3 rather than /usr/include:

# rpm -ql netcdf-devel
/usr/include/netcdf-3
/usr/include/netcdf-3/ncvalues.h
/usr/include/netcdf-3/netcdf.h
/usr/lib/netcdf-3/libnetcdf.a
/usr/lib/netcdf-3/libnetcdf_c++.a
/usr/lib/netcdf-3/libnetcdf_g77.a

Last week I posted in this list that I re-built the Fedora-Extras
netcdf rpm so that it would have more standard installation, and then
I was able to make RNetCDF work.

In the meanwhile, I posted in bugzilla.redhat.com asking if they
might use the standard packaging, but their response is an adamant
refusal:

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=189734

When netcdf updates are issued in the Fedora-Extras network, the
special hacks I put in to un-do their special hacks are lost, and
netcdf programs don't work anymore.

The attempt to build ncdf fails inside R or on the command line, but
it gives a GOOD HINT about a command line work around:

# R CMD INSTALL ncdf_1.5.tar.gz
[...]

checking /sw/include/netcdf.h presence... no
checking for /sw/include/netcdf.h... no

Fatal error: I cannot find the directory that holds the netcdf include
file netcdf.h!
You can specify it as follows:
 ./configure --with-netcdf_incdir=directory_with_file_netcdf.h

 *** Special note for R CMD INSTALL users: *
 The syntax for specifying multiple --configure-args does not seem to be
 well documented in R. If you have installed the netcdf include and library
 directories in some non-standard location, you can specify BOTH these
 during the R CMD INSTALL process using the following syntax:

 R CMD INSTALL
--configure-args=-with-netcdf_incdir=/path/to/netcdf/incdir
-with-netcdf_libdir=/path/to/netcdf/libdir ncdf_1.1.tar.gz

 where you should, of course, specify your own netcdf include and library
 directories, and the actual package name.
 ***


I found that the following did work!

# R CMD INSTALL
--configure-args=-with-netcdf_incdir=/usr/include/netcdf-3
-with-netcdf_libdir=/usr/lib/netcdf-3 ncdf_1.5.tar.gz

It is not the best solution, because special administrative effort is
required. And the install.packages approach inside R won't work.

However, with RNetCDF, the problem is slightly worse, and no such
helpful message appears:

# R CMD INSTALL RNetCDF_1.1-3.tar.gz
* Installing *source* package 'RNetCDF' ...
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for executable suffix...
checking for object suffix... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for main in -lnetcdf... no
configure: error: netcdf library not found
ERROR: configuration failed for package 'RNetCDF'
** Removing '/usr/lib/R/library/RNetCDF'


I have no reason to doubt that the Fedora-Extras authors are right,
and that some changes in the configure scripts for these packages are
required.

In RnetCDF's configure.ac file, I see the place where it specifies the
NETCDF_INCDIR

if test -z ${NETCDF_PATH}; then
 AC_CHECK_FILE(/usr/local/include/netcdf.h,
 [USR_LOCAL_NETCDF_H=TRUE], [USR_LOCAL_NETCDF_H=FALSE])
 if test ${USR_LOCAL_NETCDF_H} = TRUE; then
 NETCDF_INCDIR=/usr/local/include
 NETCDF_LIBDIR=/usr/local/lib
 NETCDF_LIBNAME=netcdf
 HAVE_NETCDF_H=TRUE
 elif test ${HAVE_NETCDF_H} = FALSE; 

[R] [R-pkgs] new version of minpack.lm

2008-03-13 Thread Katharine Mullen
The package minpack.lm allows nonlinear regression problems to be
addressed with a modification of the Levenberg-Marquardt algorithm based
on the implementation of 'lmder' and 'lmdif' in MINPACK. Version 1.0-8 of
the package is now available on CRAN.

Changes in version 1.0-8 include:

o possibility to obtain standard error estimates on the parameters
  via new methods for the generic functions 'summary' and 'vcov'

o possibility to extract other information via new methods for the
  generic functions 'coef', 'deviance', 'df.residual', 'print',
  and 'residuals'

o the argument 'control' of 'nls.lm' now defaults to
  'nls.lm.control()'; 'nls.control.lm' allows a maximum number of
  iterations to be specified; when the element 'nprint' of the
  'control' argument of a call to 'nls.lm' is an integer greater
  than 0, the residual sum of squares is now included in the
  information printed every 'nprint' iterations

`   o the list returned by 'nls.lm' includes elements 'niter' and
  'deviance' that represent the number of iterations performed and
  the residual sum of squares, respectively

side-note on Levenberg-Marquardt (LM) versus Gauss-Newton (GN):
There was some discussion
(http://finzi.psych.upenn.edu/R/Rhelp02a/archive/108758.html) on Rhelp
regarding whether one comes across real-world problems in which LM
performs better than GN.  I have been seeing such problems recently in
some applications where GN as implemented in 'nls' reduces the step to a
very small value, resulting in little change in the residual sum of
squares from the starting values, whereas both NL2SOL applied via 'nls'
called with 'algorithm=port' or LM as implemented in
'minpack.lm::nls.lm' significantly reduce the RSS.  The implementation of
NL2SOL is slower by a significant factor on these problems as compared to
either the GN or LM implementations, making use of 'minpack.lm::nls.lm'
attractive.  Note that these problems may be considered pathological;
there are issues with near collinearity of columns of the Jacobian and
with the assumption that the residuals are Gaussian.

Kate Mullen
Timur Elzhov

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

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


[R] factanal and plotting?

2008-03-13 Thread Martin Kaffanke
Hi there!

To make a good choice for the estimation of the number of usefull
factors.  And I'd like to plot a graph like:

http://de.wikipedia.org/wiki/Bild:Parallelanalyse.jpg

where I don't need the green line (random values).

But with

str(factanal(data, factors=10)) I cannot figure out where I can find the
values for plotting.

Can you please help me in this question?

Thanks,
Martin

-- 
Ihr Partner für Webdesign, Webapplikationen und Webspace.
http://www.roomandspace.com/
Martin Kaffanke +43 650 4514224


signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 generate bar charts with the standard deviation

2008-03-13 Thread Marc Schwartz
Ng Stanley wrote:
 Hi,
 
 I have the two vectors mean and sd of individual columns, but I am unsure
 how to generate bar charts with the standard deviation, even after looking
 the help of barplot and barplot.2.


Barplots are not well suited for presenting continuous data and many 
would argue that even for proportions, they should not be used to 
present CI's.


You are better off using:

1. plotCI() in the gplots package:

http://cged.genes.nig.ac.jp/RGM2/R_current/library/gplots/man/plotCI.html


2. plotmeans() in the same, which is a wrapper to the above:

http://cged.genes.nig.ac.jp/RGM2/R_current/library/gplots/man/plotmeans.html


3. errbar() in the Hmisc package:

http://cged.genes.nig.ac.jp/RGM2/R_current/library/Hmisc/man/errbar.html


4. arrows() and/or segments() in the default R installation, which can 
be used like errbar() to add CI's to points.


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.


[R] lars with weights - unshrunk coef do not match with lm with weights

2008-03-13 Thread Young Cho
I have been looking at 'lars' pkg and got puzzled by the behavior of
function 'lars'. I want to do weighted lasso regression and can't get a
match from lars output with lm output. Here is an example:

y = rnorm(10)
x = matrix(runif(50),nrow=10)
X = data.frame(y,x)
z = runif(10)
X = data.frame(y,x,z)
X$z = X$z / sum(X$z)   # this is not necessary.
fit1 =  lars(as.matrix(X[,2:6])*matrix(sqrt(X[,7]),10,5),as.matrix
(X[,1])*sqrt(X[,7]))
fit2 = lm(y~.-z,data=X,weights=z)
coef(fit1,mode='fraction',s=1)
fit2

I got this:

 coef(fit1,mode='fraction',s=1)
X1 X2 X3 X4 X5
-2.8603082 -0.8303739  0.1064474  3.6563283  2.8342368
 fit2

Call:
lm(formula = y ~ . - z, data = X, weights = z)

Coefficients:
(Intercept)   X1   X2   X3   X4
X5
-0.4227  -2.4817  -0.7105  -0.2611   2.6908   2.0295


 Shouldn't they match? If not, what did I do wrong and how to correctly do
lasso with weights? Thanks a lot.

Young

[[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] lars with weights do not match with lm output

2008-03-13 Thread Young Cho
I got my posting bounced and sorry if I accidentally post twice.
I have been looking at 'lars' pkg and got puzzled by the behavior of
function 'lars'. I want to do weighted lasso regression and can't get a
match from lars output with lm output. Here is an example:

y = rnorm(10)
x = matrix(runif(50),nrow=10)
X = data.frame(y,x)
z = runif(10)
X = data.frame(y,x,z)
X$z = X$z / sum(X$z)   # this is not necessary.
fit1 =  lars(as.matrix(X[,2:6])*matrix(sqrt(X[,7]),10,5),as.matrix
(X[,1])*sqrt(X[,7]))
fit2 = lm(y~.-z,data=X,weights=z)
coef(fit1,mode='fraction',s=1)
fit2

I got this:

 coef(fit1,mode='fraction',s=1)
X1 X2 X3 X4 X5
-2.8603082 -0.8303739  0.1064474  3.6563283  2.8342368
 fit2

Call:
lm(formula = y ~ . - z, data = X, weights = z)

Coefficients:
(Intercept)   X1   X2   X3   X4
X5
-0.4227  -2.4817  -0.7105  -0.2611   2.6908   2.0295


Shouldn't they match? If not, what did I miss and how to correctly do lasso
with weights? Thanks a lot for any advice.

Young

[[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] Use of ellipses ... in argument list of optim(), integrate(), etc.

2008-03-13 Thread Ravi Varadhan
Hi,

 

I have noticed that there is a change in the use of ellipses or . in R
versions 2.6.1 and later.  In versions 2.5.1 and earlier, the . were always
at the end of the argument list, but in 2.6.1 they are placed after the main
arguments and before method control arguments.  This results in the user
having to specify the exact (complete) names of the control arguments, i.e.
partial matching is not allowed.  

 

An example with integrate() : 

 

 integrate(function(x) exp(-x^2), lower=-Inf, upper=L, subdiv=1000)

 

Error in f(x, ...) : unused argument(s) (subdiv = 1000)

 

 integrate(function(x) exp(-x^2), lower=-Inf, upper=L, subdivisions=1000)

 

1.633051 with absolute error  1.6e-06

 

 

Here is an example with optim():

 

 res - optim(50, fw, meth=BFGS, control=list(maxit=2, temp=20,
parscale=20)) 

 

Error in fn(par, ...) : unused argument(s) (meth = BFGS)

 

 

FYI, I am using R version 2.6.1 on Windows XP.

 

May I ask what the rationale behind this change is and also about the pros
and cons of the two different ways of specifying (.)?

 

Thank you very much.

 

Best,

Ravi.

 


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

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

 




 


[[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] fast way to compare two matrices of combinations

2008-03-13 Thread Mark W Kimpel
I have a list (length 750), each element containing a vector of unique 
strings (unique gene ids), with length up to ~40 (median 15). I want to 
compile a matrix of all possible triplets and their frequency within 
gene elements. Using combn and a lot of looping, I am accomplishing this 
but it is VERY slow.

I've tried to figure out a way to vectorize this, using match and 
%in%, but can't get my mind around it.

Below is my code. sig.tf.pairs is the list. Suggestions?

Mark



M - 3 # 3 for triplets, etc.
##
# count all triplets
all.triplets - NULL
all.count.vec - NULL
for (i in 1:length(sig.tf.pairs)){
   if (length(sig.tf.pairs[[i]] = M)){
 triplets - combn(sig.tf.pairs[[i]], M, simplify = TRUE)
 for (j in 1:ncol(triplets)){
   o - order(triplets[,j])
   triplets[,j] - triplets[o,j]
   count.vec - rep(1, ncol(triplets))
 }
 if (is.null(all.count.vec)){
   all.count.vec - count.vec
   all.triplets - triplets
 } else {
   redundant.vec - NULL
   for (k in 1:ncol(all.triplets)){
 for (m in 1:ncol(triplets)){
   if (length(intersect(triplets[,m], all.triplets[,k] == M))){
 all.count.vec[k] - all.count.vec[k] + 1
 redundant.vec - c(redundant.vec, m)
   }
 }
   }
   if(!is.null(redundant.vec)){
 triplets - triplets[,-redundant.vec]
 count.vec - count.vec[,-redundant.vec]
   }
   all.triplets - cbind(all.triplets, triplets)
   all.count.vec - c(all.count.vec, count.vec)
 }
   }
}
###

-- 

Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
Indiana University School of Medicine

15032 Hunter Court, Westfield, IN  46074

(317) 490-5129 Work,  Mobile  VoiceMail
(317) 204-4202 Home (no voice mail please)

mwkimpelatgmaildotcom

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


Re: [R] fast way to compare two matrices of combinations

2008-03-13 Thread Erik Iverson
Hello Mark -

It may help if you provide a (small) set of example input and what you'd 
like as your output.

Best,
Erik Iverson

Mark W Kimpel wrote:
 I have a list (length 750), each element containing a vector of unique 
 strings (unique gene ids), with length up to ~40 (median 15). I want to 
 compile a matrix of all possible triplets and their frequency within 
 gene elements. Using combn and a lot of looping, I am accomplishing this 
 but it is VERY slow.
 
 I've tried to figure out a way to vectorize this, using match and 
 %in%, but can't get my mind around it.
 
 Below is my code. sig.tf.pairs is the list. Suggestions?
 
 Mark
 
 
 
 M - 3 # 3 for triplets, etc.
 ##
 # count all triplets
 all.triplets - NULL
 all.count.vec - NULL
 for (i in 1:length(sig.tf.pairs)){
if (length(sig.tf.pairs[[i]] = M)){
  triplets - combn(sig.tf.pairs[[i]], M, simplify = TRUE)
  for (j in 1:ncol(triplets)){
o - order(triplets[,j])
triplets[,j] - triplets[o,j]
count.vec - rep(1, ncol(triplets))
  }
  if (is.null(all.count.vec)){
all.count.vec - count.vec
all.triplets - triplets
  } else {
redundant.vec - NULL
for (k in 1:ncol(all.triplets)){
  for (m in 1:ncol(triplets)){
if (length(intersect(triplets[,m], all.triplets[,k] == M))){
  all.count.vec[k] - all.count.vec[k] + 1
  redundant.vec - c(redundant.vec, m)
}
  }
}
if(!is.null(redundant.vec)){
  triplets - triplets[,-redundant.vec]
  count.vec - count.vec[,-redundant.vec]
}
all.triplets - cbind(all.triplets, triplets)
all.count.vec - c(all.count.vec, count.vec)
  }
}
 }
 ###


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


Re: [R] Types of quadrature

2008-03-13 Thread Ravi Varadhan
David,

The problem is with 1 - pghyp(.).  Here is a better way to compute your
omega - I first compute a complementary pghyp, which is 1 - pghyp, and
then use this to compute the numerator.  The denominator is okay as it is.

pghyp.c - function(x) sapply(x, function(x){integrate(function(x)dghyp(x),
lower=x, upper=Inf, subdivisions=1000, rel.tol=1.e-07)$val})

L - 1

int.num - integrate(function(x)pghyp.c(x), lower=L, upper=Inf)$val

int.denom - integrate(pghyp, lower = -Inf, upper = L)$val

 int.num
[1] 0.08397642

 int.denom
[1] 1.083976

You should contact the package developer to provide an option for computing
1 - pghyp by specifying an option such as lower.tail=FALSE, as it is done
with pnorm().  This would also solve your problem.

Hope this helps,
Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

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







-Original Message-
From: Lüthi David (luda) [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 13, 2008 12:16 PM
To: Ravi Varadhan
Subject: AW: [R] Types of quadrature

Hi Ravi

Thanks again. The integral exists because the ghyp density decays
exponentially for x - \infty. The problem is that pghyp (which performs
numerical integration of the density dghyp) gives 0 for large x (e.g. 2)
which results in (1 - pghyp) = 1 for large x and this of course diverges. I
know that there is a package rjacobi and also cwhmisc with function
adaptsim, however, both of them seem to be inappropriate.
Adaptsim does not accept infinite boundaries and rjacobi does need
quadrature nodes...

Best regards,
David



-Ursprüngliche Nachricht-
Von: Ravi Varadhan [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 13. März 2008 16:53
An: Lüthi David (luda)
Betreff: RE: [R] Types of quadrature


Hi David,

As integrate() says, your integrals for ghyp are probably divergent.  Do you
know any theoretical result that says that the ratio you are computing for
ghyp actually exists?  

Here is how you would integrate in your pnorm() example:

 integrate(function(x) pnorm(x, lower.tail=FALSE), lower=1, upper=Inf)

0.08331547 with absolute error  1.5e-07



Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

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






-Original Message-
From: Lüthi David (luda) [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 13, 2008 4:41 AM
To: Ravi Varadhan
Subject: AW: [R] Types of quadrature

Dear Prof. Ripley, Dear Prof. Varadhan

Forgive me for being unprecise. Let me demonstrate my problem in an example:

Assume the cumulative distribution function has to be integrated
numerically:

scalar.pnorm - function(x){
  return(integrate(dnorm, -Inf, x)$value)
}

.pnorm - Vectorize(scalar.pnorm)

integrate(function(x)1 - .pnorm(x), lower = 1, upper = Inf)$value



The final usage would be:

library(ghyp)

omega.ghyp - function(L, object = ghyp(), ...){
  int.num - integrate(function(x, object, ...)1 - pghyp(x, object, ...),
object = object, lower = L, upper = Inf, ...) 
  int.denom - integrate(pghyp, object = object, lower = -Inf, upper = L,
...)
  return(int.num$value / int.denom$value)
}

object - ghyp()
omega.ghyp(1, object)

I do not see a way to avoid this or reformulate those expressions!?

Many thanks and best regards,

David





-Ursprüngliche Nachricht-
Von: Ravi Varadhan [mailto:[EMAIL PROTECTED] 
Gesendet: Mittwoch, 12. März 2008 19:21
An: Lüthi David (luda); r-help@r-project.org
Betreff: RE: [R] Types of quadrature


Hi,

Why do you need an extension of integrate()?  integrate() is adaptive - it
uses an adaptive Gauss-Kronrod quadrature.

You can specify Inf and -Inf as upper and lower limits, resp., in
integrate().  In fact, this is what the help page recommends, and it also
discourages the use of a large number as a surrogate for Inf.

What is the specific problem or distribution that you are having trouble
with in using integrate()?

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  

[R] smoothest way to upgrade R, say from 2.6.1 to 2.6.2?

2008-03-13 Thread Galkowski, Jan
Like many software assemblies, R is updated frequently.  Also, it
creates its own release-numbered directory when it is installed.
Packages get dumped into the subdirectory library.  I have a personal
habit of storing documents related to R packages in the doc
subdirectory.

Here are my questions.

(1) How do people manage an upgrade, from 2.6.1, say, to 2.6.2?  2.6.2
will create its own subdirectory, obliging a copy of library contents to
the new spot.  The documents are easier. 

(2) The problem with simply copying library contents is a fear of upward
incompatibilities.  Am I worrying for naught here?  Are packages upward
compatible but possibly not downwardly so?

(3) What about changing shortcuts, places for .Rprofile and the like?
Do people have scripts that do all these things at once?  

It would be nice to have a single control file where R binaries and
libraries and the like could be specified.  That way, all that would
need to be done is edit one file with an uptick on a point release
number, say, and things would be fine.   I suggest this because R is so
rich and deep that there may well be such a thing I just don't know
about.  Or there may be a way of arranging things so they are done this
way.

Ideas?

  -- Jan



[[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] Use of ellipses ... in argument list of optim(), integrate(), etc.

2008-03-13 Thread Vincent Goulet
 From the NEWS file:

CHANGES IN R VERSION 2.6.0
SIGNIFICANT USER-VISIBLE CHANGES
  o integrate(), nlm(), nlminb(), optim(), optimize() and uniroot()  
now have '...' much earlier in their argument list. This reduces the  
chances of unintentional partial matching but means that the later  
arguments must be named in full.

---
   Vincent Goulet, Associate Professor
   École d'actuariat
   Université Laval, Québec
   [EMAIL PROTECTED]   http://vgoulet.act.ulaval.ca

Le jeu. 13 mars à 12:05, Ravi Varadhan a écrit :

 Hi,



 I have noticed that there is a change in the use of ellipses or . in R
 versions 2.6.1 and later.  In versions 2.5.1 and earlier, the . were  
 always
 at the end of the argument list, but in 2.6.1 they are placed after  
 the main
 arguments and before method control arguments.  This results in the  
 user
 having to specify the exact (complete) names of the control  
 arguments, i.e.
 partial matching is not allowed.

 An example with integrate() :

 integrate(function(x) exp(-x^2), lower=-Inf, upper=L, subdiv=1000)

 Error in f(x, ...) : unused argument(s) (subdiv = 1000)

 integrate(function(x) exp(-x^2), lower=-Inf, upper=L,  
 subdivisions=1000)

 1.633051 with absolute error  1.6e-06

 Here is an example with optim():

 res - optim(50, fw, meth=BFGS, control=list(maxit=2, temp=20,
 parscale=20))

 Error in fn(par, ...) : unused argument(s) (meth = BFGS)

 FYI, I am using R version 2.6.1 on Windows XP.

 May I ask what the rationale behind this change is and also about  
 the pros
 and cons of the two different ways of specifying (.)?

 Thank you very much.

 Best,

 Ravi.

 
 Ravi Varadhan, Ph.D.
 Assistant Professor, The Center on Aging and Health
 Division of Geriatric Medicine and Gerontology
 Johns Hopkins University
 Ph: (410) 502-2619
 Fax: (410) 614-9625
 Email: [EMAIL PROTECTED]
 Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html
 

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

2008-03-13 Thread Economics Guy
This is a question I have wanted to ask for a while but hesitated
because I was sut sure I would find the answer on my own, but as of
yet...no dice.

1) Is there a way to use the loop number in naming things in R.
Specifically I have  a simulation that has two loops. I would like to
be able to write out the results to a csv file after each iteration.

something like:


for (i in 1:10){

exampleMatrix -  matrix(runif(25, 0, 1),5, 5)

write.csv(exampleMatrix, file = resultsMatrix_i.csv)

}

Where I would get 10 csv files named resultsMatrix_1, resultsMatrix_2
... resultsMatrix_10.


2) On a similar note is there a way to use the loop number when naming things.

something like:


for (i in 1:10){

exampleMatrix_i -  matrix(runif(25, 0, 1),5, 5)

}

Where I would then have 10 matrices in memory with the names
exampleMatrix_1, exampleMatrix_2 ... exampleMatrix_10.

Thanks,

EG

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

2008-03-13 Thread Aimin Yan
I want to label each bar on the top of bars when using barplot.

anyone know how to do this?

thanks

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


Re: [R] Use of ellipses ... in argument list of optim(), integrate(), etc.

2008-03-13 Thread Ravi Varadhan
Thank you, Vince.

Best,
Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

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







-Original Message-
From: Vincent Goulet [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 13, 2008 1:09 PM
To: Ravi Varadhan
Cc: r-help@r-project.org
Subject: Re: [R] Use of ellipses ... in argument list of optim(),
integrate(), etc.

 From the NEWS file:

CHANGES IN R VERSION 2.6.0
SIGNIFICANT USER-VISIBLE CHANGES
  o integrate(), nlm(), nlminb(), optim(), optimize() and uniroot()  
now have '...' much earlier in their argument list. This reduces the  
chances of unintentional partial matching but means that the later  
arguments must be named in full.

---
   Vincent Goulet, Associate Professor
   École d'actuariat
   Université Laval, Québec
   [EMAIL PROTECTED]   http://vgoulet.act.ulaval.ca

Le jeu. 13 mars à 12:05, Ravi Varadhan a écrit :

 Hi,



 I have noticed that there is a change in the use of ellipses or . in R
 versions 2.6.1 and later.  In versions 2.5.1 and earlier, the . were  
 always
 at the end of the argument list, but in 2.6.1 they are placed after  
 the main
 arguments and before method control arguments.  This results in the  
 user
 having to specify the exact (complete) names of the control  
 arguments, i.e.
 partial matching is not allowed.

 An example with integrate() :

 integrate(function(x) exp(-x^2), lower=-Inf, upper=L, subdiv=1000)

 Error in f(x, ...) : unused argument(s) (subdiv = 1000)

 integrate(function(x) exp(-x^2), lower=-Inf, upper=L,  
 subdivisions=1000)

 1.633051 with absolute error  1.6e-06

 Here is an example with optim():

 res - optim(50, fw, meth=BFGS, control=list(maxit=2, temp=20,
 parscale=20))

 Error in fn(par, ...) : unused argument(s) (meth = BFGS)

 FYI, I am using R version 2.6.1 on Windows XP.

 May I ask what the rationale behind this change is and also about  
 the pros
 and cons of the two different ways of specifying (.)?

 Thank you very much.

 Best,

 Ravi.

 
 Ravi Varadhan, Ph.D.
 Assistant Professor, The Center on Aging and Health
 Division of Geriatric Medicine and Gerontology
 Johns Hopkins University
 Ph: (410) 502-2619
 Fax: (410) 614-9625
 Email: [EMAIL PROTECTED]
 Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html



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


Re: [R] Use of ellipses ... in argument list of optim(), integrate(), etc.

2008-03-13 Thread Tony Plate
Ravi Varadhan wrote:
 Hi,
 
 I have noticed that there is a change in the use of ellipses or . in R
 versions 2.6.1 and later.  In versions 2.5.1 and earlier, the . were always
 at the end of the argument list, but in 2.6.1 they are placed after the main
 arguments and before method control arguments.  This results in the user
 having to specify the exact (complete) names of the control arguments, i.e.
 partial matching is not allowed.  
 
 An example with integrate() : 
 
 integrate(function(x) exp(-x^2), lower=-Inf, upper=L, subdiv=1000)
 
 Error in f(x, ...) : unused argument(s) (subdiv = 1000)
 
 integrate(function(x) exp(-x^2), lower=-Inf, upper=L, subdivisions=1000)
 
 1.633051 with absolute error  1.6e-06
 
 Here is an example with optim():
 
 res - optim(50, fw, meth=BFGS, control=list(maxit=2, temp=20,
 parscale=20)) 
 
 Error in fn(par, ...) : unused argument(s) (meth = BFGS)
 
 FYI, I am using R version 2.6.1 on Windows XP.
 
 May I ask what the rationale behind this change is and also about the pros
 and cons of the two different ways of specifying (.)?

Putting optim() arguments after the ... disallows the use of abbreviated 
actual arguments for optim().  This is generally a good thing, because 
prior to this change, it was impossible to supply, via the '...' arguments 
of optim(), an argument to fn() whose name was a prefix of one of the 
arguments of optim().  E.g., if your function had a argument named 'm', you 
could not previously supply it via the '...' argument of optim(), because 
if you did something like optim(x, fun, m=240), intending 'm' to be passed 
to 'fun', the 'm' would instead match the 'method' argument of optim().

The cons of the new argument structure are that abbreviations for names of 
arguments of optim() can't be used (a minor and debatable con), and that 
previous code that used abbreviations might break, but it will likely break 
quickly and noisily, so it's not too bad (the only case where it wouldn't 
break is when fn has a '...' argument itself, and it ignores unrecognized 
components, or where the are other argument name collisions).

-- Tony Plate

 
  
 
 Thank you very much.
 
  
 
 Best,
 
 Ravi.
 
  
 
 
 ---
 
 Ravi Varadhan, Ph.D.
 
 Assistant Professor, The Center on Aging and Health
 
 Division of Geriatric Medicine and Gerontology 
 
 Johns Hopkins University
 
 Ph: (410) 502-2619
 
 Fax: (410) 614-9625
 
 Email: [EMAIL PROTECTED]
 
 Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html
 
  
 
 
 
 
  
 
 
   [[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] smoothest way to upgrade R, say from 2.6.1 to 2.6.2?

2008-03-13 Thread Stefan Grosse
On Thursday 13 March 2008 06:05:15 pm Galkowski, Jan wrote:
GJ (1) How do people manage an upgrade, from 2.6.1, say, to 2.6.2?  2.6.2
GJ will create its own subdirectory, obliging a copy of library contents to
GJ the new spot.  The documents are easier.

You forgot to enlighten us about your system. From what you are telling I 
would guess its Windows (XP?). On my windows machine I install R in the very 
same directory of the old R. So you could create programs/R and there install 
your R but of course you must then alternate the suggested directory during 
the installation.

GJ
GJ (2) The problem with simply copying library contents is a fear of upward
GJ incompatibilities.  Am I worrying for naught here?  Are packages upward
GJ compatible but possibly not downwardly so?

There is no problem within minor releases like 2.6.1 - 2.6.2 but on 
greater jumps update.packages offers the option checkbuilt which if set 
TRUE updates the packages to their next built. So if 2.7.0 is released and 
you install that are over your old you should enable this option.


GJ (3) What about changing shortcuts, places for .Rprofile and the like?
GJ Do people have scripts that do all these things at once?

See above

GJ
GJ It would be nice to have a single control file where R binaries and
GJ libraries and the like could be specified.  That way, all that would
GJ need to be done is edit one file with an uptick on a point release
GJ number, say, and things would be fine.   

I don't think this is necessary.

Cheers
Stefan



-- 
Microeconomics
University of Erfurt

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

2008-03-13 Thread Erik Iverson
See ?paste and ?assign, those will get what you want done.

At least in the second case, you might consider using a list, however. 
You can then avoid the use of 'for' loops by using functions such as lapply.

Best,
Erik Iverson

Economics Guy wrote:
 This is a question I have wanted to ask for a while but hesitated
 because I was sut sure I would find the answer on my own, but as of
 yet...no dice.
 
 1) Is there a way to use the loop number in naming things in R.
 Specifically I have  a simulation that has two loops. I would like to
 be able to write out the results to a csv file after each iteration.
 
 something like:
 
 
 for (i in 1:10){
   
   exampleMatrix -  matrix(runif(25, 0, 1),5, 5)
   
   write.csv(exampleMatrix, file = resultsMatrix_i.csv)
   
   }
 
 Where I would get 10 csv files named resultsMatrix_1, resultsMatrix_2
 ... resultsMatrix_10.
 
 
 2) On a similar note is there a way to use the loop number when naming things.
 
 something like:
 
 
 for (i in 1:10){
   
   exampleMatrix_i -  matrix(runif(25, 0, 1),5, 5)
   
   }
 
 Where I would then have 10 matrices in memory with the names
 exampleMatrix_1, exampleMatrix_2 ... exampleMatrix_10.
 
 Thanks,
 
 EG
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 loop numbers in write.csv

2008-03-13 Thread Economics Guy
Thanks!

Double thanks to Phil, I used your guide to learn LaTeX many moons ago.

On Thu, Mar 13, 2008 at 1:26 PM, Greg Snow [EMAIL PROTECTED] wrote:

  For filenames you can do something like:

   file = paste(resultsMatrix_', i, sep='')

  For naming objects in the workspace, there is a way, but you really
  don't want to do that.  It is better to store them in a list, for
  example:

  resultList - list()

 for( i in 1:10){
 resultList[[i]] -  matrix(runif(25, 0, 1),5, 5)
}

  If you want the elements of the list named you can do:

  names( resultList ) - paste('resultMatrix_',1:10, sep='')

  Now you have 10 matricies all grouped together in a list, you can access
  a single matrix like resultList[[1]] or resultList$resultMatrix_1, or
  you can do something to all of them using lapply or sapply.  You are
  much less likely to overwrite data by accident, you can save, copy,
  load, delete, etc the whole set in 1 step rather than using a loop.

  Hope this helps,

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





   -Original Message-
   From: [EMAIL PROTECTED]
   [mailto:[EMAIL PROTECTED] On Behalf Of Economics Guy
   Sent: Thursday, March 13, 2008 11:07 AM
   To: [EMAIL PROTECTED]
   Subject: [R] Using loop numbers in write.csv
  
   This is a question I have wanted to ask for a while but
   hesitated because I was sut sure I would find the answer on
   my own, but as of yet...no dice.
  
   1) Is there a way to use the loop number in naming things in R.
   Specifically I have  a simulation that has two loops. I would
   like to be able to write out the results to a csv file after
   each iteration.
  
   something like:
  
  
   for (i in 1:10){
  
 exampleMatrix -  matrix(runif(25, 0, 1),5, 5)
  
 write.csv(exampleMatrix, file = resultsMatrix_i.csv)
  
 }
  
   Where I would get 10 csv files named resultsMatrix_1,
   resultsMatrix_2 ... resultsMatrix_10.
  
  
   2) On a similar note is there a way to use the loop number
   when naming things.
  
   something like:
  
  
   for (i in 1:10){
  
 exampleMatrix_i -  matrix(runif(25, 0, 1),5, 5)
  
 }
  
   Where I would then have 10 matrices in memory with the names
   exampleMatrix_1, exampleMatrix_2 ... exampleMatrix_10.
  
   Thanks,
  
   EG
  


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





-- 
Robi Ragan
Graduate Student
Department of Economics
Department of Political Science
The University of Georgia
robi.myweb.uga.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] Using loop numbers in write.csv

2008-03-13 Thread Greg Snow

For filenames you can do something like:

 file = paste(resultsMatrix_', i, sep='')

For naming objects in the workspace, there is a way, but you really
don't want to do that.  It is better to store them in a list, for
example:

resultList - list()
for( i in 1:10){
resultList[[i]] -  matrix(runif(25, 0, 1),5, 5)
   }

If you want the elements of the list named you can do:

names( resultList ) - paste('resultMatrix_',1:10, sep='')

Now you have 10 matricies all grouped together in a list, you can access
a single matrix like resultList[[1]] or resultList$resultMatrix_1, or
you can do something to all of them using lapply or sapply.  You are
much less likely to overwrite data by accident, you can save, copy,
load, delete, etc the whole set in 1 step rather than using a loop.

Hope this helps,

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

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Economics Guy
 Sent: Thursday, March 13, 2008 11:07 AM
 To: [EMAIL PROTECTED]
 Subject: [R] Using loop numbers in write.csv
 
 This is a question I have wanted to ask for a while but 
 hesitated because I was sut sure I would find the answer on 
 my own, but as of yet...no dice.
 
 1) Is there a way to use the loop number in naming things in R.
 Specifically I have  a simulation that has two loops. I would 
 like to be able to write out the results to a csv file after 
 each iteration.
 
 something like:
 
 
 for (i in 1:10){
   
   exampleMatrix -  matrix(runif(25, 0, 1),5, 5)
   
   write.csv(exampleMatrix, file = resultsMatrix_i.csv)
   
   }
 
 Where I would get 10 csv files named resultsMatrix_1, 
 resultsMatrix_2 ... resultsMatrix_10.
 
 
 2) On a similar note is there a way to use the loop number 
 when naming things.
 
 something like:
 
 
 for (i in 1:10){
   
   exampleMatrix_i -  matrix(runif(25, 0, 1),5, 5)
   
   }
 
 Where I would then have 10 matrices in memory with the names 
 exampleMatrix_1, exampleMatrix_2 ... exampleMatrix_10.
 
 Thanks,
 
 EG
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] label each bar by value

2008-03-13 Thread John Kane
?text 

tmp - c(34,22,77)
tmp.labels - c(cat, dog, sheep)
tmp2 - barplot(tmp, ylim=c(0, max(tmp)+10))
text(1:3, tmp+2 , labels=tmp.labels)

--- Aimin Yan [EMAIL PROTECTED] wrote:

 I want to label each bar on the top of bars when
 using barplot.
 
 anyone know how to do this?
 
 thanks
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


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


Re: [R] label each bar by value

2008-03-13 Thread Greg Snow
There was a discussion on this a while back, see:
http://tolstoy.newcastle.edu.au/R/e2/help/07/08/22858.html

There is some good discussion there on why you may not want to do this
(adding the numbers at the tops of bars tends to distort the visual
comparison of heights, among other things).  If you follow the thread
for a while and think about what you really want to do, there are some
examples of alternative ways to accomplish what you probably really want
to do.

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

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Aimin Yan
 Sent: Thursday, March 13, 2008 11:10 AM
 To: r-help@r-project.org
 Subject: [R] label each bar by value
 
 I want to label each bar on the top of bars when using barplot.
 
 anyone know how to do this?
 
 thanks
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


[R] VGAM and persp function

2008-03-13 Thread Quan Li
Hi all,

I loaded VGAM, which masks the persp function from graphics. How can I run the 
persp function after running VGAM? I tried reloading graphics but it did not 
work. Thank you.

quan

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


Re: [R] [PS] Re: a more elegant way to get percentages? (now R books)

2008-03-13 Thread hadley wickham
  There has been a virtual population explosion of R books in recent years
  and we all have our favorites.  You may wish to pick one oriented toward
  your specialty, but the absolute minimum lowest common denominator (by
  which I mean that it has the ground zero essential information that all
  users must share, not that it is minimal or incomplete) is the manual
  An Introduction to R, available by download from the Cran website.

I don't mean to pick on you in particular, or on the authors of An
introduction to R, but I really don't see how anyone in good
conscience can recommend this to a new user of R.  I think it does a
great job of covering the basics, and is probably a good read after
you've been using R for a year or so, but in goes into a lot of depth
into things that you really don't need to know for doing practical,
day-to-day data analysis.

For example, you don't find out how to actually load data into R until
page 30, while you get 3 page on the mode and length of objects at
page 12.  Do we really need to know that an empty (zero length) vector
still has a mode?

These comments are based on my experience teaching R to undergrad stat
majors, and so may not apply to your audience.  If you teach R in the
same order as an introduction to R it takes you about 4 weeks before
you can actually do anything useful with R, by which time the students
are bored to tears.  If you start with getting data into R and
displaying the data with graphics, you can do useful things very
quickly, providing interest and motivation, and then you can gradually
introduce a more rigourous description of the components as needed.

Hadley

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

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


Re: [R] cumsum list..

2008-03-13 Thread Julian Burgos
In this case you can simply do

cumsum(a[x,]+a[y,])

Julian


yoo wrote:
 Hi all, i have the following.. 
 
 a - data.frame(data = seq(1,10))
 
 i have indices:
 x - c(1, 5, 3, 9)
 y - c(2, 7, 4, 10)
 
 I want the cumsum of a[1:2], a[5:7], a[3:4]... 
 
 is there an elegant way to do it without any loop? Thanks!


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


Re: [R] VGAM and persp function

2008-03-13 Thread Greg Snow
Try 

 graphics::persp( . . .

Whin you run just persp, it runs the first copy it finds, with the
graphics:: on the front in specifically runs the one from the graphics
package.

Hope this helps,

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

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Quan Li
 Sent: Thursday, March 13, 2008 11:50 AM
 To: r-help@r-project.org
 Subject: [R] VGAM and persp function
 
 Hi all,
 
 I loaded VGAM, which masks the persp function from graphics. 
 How can I run the persp function after running VGAM? I tried 
 reloading graphics but it did not work. Thank you.
 
 quan
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] smoothest way to upgrade R, say from 2.6.1 to 2.6.2?

2008-03-13 Thread Gabor Grothendieck
I think Stefan has answered this so I will just
add this about batchfiles.  In the batchfiles distrirbution:

http://batchfiles.googlecode.com

is a file Rgui.bat.  If you put that anywhere in your path and make
your shortcut to that instead of to R itself then it will find the most
recent version of R from the registry and start that so you don't have
to update shortcuts each time you change R versions.  There are
also Rcmd.bat, sweave.bat and similar versions for the corresponding
tasks.  Using those you never have to set your path to R when
installing or upgrading R on Windows.

The most recent version of batchfiles is for Vista and the next to
most recent is for XP as per home page.

If you do want to move or copy your packages from one library to
another movedir.bat and copydir.bat will do that.  You can then use
checkbuilt if its a major version change.  There are also some other
methods described in the Links on the home page.

On Thu, Mar 13, 2008 at 1:23 PM, Stefan Grosse [EMAIL PROTECTED] wrote:
 On Thursday 13 March 2008 06:05:15 pm Galkowski, Jan wrote:
 GJ (1) How do people manage an upgrade, from 2.6.1, say, to 2.6.2?  2.6.2
 GJ will create its own subdirectory, obliging a copy of library contents to
 GJ the new spot.  The documents are easier.

 You forgot to enlighten us about your system. From what you are telling I
 would guess its Windows (XP?). On my windows machine I install R in the very
 same directory of the old R. So you could create programs/R and there install
 your R but of course you must then alternate the suggested directory during
 the installation.

 GJ
 GJ (2) The problem with simply copying library contents is a fear of upward
 GJ incompatibilities.  Am I worrying for naught here?  Are packages upward
 GJ compatible but possibly not downwardly so?

 There is no problem within minor releases like 2.6.1 - 2.6.2 but on
 greater jumps update.packages offers the option checkbuilt which if set
 TRUE updates the packages to their next built. So if 2.7.0 is released and
 you install that are over your old you should enable this option.


 GJ (3) What about changing shortcuts, places for .Rprofile and the like?
 GJ Do people have scripts that do all these things at once?

 See above

 GJ
 GJ It would be nice to have a single control file where R binaries and
 GJ libraries and the like could be specified.  That way, all that would
 GJ need to be done is edit one file with an uptick on a point release
 GJ number, say, and things would be fine.

 I don't think this is necessary.

 Cheers
 Stefan



 --
 Microeconomics
 University of Erfurt


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Use of ellipses ... in argument list of optim(), integrate(), etc.

2008-03-13 Thread Prof Brian Ripley
There is an entry in the NEWS file for 2.6.0:

CHANGES IN R VERSION 2.6.0


SIGNIFICANT USER-VISIBLE CHANGES

 o  integrate(), nlm(), nlminb(), optim(), optimize() and uniroot()
now have '...' much earlier in their argument list.  This
reduces the chances of unintentional partial matching but
means that the later arguments must be named in full.

and there was a spate of instances of 'unintentional partial matching' at 
the time.

I have have no idea what you mean by 'ellipses or .' -- this is literally 
'...', and ellipses (e.g. Unicode U+226) do not work. From 
http://en.wikipedia.org/wiki/Ellipsis

   Most programming languages other than Perl6 require the ellipsis to be
   written as a series of periods; a single (Unicode) ellipsis character
   cannot be used.

Please use R-devel for questions about the design and development of R 
(see the posting guide).


On Thu, 13 Mar 2008, Ravi Varadhan wrote:

 Hi,



 I have noticed that there is a change in the use of ellipses or . in R
 versions 2.6.1 and later.  In versions 2.5.1 and earlier, the . were always
 at the end of the argument list, but in 2.6.1 they are placed after the main
 arguments and before method control arguments.  This results in the user
 having to specify the exact (complete) names of the control arguments, i.e.
 partial matching is not allowed.



 An example with integrate() :



 integrate(function(x) exp(-x^2), lower=-Inf, upper=L, subdiv=1000)



 Error in f(x, ...) : unused argument(s) (subdiv = 1000)



 integrate(function(x) exp(-x^2), lower=-Inf, upper=L, subdivisions=1000)



 1.633051 with absolute error  1.6e-06





 Here is an example with optim():



 res - optim(50, fw, meth=BFGS, control=list(maxit=2, temp=20,
 parscale=20))



 Error in fn(par, ...) : unused argument(s) (meth = BFGS)





 FYI, I am using R version 2.6.1 on Windows XP.



 May I ask what the rationale behind this change is and also about the pros
 and cons of the two different ways of specifying (.)?



 Thank you very much.



 Best,

 Ravi.



 
 ---

 Ravi Varadhan, Ph.D.

 Assistant Professor, The Center on Aging and Health

 Division of Geriatric Medicine and Gerontology

 Johns Hopkins University

 Ph: (410) 502-2619

 Fax: (410) 614-9625

 Email: [EMAIL PROTECTED]

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



 
 




   [[alternative HTML version deleted]]

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


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

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


Re: [R] fast way to compare two matrices of combinations

2008-03-13 Thread Charles C. Berry
On Thu, 13 Mar 2008, Mark W Kimpel wrote:

 I have a list (length 750), each element containing a vector of unique
 strings (unique gene ids), with length up to ~40 (median 15). I want to
 compile a matrix of all possible triplets and their frequency within
 gene elements. Using combn and a lot of looping, I am accomplishing this
 but it is VERY slow.

 I've tried to figure out a way to vectorize this, using match and
 %in%, but can't get my mind around it.

 Below is my code. sig.tf.pairs is the list. Suggestions?

First, be sure that your code does what you really intend for it to do.

Does this really do what you wanted?

   if (length(intersect(triplets[,m], all.triplets[,k] == M))){

If so, then why does the first line below never produce an error?

 count.vec - count.vec[,-redundant.vec]

is.null(dim(count.vec)) ## TRUE

You are basically tabulating. Use the functions that are built for that.

It looks like what you want is along these lines:

tab.combns - function(x) apply( combn( sort(x), M ),2,
function(x) paste(x,collapse=''))

tab.all - table( unlist( lapply(sig.tf.pairs,tab.combns) ) )

Chuck

 Mark


 
 M - 3 # 3 for triplets, etc.
 ##
 # count all triplets
 all.triplets - NULL
 all.count.vec - NULL
 for (i in 1:length(sig.tf.pairs)){
   if (length(sig.tf.pairs[[i]] = M)){
 triplets - combn(sig.tf.pairs[[i]], M, simplify = TRUE)
 for (j in 1:ncol(triplets)){
   o - order(triplets[,j])
   triplets[,j] - triplets[o,j]
   count.vec - rep(1, ncol(triplets))
 }
 if (is.null(all.count.vec)){
   all.count.vec - count.vec
   all.triplets - triplets
 } else {
   redundant.vec - NULL
   for (k in 1:ncol(all.triplets)){
 for (m in 1:ncol(triplets)){
   if (length(intersect(triplets[,m], all.triplets[,k] == M))){
 all.count.vec[k] - all.count.vec[k] + 1
 redundant.vec - c(redundant.vec, m)
   }
 }
   }
   if(!is.null(redundant.vec)){
 triplets - triplets[,-redundant.vec]
 count.vec - count.vec[,-redundant.vec]
   }
   all.triplets - cbind(all.triplets, triplets)
   all.count.vec - c(all.count.vec, count.vec)
 }
   }
 }
 ###

 -- 

 Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
 Indiana University School of Medicine

 15032 Hunter Court, Westfield, IN  46074

 (317) 490-5129 Work,  Mobile  VoiceMail
 (317) 204-4202 Home (no voice mail please)

 mwkimpelatgmaildotcom

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


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

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


Re: [R] generalized linear mixed models with a beta distribution

2008-03-13 Thread Craig A Faulhaber
Thanks for the tips and clarifications.  I'm a newbie and don't always 
have the terminology down correctly.  My understanding is that one 
should be able to use generalized linear mixed models to model response 
variables that take any of the exponential family of distributions.  The 
beta distribution belongs to this family and can be modeled in PROC 
GLIMMIX in SAS.  I was hoping to find something similar in R.  Is 
modeling in nlme via a variance specification the best and/or only 
option available in R?

For clarification, here's what I'm trying to model:
I have a beta-distributed response variable (y).  I have a fixed-effect 
explanatory variable (treatment), and I'd like to include a random term 
for individuals used in the experiment.  The model in lmer would be:  y 
~ treatment + (1 | individual).   As far as I can tell, the appropriate 
link function for the model would be the logit.

Thanks again, Professor Ripley, for your comments and suggestions.

Craig

Prof Brian Ripley wrote:
 glmmPQL can fit the same GLM families as glm() can -- it does not list 
 _any_ .

 Howver, the beta distribution does not give a GLM family and hence 
 your subject line is strictly about a non-existent concept.  I'm 
 presuming that you want to model the logit of the mean of a beta by a 
 random effects model -- it is unclear what you want to do with the 
 other parameter.

 Note that the beta does fit into the framework of package gamlss, but 
 I am not aware of an option for random effects in that framework.

 On Wed, 12 Mar 2008, Craig A Faulhaber wrote:

 Greetings,

 I am interested in using a generalized linear mixed model with data that
 best fits a beta distribution (i.e., the data is bounded between 0 and 1
 but is not binomial).  I noticed that the beta distribution is not
 listed as an option in the family objects for glmmPQL or  lmer.  I
 found a thread on this listserve from 2006 ([R] lmer and a response
 that is a proportion) that indicated that there was no package

 https://stat.ethz.ch/pipermail/r-help/2006-December/121567.html

 available for mixed effects models with a beta distribution at that
 time.  This thread also indicated that package betareg did not allow
 inclusion of random effects.

 But it did suggest modelling this in nlme via a variance 
 specification, and that remains a good suggestion.

 Does anyone know of a package or code for a generalized linear mixed
 model that allows a beta distribution?  Transforming my data might allow
 me to use another family, but I would rather not transform the data if
 possible.  Thanks for your help!

 Sincerely,
 Craig Faulhaber


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Splitting a set of vectors in a list

2008-03-13 Thread John Kane
I have a set of character vectors of uneven length
that I have stored in a list.  I can easily enough get
any column of them  using lapply but what I want is to
be able to create a matrix of them.  Other than some
kind of brute force looping approach I have drawn a
blank. 

Would somebody please suggest something? Thanks
 
Example.

mylist - list(aa=c(cat,peach ), bb=c(dog,
apple, iron), 
 cc = c(rabbit, orange, zinc, silk))
myfun - function(dff) dff[1]   
vect1  - unlist(lapply(mylist, myfun))


  Looking for the perfect gift? Give the gift of Flickr!

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


Re: [R] smoothest way to upgrade R, say from 2.6.1 to 2.6.2?

2008-03-13 Thread Prof Brian Ripley
If this _is_ Windows, the question is discussed in detail in the rw-FAQ.
That document also discusses how to install packages into a site or 
personal library which can make upgrading easier.

Another consideration not told to us was whether one wants to keep around 
a working copy of the older version.  My dept does so (so students can use 
a consistent version when preparing their theses, for example), and that 
affects the choice of strategy.

On Thu, 13 Mar 2008, Stefan Grosse wrote:

 On Thursday 13 March 2008 06:05:15 pm Galkowski, Jan wrote:
 GJ (1) How do people manage an upgrade, from 2.6.1, say, to 2.6.2?  2.6.2
 GJ will create its own subdirectory, obliging a copy of library contents to
 GJ the new spot.  The documents are easier.

 You forgot to enlighten us about your system. From what you are telling I
 would guess its Windows (XP?). On my windows machine I install R in the very
 same directory of the old R. So you could create programs/R and there install
 your R but of course you must then alternate the suggested directory during
 the installation.

 GJ
 GJ (2) The problem with simply copying library contents is a fear of upward
 GJ incompatibilities.  Am I worrying for naught here?  Are packages upward
 GJ compatible but possibly not downwardly so?

 There is no problem within minor releases like 2.6.1 - 2.6.2 but on
 greater jumps update.packages offers the option checkbuilt which if set
 TRUE updates the packages to their next built. So if 2.7.0 is released and
 you install that are over your old you should enable this option.


 GJ (3) What about changing shortcuts, places for .Rprofile and the like?
 GJ Do people have scripts that do all these things at once?

 See above

 GJ
 GJ It would be nice to have a single control file where R binaries and
 GJ libraries and the like could be specified.  That way, all that would
 GJ need to be done is edit one file with an uptick on a point release
 GJ number, say, and things would be fine.

 I don't think this is necessary.

 Cheers
 Stefan



 --
 Microeconomics
 University of Erfurt

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


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

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


[R] Plot contour over filled contour

2008-03-13 Thread Devred, Emmanuel
Dear R-users,

I haven't found a way in the searchable archive to overplot a contour
(lines) over a surface.
I have a (n,m)  matrix that represents sea surface temperature that I
have plotted using image.plot(), filled.contour() or image(). I would
like to overplot this image with some contour lines of mixed layer depth
values(same size matrix). How can I do this?

 Any help is appreciated, thank you,

   Emmanuel

---
Dr. Emmanuel Devred
Bedford Institute of Oceanography,
1 Challenger Drive,
Dartmouth, Nova Scotia, B2Y 4A2,
Canada

Ph:  (1) 902 426-4681
Fax: (1) 902 426-9388

[EMAIL PROTECTED]

http://myweb.dal.ca/edevred/
---



[[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] Use of ellipses ... in argument list of optim(), integrate(), etc.

2008-03-13 Thread Ravi Varadhan
Thanks to Tony Plate, Vince Goulet, and Prof. Brian Ripley (I apologize for
not posting this to R-devel).  

It is nice to know that there can be no unintended side-effects of this new
ellipsical convention, other than the inconvenience of having to provide
complete names of arguments after the ellipsis.

Best,
Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

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

 





-Original Message-
From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 13, 2008 2:01 PM
To: Ravi Varadhan
Cc: r-help@r-project.org
Subject: Re: [R] Use of ellipses ... in argument list of optim(),
integrate(), etc.

There is an entry in the NEWS file for 2.6.0:

CHANGES IN R VERSION 2.6.0


SIGNIFICANT USER-VISIBLE CHANGES

 o  integrate(), nlm(), nlminb(), optim(), optimize() and uniroot()
now have '...' much earlier in their argument list.  This
reduces the chances of unintentional partial matching but
means that the later arguments must be named in full.

and there was a spate of instances of 'unintentional partial matching' at 
the time.

I have have no idea what you mean by 'ellipses or .' -- this is literally 
'...', and ellipses (e.g. Unicode U+226) do not work. From 
http://en.wikipedia.org/wiki/Ellipsis

   Most programming languages other than Perl6 require the ellipsis to be
   written as a series of periods; a single (Unicode) ellipsis character
   cannot be used.

Please use R-devel for questions about the design and development of R 
(see the posting guide).


On Thu, 13 Mar 2008, Ravi Varadhan wrote:

 Hi,



 I have noticed that there is a change in the use of ellipses or . in R
 versions 2.6.1 and later.  In versions 2.5.1 and earlier, the . were
always
 at the end of the argument list, but in 2.6.1 they are placed after the
main
 arguments and before method control arguments.  This results in the user
 having to specify the exact (complete) names of the control arguments,
i.e.
 partial matching is not allowed.



 An example with integrate() :



 integrate(function(x) exp(-x^2), lower=-Inf, upper=L, subdiv=1000)



 Error in f(x, ...) : unused argument(s) (subdiv = 1000)



 integrate(function(x) exp(-x^2), lower=-Inf, upper=L, subdivisions=1000)



 1.633051 with absolute error  1.6e-06





 Here is an example with optim():



 res - optim(50, fw, meth=BFGS, control=list(maxit=2, temp=20,
 parscale=20))



 Error in fn(par, ...) : unused argument(s) (meth = BFGS)





 FYI, I am using R version 2.6.1 on Windows XP.



 May I ask what the rationale behind this change is and also about the pros
 and cons of the two different ways of specifying (.)?



 Thank you very much.



 Best,

 Ravi.





 ---

 Ravi Varadhan, Ph.D.

 Assistant Professor, The Center on Aging and Health

 Division of Geriatric Medicine and Gerontology

 Johns Hopkins University

 Ph: (410) 502-2619

 Fax: (410) 614-9625

 Email: [EMAIL PROTECTED]

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





 




   [[alternative HTML version deleted]]

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


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

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


Re: [R] Splitting a set of vectors in a list

2008-03-13 Thread Erik Iverson
What would you want your output matrix to look like given mylist?

John Kane wrote:
 I have a set of character vectors of uneven length
 that I have stored in a list.  I can easily enough get
 any column of them  using lapply but what I want is to
 be able to create a matrix of them.  Other than some
 kind of brute force looping approach I have drawn a
 blank. 
 
 Would somebody please suggest something? Thanks
  
 Example.
 
 mylist - list(aa=c(cat,peach ), bb=c(dog,
 apple, iron), 
  cc = c(rabbit, orange, zinc, silk))
 myfun - function(dff) dff[1]   
 vect1  - unlist(lapply(mylist, myfun))
 
 
   Looking for the perfect gift? Give the gift of Flickr!
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Splitting a set of vectors in a list

2008-03-13 Thread John Kane
Ideally something like this:
==
t(cbind( c(cat ,  peach , NA, NA), bbb  - c(dog
,  apple ,iron, NA),
ccb - c(rabbit ,orange ,zinc ,  silk ))) 

==

Thanks

--- Erik Iverson [EMAIL PROTECTED] wrote:

 What would you want your output matrix to look like
 given mylist?
 
 John Kane wrote:
  I have a set of character vectors of uneven length
  that I have stored in a list.  I can easily enough
 get
  any column of them  using lapply but what I want
 is to
  be able to create a matrix of them.  Other than
 some
  kind of brute force looping approach I have drawn
 a
  blank. 
  
  Would somebody please suggest something? Thanks
   
  Example.
  
  mylist - list(aa=c(cat,peach ), bb=c(dog,
  apple, iron), 
   cc = c(rabbit, orange, zinc,
 silk))
  myfun - function(dff) dff[1]   
  vect1  - unlist(lapply(mylist, myfun))
  
  
Looking for the perfect gift? Give the gift
 of Flickr!
  
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained,
 reproducible code.
 



[[elided trailing spam]]

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


Re: [R] Splitting a set of vectors in a list

2008-03-13 Thread Henrique Dallazuanna
If I understand correctly, try this:

as.data.frame(lapply(mylist, `[`, 1:max(unlist(lapply(mylist, length)

On 13/03/2008, John Kane [EMAIL PROTECTED] wrote:
 I have a set of character vectors of uneven length
  that I have stored in a list.  I can easily enough get
  any column of them  using lapply but what I want is to
  be able to create a matrix of them.  Other than some
  kind of brute force looping approach I have drawn a
  blank.

  Would somebody please suggest something? Thanks

  Example.

  mylist - list(aa=c(cat,peach ), bb=c(dog,
  apple, iron),
  cc = c(rabbit, orange, zinc, silk))
  myfun - function(dff) dff[1]
  vect1  - unlist(lapply(mylist, myfun))


   Looking for the perfect gift? Give the gift of Flickr!

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



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

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


Re: [R] default values

2008-03-13 Thread Dwayne Blind
Thanks a lot.

You were right :-)

Professor Ripley can I use your SPLUS book for R too ?

2008/3/12, Prof Brian Ripley [EMAIL PROTECTED]:

 On Wed, 12 Mar 2008, Dwayne Blind wrote:


  Dear R users,
 
  I wrote the following toy example to explain my problem :
 
  a=0
  f=function(x,y,z) {
 if (a==0) x[1]+x[2]+y
 if (a!=0) x[1]+x[2]+y+z
  }
  f(1:2,3)
 
 
  I have not specified z and I get an error.


 What was the error?  It works for me (so I've no idea), and returns NULL,
 the value of the last expression (invisibly).  I think you intended

 f - function(x, y, z) if (a==0) x[1]+x[2]+y else x[1]+x[2]+y+z

 or

 f - function(x, y, z) ifelse(a==0, x[1]+x[2]+y, x[1]+x[2]+y+z)



  Although a=0, R seems to want to
  know z because it's in the expression x[1]+x[2]+y+z.
 
  So I tried to put a default value :
 
  a=0
  f=function(x,y,z=0) {
 if (a==0) x[1]+x[2]+y
 if (a!=0) x[1]+x[2]+y+z
  }
  f(1:2,3)
 
  Why isn't it working ? Sometimes everything is fine even though a
 parameter
  is not specified.
 
  Thanks a lot.
 

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


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


[[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] Plot contour over filled contour

2008-03-13 Thread Dieter Menne
Devred, Emmanuel DevredE at mar.dfo-mpo.gc.ca writes:

 I haven't found a way in the searchable archive to overplot a contour
 (lines) over a surface.
 I have a (n,m)  matrix that represents sea surface temperature that I
 have plotted using image.plot(), filled.contour() or image(). I would
 like to overplot this image with some contour lines of mixed layer depth
 values(same size matrix). How can I do this?
 

When I search for contour (nothing else), the first item by Uwe Ligges is
probably what you want:

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

Dieter

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


Re: [R] smoothest way to upgrade R, say from 2.6.1 to 2.6.2?

2008-03-13 Thread Galkowski, Jan
Thanks to Stefan Grosse, Gabor Grothendieck, and Professor Ripley for
all this guidance.  I have collected the details, concatenating them
below, for future reference. Sorry if attributions got muddled. 

It is WinXP Pro in the primary, and there's no need to keep around older
versions.  But there are (Debian) Linux users here interested in both
the same question, and any caches of R-related shell goodies that might
be out there, comparable to batchfiles, both for upgrades and other
things, like maybe spawning multiple R processes and the like, or
running headless Rs on several servers at once. 

I apologize for leaving that out, but I thought putting out a wild guess
on this might draw comment and help.  It did.

Thanks much, again.  

-Original Message-
From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 13, 2008 2:12 PM
To: Stefan Grosse
Cc: r-help@r-project.org; Galkowski, Jan
Subject: Re: [R] smoothest way to upgrade R, say from 2.6.1 to 2.6.2?

If this _is_ Windows, the question is discussed in detail in the rw-FAQ.
That document also discusses how to install packages into a site or
personal library which can make upgrading easier.

Another consideration not told to us was whether one wants to keep
around a working copy of the older version.  My dept does so (so
students can use a consistent version when preparing their theses, for
example), and that affects the choice of strategy.

On Thu, 13 Mar 2008, Stefan Grosse wrote:

 On Thursday 13 March 2008 06:05:15 pm Galkowski, Jan wrote:
 GJ (1) How do people manage an upgrade, from 2.6.1, say, to 2.6.2?  
 GJ 2.6.2 will create its own subdirectory, obliging a copy of library

 GJ contents to the new spot.  The documents are easier.

 You forgot to enlighten us about your system. From what you are 
 telling I would guess its Windows (XP?). On my windows machine I 
 install R in the very same directory of the old R. So you could create

 programs/R and there install your R but of course you must then 
 alternate the suggested directory during the installation.

 GJ
 GJ (2) The problem with simply copying library contents is a fear of 
 GJ upward incompatibilities.  Am I worrying for naught here?  Are 
 GJ packages upward compatible but possibly not downwardly so?

 There is no problem within minor releases like 2.6.1 - 2.6.2 but on 
 greater jumps update.packages offers the option checkbuilt which if 
 set TRUE updates the packages to their next built. So if 2.7.0 is 
 released and you install that are over your old you should enable this
option.


 GJ (3) What about changing shortcuts, places for .Rprofile and the
like?
 GJ Do people have scripts that do all these things at once?

 See above

 GJ
 GJ It would be nice to have a single control file where R binaries 
 GJ and libraries and the like could be specified.  That way, all that

 GJ would need to be done is edit one file with an uptick on a point 
 GJ release number, say, and things would be fine.


[snip]

 GJ Where does this update.packages with the checkbuilt live?
 
 just type update.packages()
 in case of a major version change update.packages(checkbuilt=T)
 
 GJ Is all this described on the Wiki some place?  Or in the docs?
 
 In the docs
 run
 ?update.packages
 
 or have a look at the admin guide
 http://cran.r-project.org/doc/manuals/R-admin.html
 
 

[snip]

 I think Stefan has answered this so I will just
 add this about batchfiles.  In the batchfiles distrirbution:
 
 http://batchfiles.googlecode.com
 
 is a file Rgui.bat.  If you put that anywhere in your path and make
 your shortcut to that instead of to R itself then it will find the
most
 recent version of R from the registry and start that so you don't have
 to update shortcuts each time you change R versions.  There are
 also Rcmd.bat, sweave.bat and similar versions for the corresponding
 tasks.  Using those you never have to set your path to R when
 installing or upgrading R on Windows.
 
 The most recent version of batchfiles is for Vista and the next to
 most recent is for XP as per home page.
 
 If you do want to move or copy your packages from one library to
 another movedir.bat and copydir.bat will do that.  You can then use
 checkbuilt if its a major version change.  There are also some other
 methods described in the Links on the home page.
 
 

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


Re: [R] Splitting a set of vectors in a list (Solved )

2008-03-13 Thread John Kane
My thanks to Henrique Dallazuanna and Phil Spector. 
Both solutions worked well. 
Phil suggested that an alterative to my function would
be 
vect1 = sapply(mylist,'[[',1)
and I see that Henrique used `[` in his solution.

Can you point me to some documentation that discusses
these usages. I have seen them before but I have never
actually figured out how to use them.? 

Thanks.

Problem and solutions

mylist - list(aa=c(cat,peach ), bb=c(dog,
apple, iron), 
 cc = c(rabbit, orange, zinc, silk))
myfun - function(dff) dff[1]   
vect1  - unlist(lapply(mylist, myfun))

# Desired output
t(cbind( c(cat ,  peach , NA, NA), bbb  - c(dog
,  apple ,iron, NA),
ccb - c(rabbit ,orange ,zinc ,  silk ))) 

# Phil Spector's approach
mlen = max(sapply(mylist,length))
eqlens = lapply(mylist,function(x)if(length(x)  mlen)
   
c(x,rep('',mlen-length(x))) else x)
do.call(rbind,eqlens)

#   Henrique Dallazuanna [EMAIL PROTECTED]
#I added the t()
t(as.data.frame(lapply(mylist, `[`,
1:max(unlist(lapply(mylist,
 length))


[[elided trailing spam]]

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


Re: [R] Splitting a set of vectors in a list (Solved )

2008-03-13 Thread Henrique Dallazuanna
On 13/03/2008, John Kane [EMAIL PROTECTED] wrote:
 My thanks to Henrique Dallazuanna and Phil Spector.
  Both solutions worked well.
  Phil suggested that an alterative to my function would
  be
  vect1 = sapply(mylist,'[[',1)
  and I see that Henrique used `[` in his solution.

  Can you point me to some documentation that discusses
  these usages. I have seen them before but I have never
  actually figured out how to use them.?

See ?Extract


  Thanks.

  Problem and solutions
  
  mylist - list(aa=c(cat,peach ), bb=c(dog,
  apple, iron),
  cc = c(rabbit, orange, zinc, silk))
  myfun - function(dff) dff[1]
  vect1  - unlist(lapply(mylist, myfun))

  # Desired output
  t(cbind( c(cat ,  peach , NA, NA), bbb  - c(dog
  ,  apple ,iron, NA),
  ccb - c(rabbit ,orange ,zinc ,  silk )))

  # Phil Spector's approach
  mlen = max(sapply(mylist,length))
  eqlens = lapply(mylist,function(x)if(length(x)  mlen)

  c(x,rep('',mlen-length(x))) else x)
  do.call(rbind,eqlens)

  #   Henrique Dallazuanna [EMAIL PROTECTED]
  #I added the t()
  t(as.data.frame(lapply(mylist, `[`,
  1:max(unlist(lapply(mylist,
   length))


   Looking for the perfect gift? Give the gift of Flickr!

  http://www.flickr.com/gift/




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

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


Re: [R] Splitting a set of vectors in a list (Solved )

2008-03-13 Thread Benilton Carvalho

or the suggestive :)

?[

b

On Mar 13, 2008, at 2:58 PM, Henrique Dallazuanna wrote:


On 13/03/2008, John Kane [EMAIL PROTECTED] wrote:

Can you point me to some documentation that discusses
these usages. I have seen them before but I have never
actually figured out how to use them.?


See ?Extract


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


Re: [R] default values

2008-03-13 Thread Prof Brian Ripley
On Thu, 13 Mar 2008, Dwayne Blind wrote:

 Thanks a lot.

 You were right :-)

 Professor Ripley can I use your SPLUS book for R too ?

'Modern Applied Statistics with S' and 'S Programming' both cover S and 
its implementations in S-PLUS and R.

However, 'Modern Applied Statistics with S-PLUS' is now so last millenium 
that it is an unreliable guide to recent versions of either.


 2008/3/12, Prof Brian Ripley [EMAIL PROTECTED]:

 On Wed, 12 Mar 2008, Dwayne Blind wrote:


 Dear R users,

 I wrote the following toy example to explain my problem :

 a=0
 f=function(x,y,z) {
if (a==0) x[1]+x[2]+y
if (a!=0) x[1]+x[2]+y+z
 }
 f(1:2,3)


 I have not specified z and I get an error.


 What was the error?  It works for me (so I've no idea), and returns NULL,
 the value of the last expression (invisibly).  I think you intended

 f - function(x, y, z) if (a==0) x[1]+x[2]+y else x[1]+x[2]+y+z

 or

 f - function(x, y, z) ifelse(a==0, x[1]+x[2]+y, x[1]+x[2]+y+z)



 Although a=0, R seems to want to
 know z because it's in the expression x[1]+x[2]+y+z.

 So I tried to put a default value :

 a=0
 f=function(x,y,z=0) {
if (a==0) x[1]+x[2]+y
if (a!=0) x[1]+x[2]+y+z
 }
 f(1:2,3)

 Why isn't it working ? Sometimes everything is fine even though a
 parameter
 is not specified.

 Thanks a lot.


   [[alternative HTML version deleted]]

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



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



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

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


Re: [R] Splitting a set of vectors in a list (Solved )

2008-03-13 Thread John Kane
Ah ?Extract.  Thanks 

Unless I'm missing something there is nothing  in the
Usage or Examples to suggest to a naive reader like me
that one can use an unbalanced [ or [[, that is
withoug a corresponding ] or ]]. 

I probably am just not understanding the details.

--- Henrique Dallazuanna [EMAIL PROTECTED] wrote:

 On 13/03/2008, John Kane [EMAIL PROTECTED] wrote:
  My thanks to Henrique Dallazuanna and Phil
 Spector.
   Both solutions worked well.
   Phil suggested that an alterative to my function
 would
   be
   vect1 = sapply(mylist,'[[',1)
   and I see that Henrique used `[` in his solution.
 
   Can you point me to some documentation that
 discusses
   these usages. I have seen them before but I have
 never
   actually figured out how to use them.?
 
 See ?Extract
 
 
   Thanks.
 
   Problem and solutions
  


   mylist - list(aa=c(cat,peach ), bb=c(dog,
   apple, iron),
   cc = c(rabbit, orange, zinc,
 silk))
   myfun - function(dff) dff[1]
   vect1  - unlist(lapply(mylist, myfun))
 
   # Desired output
   t(cbind( c(cat ,  peach , NA, NA), bbb  -
 c(dog
   ,  apple ,iron, NA),
   ccb - c(rabbit ,orange ,zinc ,  silk )))
 
   # Phil Spector's approach
   mlen = max(sapply(mylist,length))
   eqlens = lapply(mylist,function(x)if(length(x) 
 mlen)
 
   c(x,rep('',mlen-length(x))) else x)
   do.call(rbind,eqlens)
 
   #   Henrique Dallazuanna [EMAIL PROTECTED]
   #I added the t()
   t(as.data.frame(lapply(mylist, `[`,
   1:max(unlist(lapply(mylist,
length))
 
 
Looking for the perfect gift? Give the gift
 of Flickr!
 
   http://www.flickr.com/gift/
 
 
 
 
 -- 
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O


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


Re: [R] How to cbind or rbind different lengths vectors/arrays without repeating the elements of the shorter vectors/arrays ?

2008-03-13 Thread John Kane
I don't think you can. What is your desired output?  

You can always do c(1:2, 1:10)

--- Ng Stanley [EMAIL PROTECTED] wrote:

 Hi,
 
 How to cbind or rbind different lengths
 vectors/arrays without repeating the
 elements of the shorter vectors/arrays ?
 
  cbind(1:2, 1:10)
   [,1] [,2]
  [1,]11
  [2,]22
  [3,]13
  [4,]24
  [5,]15
  [6,]26
  [7,]17
  [8,]28
  [9,]19
 [10,]2   10
 
   [[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.
 



  Looking for the perfect gift? Give the gift of Flickr!

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


Re: [R] Splitting a set of vectors in a list (Solved )

2008-03-13 Thread Henrique Dallazuanna
A example:

x - rnorm(5)

x[3]
`[`(x, 3)
`[[`(x, 3)

x[3:4]
`[`(x, 3:4)
`[[`(x, 3:4) # Error


On 13/03/2008, John Kane [EMAIL PROTECTED] wrote:
 Ah ?Extract.  Thanks

  Unless I'm missing something there is nothing  in the
  Usage or Examples to suggest to a naive reader like me
  that one can use an unbalanced [ or [[, that is
  withoug a corresponding ] or ]].

  I probably am just not understanding the details.


  --- Henrique Dallazuanna [EMAIL PROTECTED] wrote:

   On 13/03/2008, John Kane [EMAIL PROTECTED] wrote:
My thanks to Henrique Dallazuanna and Phil
   Spector.
 Both solutions worked well.
 Phil suggested that an alterative to my function
   would
 be
 vect1 = sapply(mylist,'[[',1)
 and I see that Henrique used `[` in his solution.
   
 Can you point me to some documentation that
   discusses
 these usages. I have seen them before but I have
   never
 actually figured out how to use them.?
  
   See ?Extract
  
   
 Thanks.
   
 Problem and solutions
   
  
  
 mylist - list(aa=c(cat,peach ), bb=c(dog,
 apple, iron),
 cc = c(rabbit, orange, zinc,
   silk))
 myfun - function(dff) dff[1]
 vect1  - unlist(lapply(mylist, myfun))
   
 # Desired output
 t(cbind( c(cat ,  peach , NA, NA), bbb  -
   c(dog
 ,  apple ,iron, NA),
 ccb - c(rabbit ,orange ,zinc ,  silk )))
   
 # Phil Spector's approach
 mlen = max(sapply(mylist,length))
 eqlens = lapply(mylist,function(x)if(length(x) 
   mlen)
   
 c(x,rep('',mlen-length(x))) else x)
 do.call(rbind,eqlens)
   
 #   Henrique Dallazuanna [EMAIL PROTECTED]
 #I added the t()
 t(as.data.frame(lapply(mylist, `[`,
 1:max(unlist(lapply(mylist,
  length))
   
   
  Looking for the perfect gift? Give the gift
   of Flickr!
   
 http://www.flickr.com/gift/
   
   
  
  
   --
   Henrique Dallazuanna
   Curitiba-Paraná-Brasil
   25° 25' 40 S 49° 16' 22 O
  




   
  Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your 
 favourite sites. Download it now at
  http://ca.toolbar.yahoo.com.



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

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


Re: [R] Splitting a set of vectors in a list (Solved )

2008-03-13 Thread John Kane
Blood ell !  Thanks very much, it does help give a
feel for what's happening.  I'll have to do some
experimenting.

--- Henrique Dallazuanna [EMAIL PROTECTED] wrote:

 A example:
 
 x - rnorm(5)
 
 x[3]
 `[`(x, 3)
 `[[`(x, 3)
 
 x[3:4]
 `[`(x, 3:4)
 `[[`(x, 3:4) # Error
 
 
 On 13/03/2008, John Kane [EMAIL PROTECTED] wrote:
  Ah ?Extract.  Thanks
 
   Unless I'm missing something there is nothing  in
 the
   Usage or Examples to suggest to a naive reader
 like me
   that one can use an unbalanced [ or [[, that is
   withoug a corresponding ] or ]].
 
   I probably am just not understanding the details.
 
 
   --- Henrique Dallazuanna [EMAIL PROTECTED]
 wrote:
 
On 13/03/2008, John Kane [EMAIL PROTECTED]
 wrote:
 My thanks to Henrique Dallazuanna and Phil
Spector.
  Both solutions worked well.
  Phil suggested that an alterative to my
 function
would
  be
  vect1 = sapply(mylist,'[[',1)
  and I see that Henrique used `[` in his
 solution.

  Can you point me to some documentation that
discusses
  these usages. I have seen them before but I
 have
never
  actually figured out how to use them.?
   
See ?Extract
   

  Thanks.

  Problem and solutions

   
  


  mylist - list(aa=c(cat,peach ),
 bb=c(dog,
  apple, iron),
  cc = c(rabbit, orange, zinc,
silk))
  myfun - function(dff) dff[1]
  vect1  - unlist(lapply(mylist, myfun))

  # Desired output
  t(cbind( c(cat ,  peach , NA, NA), bbb 
 -
c(dog
  ,  apple ,iron, NA),
  ccb - c(rabbit ,orange ,zinc , 
 silk )))

  # Phil Spector's approach
  mlen = max(sapply(mylist,length))
  eqlens =
 lapply(mylist,function(x)if(length(x) 
mlen)

  c(x,rep('',mlen-length(x))) else x)
  do.call(rbind,eqlens)

  #   Henrique Dallazuanna
 [EMAIL PROTECTED]
  #I added the t()
  t(as.data.frame(lapply(mylist, `[`,
  1:max(unlist(lapply(mylist,
   length))


   Looking for the perfect gift? Give the
 gift
of Flickr!

  http://www.flickr.com/gift/


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

 the web, and bookmark your favourite sites. Download
 it now at
   http://ca.toolbar.yahoo.com.
 
 
 
 -- 
 Henrique Dallazuanna
 Curitiba-Paran�-Brasil
 25� 25' 40 S 49� 16' 22 O
 



[[elided trailing spam]]

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


[R] FW: Os resultados do seus comandos de email

2008-03-13 Thread lamack lamack



Dear all, what is the best way to do this?

end = c(2,6,4)

I neeed: expand.grid(0:end[1],0:end[2],0:end[3])

Best regards


JL
_
Confira vídeos com notícias do NY Times, gols direto do Lance, videocas[[elided 
Hotmail spam]]

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


Re: [R] FW: Os resultados do seus comandos de email

2008-03-13 Thread Henrique Dallazuanna
Try:

do.call(expand.grid, sapply(end, seq, from = 0))

On 13/03/2008, lamack lamack [EMAIL PROTECTED] wrote:



  Dear all, what is the best way to do this?

  end = c(2,6,4)

  I neeed: expand.grid(0:end[1],0:end[2],0:end[3])

  Best regards


  JL
  _
  Confira vídeos com notícias do NY Times, gols direto do Lance, 
 videocas[[elided Hotmail spam]]

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



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

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


Re: [R] How to manipulate data according to groups ?

2008-03-13 Thread John Kane
?aggregate

 tt - matrix(c(rnorm(10), 1,1,2,2,1,3,3,3,3,2),
ncol=2))
 aggregate(t[,1], by=list(t[,2]), mean)
should work


--- Ng Stanley [EMAIL PROTECTED] wrote:

 Hi,
 
 I have a two columns data, the first column are
 values, and second column
 are the groups. For this example, there are 3 groups
 1,2,3.
 
 How can I manipulate the values in the first column
 according to groups, say
 I would like to find mean, sum, and standard
 deviation for the different
 groups ? How do I plot data according to groups ?
 
  t - matrix(c(rnorm(10), 1,1,2,2,1,3,3,3,3,2),
 ncol=2)
 
   [[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] LIMMA: array spot summary options beyond duplicateCorrelation()

2008-03-13 Thread Quin Wills
Hello Limma users

A quick question, I hope:

I have dual-channel spotted expression arrays in a simple loop design 
(no dye swaps), viz:

1 vs reference
2 vs 1
3 vs 2
reference vs 3

There are 4 replicate spots for each probe on each array.

It seems as if getting meaningful spot summary results using 
duplicateCorrelation() is not possible in my case as the spots are not 
regularly spaced, and I don't *really* have enough arrays, no?

So then what are my other options in Limma to summarise replicated spots?

Thanks,
Quin

* *

* *

*Quin Wills*
*DPhil candidate*

* *

*Department of Statistics*

*University** of Oxford***

*1 South Parks Road*
*Oxford***

*OX1 3TG
United Kingdom*

 

*01865 285 394*


[[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] Warned about these three little maids...

2008-03-13 Thread Brian Lunergan
Greetings all:

Newcomer to R as I work on learning it to transfer my college classroom 
stats training to something more useful and accurate then that spreadsheet 
from Redmond which shall remain nameless.

I'm running v2.6.2 on a Win XP Home system that I keep up to date with all 
the called for patches. Haven't added much to the basic install other than 
the bits and bobs needed to run the R Commander package and its plugins. I 
did, however, use the ctv library to add the Graphics view.

When I reached the end of the install (a somewhat drawn out exercise as I 
haven't jumped into a high speed hookup yet) R warned me that gtkDevice, 
RGrace, and xgobi were not available. I use the Ontario, Canada mirror and 
they are indeed not listed among the install choices. A quick search on the 
names and I get the impression these three are not available for the 
Windows platform. Correct perception or no? Do I need them for a windows 
setup? Where would I find them if they are needed?

Any help or advice much appreciated...

-- 

Brian Lunergan
Nepean, Ontario
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] plotting zoo object

2008-03-13 Thread stephen sefick
JAN FEB MAR APR MAY JUN JUL AUG 
SEP OCT NOV DEC
1968NA  10.710.09.3 7.4 8.1 9.3 9.5 8.5 
10.010.013.0
196913.09.9 7.0 5.9 NA  6.5 7.3 6.6 NA  
NA  NA  NA
197010.78.9 8.1 NA  NA  7.1 7.7 NA  6.5 
NA  8.3 NA
1971NA  11.6NA  NA  7.8 NA  NA  6.2 NA  
NA  8.4 NA

x-read.zoo(textconnection, sep=,, format= %Y, header=TRUE)
plot(x)

#this plots all of the years by each month.  I would like to plot one
long time series from 1968 to 1971
#is there an easy way to do this?  I can reformat the data in excel so
that the index will be year then month, but this will take a while.
the end goal is #to be able to apply some signal processing things
like spectral density after fitting the seasonal trend etc.
thanks

Stephen


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

-K. Mullis

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


Re: [R] Warned about these three little maids...

2008-03-13 Thread Prof Brian Ripley
You should consult the summary

http://cran.r-project.org/bin/windows/contrib/checkSummaryWin.html

to answer such questions.  These are not part of the install of R -- you 
must have chosen to install some packages which depend on them.  As to 
whether you need them -- that depends if you need the packages that depend 
on them.

You are wrong about xgobi: it is on the CRAN extras site and a default 
repositories setup will find it.  However, it is an interface to XGobi, 
and that is pretty much obsolete in favour of GGobi (and rggobi is its R 
interface).

Package gtkDevice has been withdrawn.

It should be possible to build package RGrace for Windows -- it only 
depends on packages RGtk2 and cairoDevice these days, and I've just done 
so.  (Earlier versions were a different story.)  However, it fails its 
checks as it incorrectly uses UTF8 (instead of UTF-8) for an encoding 
name. (So Cc:ing the maintainer.)

On Thu, 13 Mar 2008, Brian Lunergan wrote:

 Greetings all:

 Newcomer to R as I work on learning it to transfer my college classroom
 stats training to something more useful and accurate then that spreadsheet
 from Redmond which shall remain nameless.

 I'm running v2.6.2 on a Win XP Home system that I keep up to date with all
 the called for patches. Haven't added much to the basic install other than
 the bits and bobs needed to run the R Commander package and its plugins. I
 did, however, use the ctv library to add the Graphics view.

 When I reached the end of the install (a somewhat drawn out exercise as I
 haven't jumped into a high speed hookup yet) R warned me that gtkDevice,
 RGrace, and xgobi were not available. I use the Ontario, Canada mirror and
 they are indeed not listed among the install choices. A quick search on the
 names and I get the impression these three are not available for the
 Windows platform. Correct perception or no? Do I need them for a windows
 setup? Where would I find them if they are needed?

 Any help or advice much appreciated...

 --

 Brian Lunergan
 Nepean, Ontario
 Canada


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

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


[R] manova with non-normal error distribution

2008-03-13 Thread Jarrett Byrnes
This may be a silly question to ask, but, is it possible do do a  
MANOVA-style analysis with a generalized linear model?  I have a data  
set that I'm working with that, for each variable (time in this case,  
as it's a repeated measures MANOVA) is fit much better using glm  
rather than a traditional linear model - even after transforming the  
data so that the resulting (I'm log transforming the data for lm,  
whereas under glm the data is most appropriate for a model with a  
poisson error and an exponential link).

However, under glm, if I try and fit my matrix of response variable, I  
get the error
Error: (subscript) logical subscript too long

Is there a library or method of analysis that handles this type of  
problem?

Much obliged!

-Jarrett





Jarrett Byrnes
Population Biology Graduate Group, UC Davis
Bodega Marine Lab
707-875-1969
http://www-eve.ucdavis.edu/stachowicz/byrnes.shtml


[[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] zoo object: replace NAs from another zoo object

2008-03-13 Thread Timothy W. Hilton
Hello,

I have two zoo objects, new and old, indexed by chron objects.  Their structure 
is like this:

(05/25/06 00:00:00) NA NA  NA
(05/25/06 00:02:00) 948.20 24.198   0
(05/25/06 00:04:00) 948.26 20.640   0
(05/25/06 00:06:00) 948.37 19.653   0
(05/25/06 00:08:00) 948.48 19.135   0
(05/25/06 00:10:00) 948.54 22.510   0
(05/25/06 00:12:00) 948.55 27.175   0
(05/25/06 00:14:00) 948.46 30.075   0
(05/25/06 00:16:00) 948.59 28.815   0
(05/25/06 00:18:00) 948.96 27.938   0

old spans a larger range of dates than new.  I would like to take all the 
values in new that are not NA and place them in old, matching the time indices. 
 I have tried a number of variations on the themes of merge and replace, but 
can't get them to work, and the brute force for loop solution is unnacceptably 
slow.  Could someone suggest a solution?

Many thanks,
Tim

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