connectedness {connectedness} | R Documentation |
connectedness
finds disconnected sets in a two-way classification
without interaction. Its output can be used for plotting and subseting
the data.
connectedness(x, y, sort=TRUE, subset=TRUE, drop=FALSE)
x |
vector, factor1 |
y |
vector, factor2 |
sort |
boolean, sort sets by number of records |
subset |
boolean, fill the subset slot, see details |
drop |
boolean, drop unused levels, see details |
x
and y
must be vectors of the same length. Class of
x
and y
need not be factor, however this is the most
common usage.
Only complete cases (via complete.cases
) of x
and y
are processed i.e. combinations with NA are removed.
List structure of returned value is:
If you work with big datasets, subset=FALSE
might help you in
returning smaller object. However, subset
method can not be used
on such "truncated" object; read also help page of
subset.connectedness
.
Argumnet drop
can be used to drop unused levels before finding
sets. This will remove all sets that have levels of only one effect.
In case of many levels print method truncates them to keep print within
getOption("width")
. Use levelsBySet
to get all
levels by set.
A list of class "connectedness" and "list" returned with structure as described in details.
Gregor Gorjanc
Fernando, R. L. and Gianola, D. and Grossman, M. (1983) Identify all connected subsets in a two-way classification without interaction. Journal of Dairy Science, 66:1399-1402
Searle, S.R. (1987) Linear models for unbalanced models. John Wiley and Sons Inc.
plot.connectedness
,
levelsBySet
and
subset.connectedness
; similar functionality is available
in pheno package: connectedSets
and
maxConnectedSet
data(connect) table(connect$group, connect$season) tmp <- connectedness(x=connect$group, y=connect$season) tmpD <- connectedness(x=connect$group, y=connect$season, drop=TRUE) ## Print method tmp print(tmp) print(tmpD) ## Plot method par(mfrow=c(2, 2)) plot(tmp) plot(tmp, matrix=FALSE, lines=TRUE, col=c("green", "blue"), pointsArg=list(pch=c(15, 19), cex=2), linesArg=list(lwd=2)) plot(tmp, scale=FALSE, lines=TRUE, linesSet=1, linesArg=list(col="black", lwd=2)) plot(tmp, set=2, col=c("gray"), plotArg=list(xlab="Group", ylab="Season")) ## Subset method subset(x=tmp, data=connect, set=1) subset(x=tmpD, data=connect, set=1) subset(x=tmp, data=connect, set=2) subset(x=tmp, data=connect, set=c(1, 2)) subset(x=tmp, data=connect) ## levelBySet method levelsBySet(x=tmp) levelsBySet(x=tmpD) levelsBySet(x=tmp, set=1, factor="x") levelsBySet(x=tmp, set=c(1, 2), factor="y")