[R] "subscript out of range" message
arinbasu@softhome.net
arinbasu at softhome.net
Fri Aug 22 04:49:57 CEST 2003
Hi All:
I was recently working with a dataset on arsenic poisoning. Among the
variables in the dataset, I used the following three variables to produce
crosstabulations (variable names: FOLSTAT, GENDER, ASBIN; all three were
categorical variables, FOLSTAT denoted follow up status for the subjects and
had seven levels, GENDER denoted sex (two levels: male,female), and ASBIN
denoted binarized arsenic concentrations (two levels: "<0.05", ">0.05"
denoting less than 0.05 mg/L and more than 0.05 mg/L respectively).
To illustrate, I used the following code for crosstabulation:
x <- table(FOLSTAT,GENDER,ASBIN)
# from the results, I then wanted to subset a table for the ASBIN
value ">0.05"
I used the following code to subset the table:
y <- x[,,ASBIN=">0.05"]
# When I do this, R throws an error message stating "subscript out of
range". However, it runs fine if I change the labels for my ASBIN variable
from "<0.05" and ">=0.05" to words like "Nonexposed" and "Exposed"
respectively.
I searched the archives and the documentations for this, but could not find
a solution. I understand that sometimes it is more expressive to use
expressions like "<0.05" (or something similar) as headings in
cross-tabulations. What was I doing incorrectly?
Would greatly appreciate your insight.
I use:
R version: 1.7.1
OS: Windows XP Home
TIA,
Arin Basu
More information about the R-help
mailing list