Hello All! I am trying to plot the frequency of species coocurrance. If given a data set similar like this...(V1="species A", V2="species B", V3="frequency of cooccurance")
> data V1 V2 V3 1 A B 0 2 A C 2 3 A D 5 4 B C 0 5 B D 1 6 C D 0 > data1<-as.data.frame(lapply(data,function(x)(rep(x,data$V3)))) > as.data.frame(data1[-1]) > fdata<-ftable(as.data.frame(data1[-3])) > fdata V2 B C D V1 A 0 2 5 B 0 0 1 C 0 0 0 Question 1: How can I create a matrix or (contingency) table that would include "A, B, C and D" in columns and "A, B, C, and D" in the rows (through R, not manually adjusting the original data text file). - When I "lapply(data,function(x)(rep(x,data$V3)))", the rows with V3=0 are dropped. Question 2: How would I graph the frequency of the counts (V3) (would look most likely follow the poisson distribution). I've used plot(table(data$V3)) to get the correct graph, but is there a way to graph the frequency from a contingency table (question 1) to elicit the same graph? Thanks in advance for your help... Best, Lanna [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.