Skip to content
Back to formatted view

Raw Message

Message-ID: <20051213150515.175B8A3C7@slim.kubism.ku.dk>
Date: 2005-12-13T15:05:15Z
From: rasche@molgen.mpg.de
Subject: 0/1 vector for indexing leads to funny behaviour (PR#8389)

Full_Name: Axel Rasche
Version: 2.2.0
OS: Linux
Submission from: (NULL) (141.14.21.81)


Dear Debuggers,

This is not a serious problem. Are 0/1 vectors intended to be used as index
vectors? If yes, there is a bug. If not, it leads just to some funny behaviour
rather than an error message.

In the appendix is some simple code to reproduce the problem. A logical vector
as.logic(a) helps by indexing the vector b. The 0/1 vector a just returns the
first value "a". But as many times as there is a 1 in a.

Best regards,
Axel


Appendix:

b = c("a","b","c","d")
a = c(0,1,1,0)
b[as.logical(a)]
b[a]
a = c(1,0,1,0)
b[as.logical(a)]
b[a]
a = c(0,1,1,1)
b[as.logical(a)]
b[a]