I’m trying to directly enter the following data into R (which represents a contingency table)
Area School Coffeshop Hospitals Parks Totatl
Washington 142 120 20 20 302
Seattle 120 140 30 40 330
Total 262 260 50 60 632
My code is this:
n<-c("Area","School","Cofeeshop","Hospitals","Parks","Total")
x<-c("Washington",142,120,20,20,302)
y<-c("Seattle",120,140,30,40,330)
z<-c("Total",262,260,50,60,631)
data<-cbind(n,x,y,z)
data<-data.frame(data)
Your code is full of basic syntax errors, please try and copy-and-paste directly from the script you are using. (I really hope you have not done this here).
If you combine character and numeric variables in the same vector, it will create a character vector, which is not what you want.
Try something like