Skip to content

List of tables rather than an extra dimension in the table or (l)apply(xtabs)

1 message · Mulholland, Tom

#
I wrote a function that created the crosstab  and removed the extraneous lines and then used lapply


aestabs <- function(x){
   temp <- xtabs(psn ~ lga + year,x)
   temp <- temp[rowSums(temp) != 0,]
   return(temp)
   }
   
eas2 <- lapply(split(ipi$eas,ipi$eas$RegionNum),aestabs)

It's not really reuseable. I guess I could pass a formula and work out a better method of subsetting dimensions (where certain factor levels are not used. But maybe someone has an elegant method they could share.

Tom