I am a complete newbie to both R and programming. Please forgive stupidity, but I'm assuming this will be an easy question to answer. I have a table (as below) and am trying to extract a set of values to add to a list. My attempt is as follows:
cfemale0=(0)
for (i in Gender) {
if (Gender[i]=="F") {
if (Treatment[i]=="Control") {
cfemale0=c(cfemale0,Distance[i])
}
}
}
Error in if (Gender[i] == "F") { : missing value where TRUE/FALSE needed
Here is an extract of the (very long) table:
14 1 F Control 1 2
14 1 F Control 2 1
14 1 F Control 3 1
14 1 F Control 4 1
14 1 F Control 5 1
14 1 F Control 6 2
14 1 F Control 7 2
14 1 F Control 8 1
14 1 F Control 9 1
14 1 F Control 10 1
14 1 F Control 11 1
14 1 F Control 12 1
14 1 F Control 13 1
14 1 F Control 14 13
14 1 F Control 15 1
14 1 F Control 16 0
14 1 F MBR 1 1
14 1 F MBR 2 2
14 1 F MBR 3 18
14 1 F MBR 4 5
14 1 F MBR 5 16
14 1 F MBR 6 5
14 1 F MBR 7 0
14 1 F MBR 8 1
14 1 F MBR 9 3
14 1 F MBR 10 1
14 1 F MBR 11 17
14 1 F MBR 12 16
14 1 F MBR 13 17
14 1 F MBR 14 16
14 1 F MBR 15 17
14 1 F MBR 16 2
14 1 F MBL 1 2
14 1 F MBL 2 2
14 1 F MBL 3 1
14 1 F MBL 4 2
14 1 F MBL 5 1
14 1 F MBL 6 3
14 1 F MBL 7 4
14 1 F MBL 8 3
14 1 F MBL 9 3
14 1 F MBL 10 3
14 1 F MBL 11 2
14 1 F MBL 12 2
14 1 F MBL 13 2
14 1 F MBL 14 1
14 1 F MBL 15 1
14 1 F MBL 16 1
12 2 M Control 1 7
12 2 M Control 2 7
12 2 M Control 3 15
12 2 M Control 4 19
12 2 M Control 5 16
12 2 M Control 6 19
12 2 M Control 7 15
12 2 M Control 8 18
12 2 M Control 9 13
12 2 M Control 10 19
12 2 M Control 11 12
12 2 M Control 12 4
12 2 M Control 13 15
12 2 M Control 14 14
12 2 M Control 15 19
12 2 M Control 16 6
12 2 M MBR 1 7
12 2 M MBR 2 15
12 2 M MBR 3 15
12 2 M MBR 4 3
12 2 M MBR 5 8
12 2 M MBR 6 10
12 2 M MBR 7 17
12 2 M MBR 8 3