connectedness {connectedness} | R Documentation |
connectedness
finds disconnected subsets in a two-way
classification without interaction. Its output can be used for plotting
and subseting the data.
connectedness(x, y, sort=TRUE, subsetData=TRUE, drop=FALSE)
x |
vector, factor1 |
y |
vector, factor2 |
sort |
logical, sort subsets by number of records |
subsetData |
logical, fill the subsetData slot, see details |
drop |
logical, 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:
NA
are to be removed, used for subset method
If you work with big datasets, subsetData=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
subsets. This will remove rows with either factor having missing values
(NA
).
In case of many levels print method truncates them to keep print within
getOption("width")
. Use levelsBySubset
to get all
levels by subset.
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
,
levelsBySubset
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, linesSubset=1, linesArg=list(col="black", lwd=2)) plot(tmp, subset=1, col=c("gray"), plotArg=list(xlab="Group", ylab="Season")) ## Subset method subset(x=tmp, data=connect, subset=1) subset(x=tmpD, data=connect, subset=1) subset(x=tmp, data=connect, subset=2) subset(x=tmp, data=connect, subset=c(1, 2)) subset(x=tmp, data=connect) ## levelBySet method levelsBySubset(x=tmp) levelsBySubset(x=tmpD) levelsBySubset(x=tmp, subset=1, factor="x") levelsBySubset(x=tmp, subset=2, factor="xy") levelsBySubset(x=tmp, subset=c(1, 2), factor="y")