next up previous contents
Next: Adding covariates Up: Operations on ldframe objects Previous: Selections on ldframe objects

Illegal selections

Recall that the main requirement of an ldframe object is that its Subject column be block-sorted, with unique subject codes appearing in contiguous blocks. It is however possible to select rows from an ldframe object such that the resultant object does not comply with this restriction. If you attempt to do so, a warning will be given and the result object will be of class data.frame instead of ldframe.
\begin{Example}
\gt baddf <- data.ldf[c(1:5,10:6),]
Warning messages:
 Selection...
 ....81 1 5
 7 2.11 1 4
 6 3.25 1 3
\gt class(baddf)
[1] ''data.frame''\end{Example}
Observe that the observations for Subject 1 no longer appear in a contiguous block. If such a situation arises, you can convert the data.frame back into an ldframe object with as.ldframe, which arranges the Subject column into contiguous blocks where necessary. By default, as.ldframe also sorts by Time within each Subject code. This is for convenience only; to suppress sorting by Time use the option sort.time=F to as.ldframe:
\begin{Example}
\gt as.ldframe(baddf,sort.time=F)
 y Subject Time 
 1 2.64 3 1
 ...
 ....98 1 2
 8 3.81 1 5
 7 2.11 1 4
 6 3.25 1 3
10 4.78 2 2
 9 4.46 2 1\end{Example}


David Smith
4/2/1998