[R] Scope

2007-02-08 Thread Geoffrey Zhu
Hi all, When I write a script, I'd like to create a main() function so that I only need to type main() t re-run it. However, I'd like all the variables in main() to be global so that when the function terminates, I still have access to the variables in the environment. Does anyone know how to do

[R] Inverse fuction of ecdf

2007-01-28 Thread Geoffrey Zhu
Hi Everyone, I want to generate some random numbers according to some empirical distribution. Therefore I am looking for the inverse of an empirical cumulative distribution function. I haven't found any in R. Can anyone give a pointer? Thanks, Geoffrey

Re: [R] Inverse fuction of ecdf

2007-01-28 Thread Geoffrey Zhu
:[EMAIL PROTECTED] Sent: Sunday, January 28, 2007 4:45 PM To: Geoffrey Zhu Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Inverse fuction of ecdf ?quantile b On Jan 28, 2007, at 5:41 PM, Geoffrey Zhu wrote: Hi Everyone, I want to generate some random numbers according to some empirical

[R] R modules

2007-01-02 Thread Geoffrey Zhu
Hi All, I'd like to know what is the best way to organize R code in multiple modules= and files. The R code we are writing is too much for a single file. Besides= , there are a lot of reusable functions we'd like to factor out. But writing= a package for that is quite an over-kill and might be

[R] Difference of array and vector

2006-12-29 Thread Geoffrey Zhu
Hi, I am really new at R. Does anyone know what is the real difference of vector and array, except that many operations that expect an array does not work on a vector? Thanks, Geoffrey ___=0A= =0A= =0A= The information in this email or in any

[R] HOW TO: vectorize an iterative process.

2006-12-26 Thread Geoffrey Zhu
SGkgRXZlcnlvbmUsDQogDQpJIGFtIHN0dWNrIHdpdGggYSBzaW1wbGUgcHJvYmxlbS4gU3Vw cG9zZSBJIGhhdmUgYSB2ZWN0b3IgeCwgYW5kIEkgd2FudCB0byBjYWxjdWxhdGUgeVtpXT14 W2krMV0teFtpXSwgaXQgaXMgdmVyeSBlYXN5LiBJIGp1c3QgbmVlZCB0byB3cml0ZSB5PC14 WzI6bGVuZ3RoKHgpXS14WzE6bGVuZ3RoKHgpLTFdLiANCiANCk5vdyBpZiBJIGtub3cgeSwg

[R] vectorizing an iterative process.

2006-12-26 Thread Geoffrey Zhu
Hi Everyone, I am stuck with a simple problem. Suppose I have a vector x, and I want to calculate y[i]=3Dx[i+1]-x[i], it is very easy. I just need to write y-x[2:length(x)]-x[1:length(x)-1]. Now if I know y, and want to know the vector x defined by x[i]=3Dx[i-1]+y[i-1] for all i, how can I do

Re: [R] vectorizing an iterative process.

2006-12-26 Thread Geoffrey Zhu
PROTECTED] Sent: Tuesday, December 26, 2006 9:56 AM To: Geoffrey Zhu; r-help@stat.math.ethz.ch Subject: Re: [R] vectorizing an iterative process. x[i]=3D3Dx[i-1]+y[i-1] for all i, how can I do this without a loop? It looks like x - cumsum(y) What does 3D mean

Re: [R] vectorizing an iterative process.

2006-12-26 Thread Geoffrey Zhu
I meant x[i] - x[i-1] + y[i-1] and Y[i] - y[i-1] + x[i] below. The mailing list software just keep adding 3D's. Sorry. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Geoffrey Zhu Sent: Tuesday, December 26, 2006 10:03 AM To: Richard M. Heiberger; r

Re: [R] vectorizing an iterative process.

2006-12-26 Thread Geoffrey Zhu
Yes, this solves my problem. Thanks for your help. -Original Message- From: Christos Hatzis [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 26, 2006 10:58 AM To: Geoffrey Zhu; r-help@stat.math.ethz.ch Subject: RE: [R] vectorizing an iterative process. In your case, the recurrence