powered by
This function runs a one-sample Z-test, comparing the proportion in your sample to the proportion in the population.
z.test(df, var1, var2, prop)
This function returns the Z score and p-value for the z-test.
data frame to read in.
variable with the total number of events, by sub-unit (e.g. cities within a county).
variable with number of events for a specific group.
proportion to compare to (between 0 and 1).
data <- UCR2015[UCR2015$state=="California",] data$total_part2 <- data$burglary + data$larceny + data$mv_theft + data$arson z.test(data,total_part2,burglary,.25)
Run the code above in your browser using DataLab