moon = matrix(c(2,3,17,21,37,19,11,14,9,6), ncol=2,byrow=TRUE)
colnames(moon) <- c("Full", "Not")
rownames(moon) <-c("Violent", "Property", "Drugs", "Domestic", "Other")
moon <- as.table(moon)
addmargins(moon)
##          Full Not Sum
## Violent     2   3   5
## Property   17  21  38
## Drugs      37  19  56
## Domestic   11  14  25
## Other       9   6  15
## Sum        76  63 139
prop.table(moon)
##                Full        Not
## Violent  0.01438849 0.02158273
## Property 0.12230216 0.15107914
## Drugs    0.26618705 0.13669065
## Domestic 0.07913669 0.10071942
## Other    0.06474820 0.04316547
chisq.test(moon)
## Warning in chisq.test(moon): Chi-squared approximation may be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  moon
## X-squared = 6.2052, df = 4, p-value = 0.1843
chisq.test(moon)$expected
## Warning in chisq.test(moon): Chi-squared approximation may be incorrect
##               Full       Not
## Violent   2.733813  2.266187
## Property 20.776978 17.223022
## Drugs    30.618705 25.381295
## Domestic 13.669065 11.330935
## Other     8.201439  6.798561
"a) independence test"
## [1] "a) independence test"
"b) Null is moon phase is independent of criminal behavior"
## [1] "b) Null is moon phase is independent of criminal behavior"
"c) chi-square prcoedure innacurate due to lack of data"
## [1] "c) chi-square prcoedure innacurate due to lack of data"
"#36"
## [1] "#36"
"a) put data in matrix with expected values"
## [1] "a) put data in matrix with expected values"
"b Ho: Moon is inpependent of criminal activity vs Ha: Ho is false:reject null because there is 0% cahance that amount of crimminal activity during full moon was due to random variation

"
## [1] "b Ho: Moon is inpependent of criminal activity vs Ha: Ho is false:reject null because there is 0% cahance that amount of crimminal activity during full moon was due to random variation\n\n"

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.