From: cruz <cruadam_at_gmail.com>

Date: Sat, 08 Nov 2008 09:08:25 +0800

[1] 1 2

[1] 3 1

R-help_at_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. Received on Sat 08 Nov 2008 - 01:13:25 GMT

Date: Sat, 08 Nov 2008 09:08:25 +0800

*> 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 8:22 AM, David Croll <david.croll_at_gmx.ch> wrote:

> 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 TRUE/FALSE needed
**>
**> I googled for possible solutions, but I did not find a good explanation for
**> this...
**>
**>
**> The code:
**>
**> test <- function() {
**> vector1 <- sample(1:100,10)
**> vector2 <- sample(1:100,10)
**> for (i in vector1) {
**> for (j in vector2) {
**> if (vector1[i] == vector2[j]) {
**> show(list(i,j))
**> }
**> }
**> }
**> }
**>
**> Regards, David
**>
**> ______________________________________________
**> R-help_at_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_at_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. Received on Sat 08 Nov 2008 - 01:13:25 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Sat 08 Nov 2008 - 11:30:23 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*