verschmelzenden ich die folgende Liste von Kreuztabellen habenR mehrere Kreuztabellen in einer
structure(list(`1` = structure(c(1L, 1L, 1L, 0L, 1L, 0L), .Dim = 2:3, .Dimnames = structure(list(
c("a", "b"), c("x", "y", "z")), .Names = c("", "")), class = "table"),
`2` = structure(c(1L, 1L, 0L, 1L), .Dim = c(2L, 2L), .Dimnames = structure(list(
c("b", "c"), c("y", "z")), .Names = c("", "")), class = "table")), .Names = c("1", "2"))
Die Liste hat 2 Kontingenztafeln und ich möchte, dass sie zu einem verschmelzen. Ich habe die Lösung aus here versucht, aber es hat nicht funktioniert. Es gab den folgenden Fehler
> tapply(T,names(T),sum)
Error in FUN(X[[1L]], ...) : invalid 'type' (list) of argument
Die erwartete Ausgabe ist
> table(x[[1]],x[[2]])
x y z
a 1 1 1
b 1 1 0
c 0 1 1
Wo x
structure(list(id = c("a", "a", "a", "b", "b", "c", "c"), upc = c("x","y", "z", "x", "y", "z", "y"), sfactor = c("1", "1", "1", "1","2", "2", "2")), .Names = c("id", "upc", "sfactor"), row.names = c(NA, -7L), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x25aa378>)
Jede Hilfe willkommen ist. Danke im Voraus.