Hi everybody, I am a beginner in R and am attempting to run a one way ANOVA (edit: after some thought I may be better off running a chi squared analysis instead.) in R and have started with creating an array holding my data that looks like the following. (I'm not looking for a solution, I am just looking for insight into how to access the matrix data)
TRT nonLT ser none total
GB 81 46 5253 5380
SG 31 19 804 854
BP 606 325 8110 9041
the treatments are types of surgeries I have labeled as GB, SG, and BP. nonLT, ser, and none are the responses (non life threatening, serious, and none).
I made a matrix in R and gave my rows and columns names, but am lost at how to assign treatments. I am not sure how to access the row/column data if not by using my assigned names for them. I keep getting told that "GB" or other things can't be found. I attempted to assign treatments using "treat1=z$New[z$Trt=="GB"] and am told that "Error in z$New : $ operator is invalid for atomic vectors"
So I'm not sure if there is a way that I can change my data in R that would allow me to use that command?