r - Making contingency table -


i'm having trouble contingency table.

i want convert kind of table:

dat <- read.csv(text="gatunek,obecnosc,lokalizacja,frekwencja koń dziki,tak,polska,11 koń dziki,nie,polska,14 koń dziki,tak,kujawy,39 koń dziki,nie,kujawy,31",header=true)  #  gatunek obecnosc lokalizacja frekwencja #koń dziki      tak      polska         11 #koń dziki      nie      polska         14 #koń dziki      tak      kujawy         39 #koń dziki      nie      kujawy         31 

to this:

table1

don't afraid, it's polish language. moment have table this:

table2

xtabs should trick:

x <- data.frame(a = c(1, 2, 1, 2), b = c("a", "a", "b", "b"), c = c(11, 14, 39, 31)) xtabs(c ~ + b, data = x)  #   b #a     b #  1 11 39 #  2 14 31 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -