Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread Jennifer Sabatier
Hah - I guess I didn't mean I understood it in full as I expect I will run into it again without anticipating it. But, now that I know the "old adage" I will look there first when I run into a problem. Also, I used the square root of machine precision instead - thanks for that, too. Thank you, t

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread R. Michael Weylandt
On Fri, Aug 24, 2012 at 7:29 PM, Jennifer Sabatier wrote: > AHHH I GOT IT!! > > And I *think* I understand about floating point arithmetic.. Well then you're doing much better than the rest of us: it's quite a difficult subject and only gets trickier as you think about it more. (N

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread Jennifer Sabatier
AHHH I GOT IT!! And I *think* I understand about floating point arithmetic.. In this case vn$PM.DIST.TOT is the sum of proportions. So, it should be anywhere 0 and 1. In our case, if it's anything other than 1 when vn$PM.EXP is greater than 0 then it means something is wrong wi

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread Peter Ehlers
I see that you got other responses while I was composing an answer. Your 'example.csv' did come through for me, but I still can't replicate your PM.DIST_flag variable. Specifically, observations 30, 33, 36 and 40 are wrong. I agree with Rui, that there's something else going on. The data you've s

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread Jennifer Sabatier
Hi Michael, Thanks for letting me know how to post data. I will try to upload it that way in a second. I can usually use code to make a reproducible dataset but this time with the ifelse behaving strangely (perhaps, it's probably me) I didn't think I could do it easily so I figured I would just

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread Jennifer Sabatier
Oh, sorry, I first though you couldn't post data to the list, but then I thought I remembered other people doing so, so I tried to post it. Here is a copy. Thanks, Jen On Fri, Aug 24, 2012 at 5:49 PM, Rui Barradas wrote: > No data arrived to me. > > Rui Barradas > Em 24-08-2012 22:46, Jennifer

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread R. Michael Weylandt
On Fri, Aug 24, 2012 at 4:50 PM, R. Michael Weylandt wrote: > On Fri, Aug 24, 2012 at 4:46 PM, Jennifer Sabatier > wrote: >> Hi Michael, >> >> No, I never use attach(), exactly for the reasons you state. To do >> due diligence I did a search of code for the function and it didn't >> come up (I w

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread R. Michael Weylandt
On Fri, Aug 24, 2012 at 4:46 PM, Jennifer Sabatier wrote: > Hi Michael, > > No, I never use attach(), exactly for the reasons you state. To do > due diligence I did a search of code for the function and it didn't > come up (I would have been shocked because I never us it!). > > Now that real data

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread Rui Barradas
No data arrived to me. Rui Barradas Em 24-08-2012 22:46, Jennifer Sabatier escreveu: Hi Michael, No, I never use attach(), exactly for the reasons you state. To do due diligence I did a search of code for the function and it didn't come up (I would have been shocked because I never us it!). N

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread Jennifer Sabatier
Hi Michael, No, I never use attach(), exactly for the reasons you state. To do due diligence I did a search of code for the function and it didn't come up (I would have been shocked because I never us it!). Now that real data is up, does your suggestion still apply? I am reading it now. Thanks

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread R. Michael Weylandt
Off the wall / wild guess, do you use attach() frequently? Not entirely sure how it would come up, but it tends to make weird errors like this occur. M On Fri, Aug 24, 2012 at 4:36 PM, Jennifer Sabatier wrote: > Hi Rui, > > Thanks so much for responding but I think with my HTML problem the vn >

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread Jennifer Sabatier
Hi Rui, Thanks so much for responding but I think with my HTML problem the vn data you made must not be the same. I tried running your code on the data (I uploaded a copy) and I got the same thing I had before. Jen On Fri, Aug 24, 2012 at 5:28 PM, Rui Barradas wrote: > > 165114 1 0 0 0 0 417

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread Jennifer Sabatier
BTW - no one else who has replied to this topic was snobby or unfriendly and I thank you very much for trying to help me. It's just Bert is not the first to respond to my request for help as such. As someone looking forward to becoming an advanced R programmer in my statistical work it is discour

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread Rui Barradas
Hello, Michael's standard guess, FAQ 7.31, was also mine, but is wrong. The error is in Jennifer's flag column, not the result of her ifelse. (!) x <- scan(what="character", text=" PM.EXP PM.DIST.TOT PM.DIST_flag 0 0 0 0 0 0 0 0 0 177502 1 0 31403 1 0 0 0 0 1100549 1 0 38762 1 0 0 0

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread Jennifer Sabatier
Hi Peter, I'm really sorry, I thought I was in plain text. I don't use any formatting in my emails and in Gmail the HTML looks the same as plain text. Anyway, I've attached the data (I didn't think we could do that but I am frequently wrong). I say many cases because this is just a subset of >3

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread Jennifer Sabatier
Bert, I will thank you not to condescend to me, as I am too damn old (40) to be treated that way. You didn't even offer a solution to my problem. You only came to chastise me with regards to your assumptions about me, which is very annoying. While I am at the beginner level of R, I am not an idi

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread Peter Ehlers
On 2012-08-24 13:22, Jennifer Sabatier wrote: Hi R-Helpers, I don't think I need to post a dataset for this question but if I do, I can. Anyway, I am having a lot of trouble with the ifelse command. Here is my code: vn$PM.DIST_flag <- ifelse( (vn$PM.EXP > 0.0) & (vn$PM.DIST.TOT != 1.0), 1, 0

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread Bert Gunter
... and if Michael is correct, there is a lesson here: Think of how much time and aggravation you would have saved yourself if you had FIRST made an effort to read the docs. The FAQ's are there for a reason. As is An Introduction to R, which also should be read before posting on this list. If Mich

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread Jennifer Sabatier
Oops, sorry, I thought I was in plain text. I can't tell the difference because I use so little formatting in my emails. Try this (a truncated version since I have to hand space everything): PM.EXP PM.DIST.TOT PM.DIST_flag 0 00 6417 1

Re: [R] ifelse problem - bug or operator error

2012-08-24 Thread R. Michael Weylandt
On Fri, Aug 24, 2012 at 3:22 PM, Jennifer Sabatier wrote: > Hi R-Helpers, > > I don't think I need to post a dataset for this question but if I do, I > can. Anyway, I am having a lot of trouble with the ifelse command. > You probably should have: dput() makes it super easy as well. > Here is my

[R] ifelse problem - bug or operator error

2012-08-24 Thread Jennifer Sabatier
Hi R-Helpers, I don't think I need to post a dataset for this question but if I do, I can. Anyway, I am having a lot of trouble with the ifelse command. Here is my code: vn$PM.DIST_flag <- ifelse( (vn$PM.EXP > 0.0) & (vn$PM.DIST.TOT != 1.0), 1, 0 ) And here is my output that doesn't make ANY

Re: [R] ifelse problem

2007-12-20 Thread Charilaos Skiadas
To check for NA, use is.na. For instance your second ifelse should read: ifelse(is.na(Sheet1$Claims),0,Sheet1$Claims)) Converting Sheet1$Claims to character doesn't have the effect you think it does. NA is still NA, it does not become "NA". Try for instance: as.character(NA) as.character(NA)

[R] ifelse problem

2007-12-20 Thread Randy Walters
Could someone help me with the following code snippet. The results are not what I expect: > Sheet1$Claims[1:10] [1] NA 1 2 NA NA NA NA NA NA NA > Sheet1[1:10,"SubmissionStatus"] [1] Declined Bound Bound Bound Bound Bound Declined Dead Declined [10] Not Taken Leve