[R] Help with a Lattice plot that fails with an empty unique combination

Tom Mulholland tmulholl at bigpond.net.au
Wed Jun 9 08:58:14 CEST 2004


While using Lattice I received the following error.

Error in if (xx != 0) xx/10 else z/10 : argument is of length zero
In addition: Warning messages:
1: is.na() applied to non-(list or vector) in: is.na(x)
2: is.na() applied to non-(list or vector) in: is.na(x)
3: no finite arguments to min; returning Inf
4: no finite arguments to max; returning -Inf
5: NaNs produced in: log(x, base)
Can anyone point me in the right direction.

I have included a reproducible example from part of the data. The problem
appears to be the lack of data in column POH which I can see when I cross
tab the data

xtabs(IWD ~ about + SOA,data=test1) (from the dummy example below)

            SOA
about        ARON CRDA DCJH DJKT DEGF DOPC FACO FRNE HHW MEPR NGA OTHE OTRE
JHG POH
  non-I NO G   0    1    0    0  443    0    2  172  486  96   73 233  217
408   0
  I NO G       1    0    0    0  251    0    0   15  545  29    0   8  698
207   0
  non-I ERT    0  435  153   66  152   17   15    7   85 233   32  15  147
216   0
  I ERT       12    1    0    0  227    0    0    2  234  98    0   5  211
17   0
            SOA
about        PKJI SPOC YTGB SUCH
  non-I NO G 527    1  945  160
  I NO G     555    0  135   45
  non-I ERT  556    0  805    1
  I ERT      592    0  205  224
>

I normally subset data and drop unused factors at that stage. But my
investigations during the creation of this sample, especially when I was
creatiing the dummy dataset and found that i needed to isolate the problem
before I could create one that would duplicate the problem, indicate that it
was not just one NA doing the damage. I replaced all the NAs in the IWD with
1s and it still did not work, because the relevvent SOA varaibles were also
NA.

Aha, I thought, time to reread the lattice documentation to see what I have
missed (it will probably be in there and I've missed it, but that's another
story.) I noted the subset option but I can't see how one would filter out
the specific variations that need to be dropped.

Here's my sample to replicate the problem.

test1 <- structure(list(IWD = c(5, 3, 15, 2, 40, 1,
20, 40, 45, 50, 35, 33, 33, 3, 50, 14, 139, 139, 13, 3, 1, 1,
127, 1, 14, 1, 4, 3, 3, 3, 3, 3, 21, 51, 35, 33, 11, 11, 11,
6, 1, 7, 6, 8, 1, 1, 1, 4, 14, 6, 3, 34, 25, 3, 34, 1, 10, 14,
7, 35, 4, 13, 7, 45, 13, 7, 45, 13, 7, 45, 13, 7, 45, 13, 7,
7, 45, 13, 3, 13, 106, 4, 9, 1, 7, 40, 20, 24, 12, 2, 7, 1, 7,
6, 30, 18, NA, 2, 2, 4, 17, 4, 48, 4, 4, 1, 29, 17, 29, 2, 4,
6, 12, 3, 2, 17, 23, 65, 65, 6, 2, 23, 5, 2, 1, 4, 4, 4, 64,
24, 4, 47, 1, 44, 17, 24, 25, 57, 9, 27, 19, 7, 1, 1, 1, 4, 23,
8, 10, 10, 19, 21, 19, 21, 17, 9, 25, 12, 65, 10, 2, 2, 12, 1,
1, 19, 19, 19, 84, 6, 4, 84, 1, 7, 3, 16, 2, 84, 4, 1, 1, 1,
28, 1, 65, 10, 10, 10, 9, 8, 32, 32, 1, 15, 9, 4, 17, 3, 3, 6,
1, 12, 12, 16, 18, 17, 1, 61, 3, 3, 3, 3, 7, 1, 2, 13, NA, 49,
155, 31, 1, 43, 3, 10, 32, 65, 17, 287, 7, 55, 12, 2, 1, 12,
12, 12, 13, 43, 43, 8, 34, 14, 4, 14, 4, 32, 36, 12, 21, 13,
6, 6, 6, 6, 6, 16, 25, 25, 3, 4, 1, 1, 65, 54, 54, 72, 25, 36,
3, 26, 26, 3, 13, 111, 26, 13, NA, NA, 3, 1, 12, 1, 1, 22, 1,
25, 64, 72, 72, 1, 22, 2, 12, 3, 13, 139, 7, 1, 16, 115, 11,
54, 11, 49, 4, 1, 1, 1, 7, 11, 3, 2, 157, 4, 4, 9, 3, 15, 15,
9, 4, 19, 53, 53, 60, 221, 107, 107, 53, 3, 7, 173, NA, NA, 31,
38, 38, 74, 14, NA, NA, 92, 53, 14, 107, 107, 15, 38, 14, 53,
74, 47, 47, 7, 3, 49, 42, 74, 33, 3, 8, 4, 31, 26, 26, 26, 33,
2, 5, 5, 8, 29, 4, 94, 94, 3, 75, 1, NA, 131, 5, 11, 75, 12,
107, 74, 9, NA, NA, NA, NA, 22, 20, 1, 3, 2, 237, 237, 1, 1,
36, 36, 26, 45, 9, 12, 82, 72, 62, 198, 198, 1, 1, 8, 72, 72,
2, 2, 107, 3, 2, 2, 72, 104, 11, 197, 197, 142, 2, 198, 3, 20,
107, 107, 50, 72, 20, 72, NA, 82, 8, 118, 9, 3, 72, 24, 72, 50,
NA, 13, 107, 16, 11, 4, 8, 49, 237, 21, 201, 201, 201, 201, 176,
176, 2), SOA = structure(as.integer(c(16, 9,
16, 16, 10, 14, 10, 10, 14, 13, 14, 16, 16, 18, 13, 18, 18, 18,
18, 18, 16, 5, 5, 1, 14, 2, 12, 18, 18, 18, 16, 16, 11, 16, 13,
16, 8, 8, 8, 16, 18, 5, 14, 14, 5, 5, 5, 16, 16, 12, 19, 16,
14, 13, 14, 19, 13, 12, 16, 14, 13, 18, 5, 18, 18, 5, 18, 18,
5, 18, 18, 5, 18, 18, 5, 5, 18, 18, 16, 14, 16, 16, 9, 2, 8,
14, 10, 14, 1, 16, 16, 18, 10, 5, 16, 5, NA, 5, 14, 13, 16, 13,
14, 14, 18, 18, 8, 6, 8, 18, 16, 5, 13, 8, 8, 16, 16, 13, 13,
5, 16, 16, 16, 13, 16, 10, 10, 10, 12, 10, 13, 18, 14, 16, 16,
14, 14, 16, 5, 14, 18, 7, 7, 7, 12, 9, 5, 16, 14, 14, 16, 14,
16, 14, 16, 10, 12, 12, 13, 9, 14, 14, 18, 13, 13, 16, 16, 16,
5, 16, 16, 5, 16, 16, 16, 16, 5, 5, 10, 14, 14, 18, 18, 9, 13,
14, 14, 14, 13, 14, 5, 5, 14, 14, 13, 18, 9, 16, 16, 16, 5, 16,
16, 16, 16, 16, 16, 16, 13, 13, 13, 13, 16, 11, 16, 16, NA, 5,
10, 13, 13, 16, 14, 16, 18, 18, 16, 9, 18, 5, 8, 14, 13, 18,
18, 18, 16, 16, 16, 16, 5, 16, 16, 18, 16, 16, 5, 18, 18, 16,
16, 16, 16, 16, 16, 13, 5, 5, 2, 5, 19, 5, 18, 16, 16, 11, 5,
5, 13, 13, 13, 16, 16, 16, 13, 16, NA, NA, 10, 16, 18, 16, 16,
13, 16, 5, 8, 3, 3, 16, 13, 16, 18, 16, 16, 13, 13, 8, 16, 13,
18, 16, 18, 18, 2, 5, 5, 5, 18, 16, 8, 10, 19, 9, 9, 9, 16, 19,
19, 18, 14, 16, 16, 16, 9, 19, 2, 2, 16, 14, 13, 14, NA, NA,
9, 14, 14, 9, 5, NA, NA, 9, 16, 12, 2, 2, 19, 14, 12, 16, 9,
12, 12, 16, 13, 16, 10, 9, 4, 16, 7, 13, 9, 16, 16, 16, 4, 18,
9, 8, 12, 10, 13, 18, 18, 9, 18, 17, NA, 14, 12, 16, 18, 18,
8, 13, 18, NA, NA, NA, NA, 16, 13, 18, 3, 19, 9, 9, 9, 18, 9,
9, 18, 18, 18, 16, 18, 13, 5, 5, 5, 8, 8, 16, 9, 9, 5, 5, 8,
18, 8, 8, 9, 5, 16, 15, 15, 16, 5, 5, 3, 13, 8, 8, 9, 13, 13,
9, NA, 18, 16, 5, 18, 3, 9, 16, 13, 9, NA, 18, 8, 14, 11, 9,
16, 10, 9, 9, 8, 8, 8, 8, 18, 18, 8)), .Label = c("ARON", "CRDA",
"DCJH", "DJKT", "DEGF", "DOPC", "FACO", "FRNE", "HHW", "MEPR",
"NGA", "OTHE", "OTRE", "JHG", "POH", "PKJI", "SPOC", "YTGB",
"SUCH"), class = "factor"), about = structure(as.integer(c(3,
4, 1, 3, 1, 2, 3, 1, 2, 4, 3, 1, 1, 1, 4, 3, 1, 1, 3, 4, 3, 3,
4, 2, 1, 4, 1, 4, 4, 4, 4, 4, 3, 4, 2, 1, 1, 1, 1, 1, 1, 3, 1,
1, 3, 3, 3, 1, 2, 1, 1, 3, 2, 4, 1, 4, 1, 3, 3, 3, 4, 3, 1, 3,
3, 1, 3, 3, 1, 3, 3, 1, 3, 3, 1, 3, 3, 3, 3, 1, 1, 1, 4, 1, 3,
1, 3, 3, 4, 1, 3, 3, 4, 2, 3, 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2, 2, NA, 1, 2, NA, 3, 3, 2, 2, 2, 2, NA,
1, NA, 4, 3, 2, 2, 4, NA, 2, NA, NA, NA, NA, 3, 3, 1)), .Label = c("non-I NO
G",
"I NO G", "non-I ERT", "I ERT"
), class = "factor")), .Names = c("IWD",
"SOA", "about"))

xtabs(IWD ~ about + SOA,data=test1)

print(stripplot(IWD ~ about | SOA,data=test1,
       ylab="Days",
       sub="For days less than 365 days",
       between=list(x=0.3,y=0.3), jitter=T,
       main = paste("Covering District",j),
       scales = list( x = list(rot = 90))))


Ciao, Tom



Tom Mulholland
Tom Mulholland Associates

Ph: 9371 1302
Mob: 0417 962139

ABN: 74 018 074 092


---




More information about the R-help mailing list