-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path158-fexact2.c
19 lines (16 loc) · 865 Bytes
/
158-fexact2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <apop.h>
int main(){
int readin_status = apop_text_to_db("amash_vote_analysis.csv", .tabname="amash");
Apop_stopif( readin_status== -1, exit(1), 0, "Trouble reading in the data. "
"Have you downloaded it to this directory?");
double median_contrib = apop_query_to_float("select max(contribs) from "
" (select contribs from amash order by contribs "
" limit (select count(*)/2 from amash))");
apop_query("create table pv_xtab as "
" select vote, (contribs+0.0 > %g) as hi_money, count(*) as ct "
" from amash "
" group by vote, hi_money ", median_contrib);
apop_data *xtab = apop_db_to_crosstab("pv_xtab", "hi_money", "vote", "ct");
apop_data_show(xtab);
apop_data_show(apop_test_fisher_exact(xtab));
}