I am new to programming in R so I looking for help to start me off. I have a "long" dataset with 4 columns (which I reshaped earlier in R):
d=matrix(c(1,2,3,4,5,6,7,"A","A","A","B","B","B","B",0,0,99,0,0,99,0,99,0,99,99,0,0,99), ncol=4)
colnames(d) = c("ID","S.ID","ValA","ValB"); dt=as.table(d)
I'd like to create, for each S.ID separately (ie A and B), a contingency table for counts of ValA and ValB
For example (here) --
In my actual example I have 17 S.IDs and I'd like to write a program that will generate the contingency tables for each of these.
Additionally, Will this be easier to do in R Studio? If so, please can you also detail how?
Thank you very much!
-Thanks to all who answered so prompltly! :)