0)
The row of data I want to put in the matrix is:
tab1[tab1$comp==the.comp & tab1$schlid==the.schl & tab1$ext.obs==0,]
schlid ext.obs comp 1 2 3 4 NA
41 22091 0 1 0.04166667 0.04166667 0.7083333 0.2083333 0
If I do this:
tab1.m1[1,] <- as.matrix(subset(tab1, tab1$comp==the.comp &
tab1$schlid==the.schl & tab1$ext.obs==0)[4:7])
I get the correct values in the matrix:
tab1.m1[1,] <- as.matrix(subset(tab1, tab1$comp==the.comp &
tab1$schlid==the.schl & tab1$ext.obs==0)[4:7])
tab1.m1
[,1] [,2] [,3] [,4]
[1,] 0.04166667 0.04166667 0.7083333 0.2083333
[2,] 0.00000000 0.00000000 0.0000000 0.0000000
but when I use the ifelse() as above, I get this:
[,1] [,2] [,3] [,4]
[1,] 0.04166667 0.04166667 0.04166667 0.04166667
[2,] 0.00000000 0.00000000 0.00000000 0.00000000
Can anyone explain this to me?
Also, is there an easier, less clumsy way to test for the existence
of a
row in a data frame?
Thanks in advance.
--
Stuart Luppescu -=- slu .at. ccsr.uchicago.edu
University of Chicago -=- CCSR
???????? -=- Kernel 2.6.39-gentoo-r3
You can't expect statistical procedures to rescue
you from poor data. -- Berton Gunter (on
dealing with missing values in a cluster analysis)
R-help (April 2005)