Re: [R] missing value where TRUE/FALSE needed ERROR

2016-02-09 Thread Maram SAlem
Thanks for helping thanoon. I used the if() { } else { . } and it worked better On 9 February 2016 at 15:56, thanoon younis wrote: > Hi, > > Try to check

[R] missing value where TRUE/FALSE needed ERROR

2016-02-09 Thread Maram SAlem
Hi all, I'm trying to write a function to implement a Metropolis-within-Gibbs algorithm for two parameters.I'm including a naive version here so as to be able to spot the error I got. So I first generate the vectors, X and R, that will help to start the algorithm using (for example): n=8; m=5;

[R] missing value where TRUE/FALSE needed

2011-12-23 Thread Michael Pearmain
Merry Xmas to all, I am writing a function and curiously this runs sometimes on one data set and fails on another and i cannot figure out why. Any help much appreciated. If i run the code below with data - iris[ ,1:4] The code runs fine, but if i run on a large dataset i get the following error

Re: [R] missing value where TRUE/FALSE needed

2011-12-23 Thread jim holtman
Does this look similar to the error you are getting: while(NA == TRUE) 1 Error in while (NA == TRUE) 1 : missing value where TRUE/FALSE needed SO 'notconverged' is probably equal to NA. BTW, what is the value of 'tol'; I do not see it defined. So when computing 'notconverged' you have

Re: [R] missing value where TRUE/FALSE needed

2011-12-23 Thread Michael Pearmain
Apologies, I was using top = 0.0001 I had looked at browser and did show notconverged = NA. But I couldn't understand why it worked for one and not the other? On Friday, 23 December 2011, jim holtman jholt...@gmail.com wrote: Does this look similar to the error you are getting: while(NA ==

Re: [R] missing value where TRUE/FALSE needed

2011-12-23 Thread jim holtman
Given that the maximum floating point value is: $double.xmax [1] 1.797693e+308 and the number you are trying to calculate is 5E323 you are exceeding the size of numbers you can process. Have a happy holiday and glad I could help. On Fri, Dec 23, 2011 at 11:24 AM, Michael Pearmain

Re: [R] missing value where TRUE/FALSE needed

2008-11-08 Thread Ray Brownrigg
To answer the actual question, your i and j indices are not what you expect (but are what you specify). Consider the following, which follows your algorithm: vector1 - sample(1:100,2) vector2 - sample(1:100,2) for (i in vector1) { + for (j in vector2) { + show(c(i, j)) + } + } [1]

[R] missing value where TRUE/FALSE needed

2008-11-07 Thread David Croll
Hello dear R people, for my MSc thesis I need to program some functions, and some of them simply do not work. In the following example, I made sure both vectors have the same length (10), but R gives me the following error: Error in if (vector1[i] == vector2[j]) { : missing value where

Re: [R] missing value where TRUE/FALSE needed

2008-11-07 Thread cruz
is this what you want? vector1 [1] 65 1 34 100 42 20 79 43 89 10 vector2 [1] 34 65 47 91 48 32 23 74 92 86 for (i in 1:10) { + for (j in 1:10) { + if (vector1[i] == vector2[j]) + show(c(i,j)) + } + } [1] 1 2 [1] 3 1 On Sat, Nov 8, 2008 at

Re: [R] missing value where TRUE/FALSE needed

2008-11-07 Thread jim holtman
It would be useful to learn how to use debug/browser. Here is the state of the machine when the error occurs: test() Error in if (vector1[i] == vector2[j]) { : missing value where TRUE/FALSE needed Enter a frame number, or 0 to exit 1: test() Selection: 1 Called from: eval(expr, envir,

Re: [R] missing value where TRUE/FALSE needed

2008-11-07 Thread Erik Iverson
They may be the same length; that's not what the error message is complaining about: it says there is a missing value (i.e., an NA) where a TRUE/FALSE value is needed, therefore the 'if' doesn't know what to do, since it is not TRUE or FALSE. So, try summary(vector1) summary(vector2)