Re: [R] simple coding question

2007-07-31 Thread Darin A. England
:31 a.m. To: r-help@stat.math.ethz.ch Subject: [R] simple coding question I have a list of ICD9 (disease) codes with various formats - 3 digit, 4 digit, 5 digit. The first three digits of these codes are what I am most interested in. I would like to either add zeros to the 3 and 4

[R] simple coding question

2007-07-30 Thread Kirsten Beyer
I have a list of ICD9 (disease) codes with various formats - 3 digit, 4 digit, 5 digit. The first three digits of these codes are what I am most interested in. I would like to either add zeros to the 3 and 4 digit codes to make them 5 digit codes or add decimal points to put them all in the

Re: [R] simple coding question

2007-07-30 Thread Peter Alspach
: Tuesday, 31 July 2007 9:31 a.m. To: r-help@stat.math.ethz.ch Subject: [R] simple coding question I have a list of ICD9 (disease) codes with various formats - 3 digit, 4 digit, 5 digit. The first three digits of these codes are what I am most interested in. I would like to either add zeros

Re: [R] A coding question involving variable assignments in ifelse()

2007-04-28 Thread AJ Rossini
I agree entirely with Gabor. My advice would be to just ignore the people who think differently -- however, if you want those particular folks to respond, you'll have to play by their rules. (and if you don't play by their rules, you'll just have to ignore the consequences -- this _IS_ the

Re: [R] A coding question involving variable assignments in ifelse()

2007-04-28 Thread Duncan Murdoch
On 4/28/2007 6:20 AM, AJ Rossini wrote: I agree entirely with Gabor. My advice would be to just ignore the people who think differently That's fairly bad advice, in that many of the people who actually provide helpful advice are old-fashioned, and like to know who they're providing it

Re: [R] A coding question involving variable assignments in ifelse()

2007-04-27 Thread xpRt.wannabe
Is this an ad hominem comment or a comment of brevity? Unless my eyes are playing tricks on me, I can't seem to find any language in the Posting Guide on what is considered a reasonable vs. unreasonable request from an anonymous poster. Kindly point me to it if it exists. In any case, thanks

Re: [R] A coding question involving variable assignments in ifelse()

2007-04-27 Thread Gabor Grothendieck
I don't think there is any requirement to identify yourself in any way nor should their be. Many people on the list are in academia and in those cases they probably want their name in lights but others may wish to have a lower profile and its common to use an alias on the net for privacy. On

Re: [R] A coding question involving variable assignments in ifelse()

2007-04-27 Thread Duncan Murdoch
On 4/27/2007 11:41 AM, Gabor Grothendieck wrote: I don't think there is any requirement to identify yourself in any way nor should their be. Many people on the list are in academia and in those cases they probably want their name in lights but others may wish to have a lower profile and its

Re: [R] A coding question involving variable assignments in ifelse()

2007-04-27 Thread rolf
I think Duncan's suggestion that the poster work it out for him/her self is perfectly reasonable. People can be anonymous all they like. Those of us who are made suspicious by this anonymity (what have they got to hide?) can decline to provide assistance. cheers,

[R] A coding question involving variable assignments in ifelse()

2007-04-26 Thread xpRt.wannabe
Dear List, Below is a simple, standard loss model that takes into account the terms of an insurance policy: deductible - 15 coverage.limit - 75 insurance.threshold - deductible + coverage.limit tmpf - function() { loss - rlnorm(rpois(1, 3), 2, 5) sum(ifelse(loss insurance.threshold, loss -

Re: [R] A coding question involving variable assignments in ifelse()

2007-04-26 Thread Duncan Murdoch
On 4/26/2007 12:48 PM, xpRt.wannabe wrote: Dear List, Below is a simple, standard loss model that takes into account the terms of an insurance policy: deductible - 15 coverage.limit - 75 insurance.threshold - deductible + coverage.limit tmpf - function() { loss - rlnorm(rpois(1, 3),

Re: [R] A coding question involving variable assignments in ifelse()

2007-04-26 Thread xpRt.wannabe
Just to be sure, is what I have below the right intepretation of your suggestion: deductible - 15 coverage.limit - 75 insurance.threshold - deductible + coverage.limit tmpf - function() { loss - rlnorm(rpois(1, 3), 2, 5) n - length(loss) accept - runif(n) 0.8 payout - runif(n) 0.999

Re: [R] A coding question involving variable assignments in ifelse()

2007-04-26 Thread Duncan Murdoch
On 4/26/2007 2:31 PM, xpRt.wannabe wrote: Just to be sure, is what I have below the right intepretation of your suggestion: Yes, that's what I suggested. Duncan Murdoch deductible - 15 coverage.limit - 75 insurance.threshold - deductible + coverage.limit tmpf - function() { loss -

Re: [R] A coding question involving variable assignments in ifelse()

2007-04-26 Thread xpRt.wannabe
I made a few slight modifications to the original model in an effort to see the inner workings of the code: deductible - 1 coverage.limit - 2 insurance.threshold - deductible + coverage.limit snip set.seed(123) loss - abs(rnorm(rpois(1, 5), 1, 3)) n - length(loss) accept - runif(n) 0.8 payout

Re: [R] A coding question involving variable assignments in ifelse()

2007-04-26 Thread Duncan Murdoch
On 4/26/2007 5:21 PM, xpRt.wannabe wrote: I made a few slight modifications to the original model in an effort to see the inner workings of the code: deductible - 1 coverage.limit - 2 insurance.threshold - deductible + coverage.limit snip set.seed(123) loss - abs(rnorm(rpois(1, 5),

Re: [R] A coding question

2006-06-03 Thread Uwe Ligges
xpRt.wannabe wrote: Uwe and Ben, Thank you both for your help. To me, both sets of code seem to do the job and should produce the same results. However, as a test I inserted set.seed( ) as follows. Unless I put set.seed( ) in the wrong lines, the results produced by both sets of code

Re: [R] A coding question

2006-06-02 Thread Uwe Ligges
xpRt.wannabe wrote: Dear List: I have the follow code: y - replicate(10,replicate(8,sum(rnorm(rpois(1,5) Now I need to apply the following condition to _every_ randomly generated Normal number in the code above: x - max(0,x-15) + max(0,x-90), where x represents the individual

Re: [R] A coding question

2006-06-02 Thread Ben Bolker
Uwe Ligges ligges at statistik.uni-dortmund.de writes: xpRt.wannabe wrote: y - replicate(10,replicate(8,sum(rnorm(rpois(1,5) x - max(0,x-15) + max(0,x-90), where x represents the individual Normal numbers. y - replicate(10, { rp - rpois(8, 5) mysum -

Re: [R] A coding question

2006-06-02 Thread xpRt.wannabe
Uwe and Ben, Thank you both for your help. To me, both sets of code seem to do the job and should produce the same results. However, as a test I inserted set.seed( ) as follows. Unless I put set.seed( ) in the wrong lines, the results produced by both sets of code turn out to be different. I

[R] A coding question

2006-06-01 Thread xpRt.wannabe
Dear List: I have the follow code: y - replicate(10,replicate(8,sum(rnorm(rpois(1,5) Now I need to apply the following condition to _every_ randomly generated Normal number in the code above: x - max(0,x-15) + max(0,x-90), where x represents the individual Normal numbers. In other words,

[R] A coding question involving variable assignments

2005-08-11 Thread xpRt.wannabe
Dear List, I have the following code that does what I want: x - replicate(5,replicate(10,sum(rnorm(rpois(1,10) How might one change it such that the maximum value generated by rnorm(rpois(1,10)) can be retrieved for later use? __

Re: [R] A coding question involving variable assignments

2005-08-11 Thread ecatchpole
On 12/08/05 05:55, xpRt.wannabe wrote,: Dear List, I have the following code that does what I want: x - replicate(5,replicate(10,sum(rnorm(rpois(1,10) How might one change it such that the maximum value generated by rnorm(rpois(1,10)) can be retrieved for later use? set.seed(99) x

Re: [R] A coding question involving variable assignments

2005-08-11 Thread xpRt.wannabe
Jim and List, Thank you for the prompt reply. Perhaps I should have been more specific in the way I phrased the question. The code you gave would return the max value just one time. I was interested in getting as many max values generated by rnorm(rpois(1,10)) as specified by:

Re: [R] A coding question involving variable assignments

2005-08-11 Thread xpRt.wannabe
Ted and List, In your code that produced 'mx', you dropped sum() from my original code though. As a result, the 10 x 5 max's are of the same value. Unfortunately, that's not what I need. On 8/11/05, ecatchpole [EMAIL PROTECTED] wrote: On 12/08/05 05:55, xpRt.wannabe wrote,: Dear List,

Re: [R] A coding question involving variable assignments

2005-08-11 Thread ecatchpole
Sorry, I don't follow. What's wrong with this? Ted. set.seed(99) x - replicate(5,replicate(10,sum(rnorm(rpois(1,10) set.seed(99) mx - replicate(5,replicate(10,max(rnorm(rpois(1,10) x [,1][,2][,3] [,4] [,5] [1,] -2.0071674 -7.0883335

Re: [R] A coding question involving variable assignments

2005-08-11 Thread xpRt.wannabe
Ted and List, What I need is I need to know what max of rnorm(rpois(1,10)) is before R does sum(), replicate(10, ...) and replicate(5, ...). The fact that you have set.seed(99) twice, does that mean, say, entry [1,1] 0.4896243 in 'mx' is one of the z number of values generated by

Re: [R] A coding question involving variable assignments

2005-08-11 Thread ecatchpole
On 12/08/05 13:27, xpRt.wannabe wrote,: Ted and List, What I need is I need to know what max of rnorm(rpois(1,10)) is before R does sum(), replicate(10, ...) and replicate(5, ...). The fact that you have set.seed(99) twice, does that mean, say, entry [1,1] 0.4896243 in 'mx' is one of the

Re: [R] A coding question involving variable assignments

2005-08-11 Thread xpRt.wannabe
Thank you! That was helpful. Another thing I learned was that I would need to do set.seed(99) not once but twice in this context. On 8/11/05, ecatchpole [EMAIL PROTECTED] wrote: On 12/08/05 13:27, xpRt.wannabe wrote,: Ted and List, What I need is I need to know what max of