![]() |
|
Data Structures | |
struct | line_parse_t |
struct | apop_char_info |
Macros | |
#define | DbType apop_opts.db_engine=='m' ? "text" : "character" |
#define | DbType2 apop_opts.db_engine=='m' ? "double" : "numeric" |
#define | Textrealloc(str, len) |
Functions | |
void | xprintf (char **q, char *format,...) |
gsl_vector * | apop_array_to_vector (double *in, int size) |
gsl_matrix * | apop_vector_to_matrix (const gsl_vector *in, char row_col) |
apop_data * | apop_db_to_crosstab (char *tabname, char *r1, char *r2, char *datacol) |
void | apop_crosstab_to_db (apop_data *in, char *tabname, char *row_col_name, char *col_col_name, char *data_col_name) |
apop_data * | apop_data_rank_compress (apop_data *in) |
apop_data * | apop_data_rank_expand (apop_data *in) |
gsl_vector * | apop_vector_copy (const gsl_vector *in) |
gsl_matrix * | apop_matrix_copy (const gsl_matrix *in) |
apop_data * | apop_text_to_data (char const *text_file, int has_row_names, int has_col_names, int const *field_ends, char const *delimiters) |
void | apop_data_unpack (const gsl_vector *in, apop_data *d, char use_info_pages) |
gsl_vector * | apop_data_pack (const apop_data *in, gsl_vector *out, char all_pages, char use_info_pages) |
apop_data * | apop_data_fill_base (apop_data *in, double ap[]) |
gsl_vector * | apop_vector_fill_base (gsl_vector *in, double ap[]) |
apop_data * | apop_text_fill_base (apop_data *data, char *text[]) |
char * | prep_string_for_sqlite (int prepped_statements, char const *astring) |
int | apop_use_sqlite_prepared_statements (size_t col_ct) |
int | apop_prepare_prepared_statements (char const *tabname, size_t col_ct, sqlite3_stmt **statement) |
char * | cut_at_dot (char const *infile) |
int | apop_text_to_db (char const *text_file, char *tabname, int has_row_names, int has_col_names, char **field_names, int const *field_ends, apop_data *field_params, char *table_params, char const *delimiters, char if_table_exists) |
Variables | |
char * | apop_nul_string |
sqlite3 * | db |
The various functions to convert from one format to another.
#define Textrealloc | ( | str, | |
len | |||
) |
void apop_crosstab_to_db | ( | apop_data * | in, |
char * | tabname, | ||
char * | row_col_name, | ||
char * | col_col_name, | ||
char * | data_col_name | ||
) |
See apop_db_to_crosstab for the storyline; this is the complement, which takes a crosstab and writes its values to the database.
For example, I would take
c0 | c1 | |
r0 | 2 | 3 |
r1 | 0 | 4 |
and do the following writes to the database:
r0
, r1
, ... c0
, c1
, .... Text columns get their own numbering system, t0
, t1
, ..., which is a little more robust than continuing the column count from the matrix.One often finds data where the column indicates the value of the data point. There may be two columns, and a mark in the first indicates a miss while a mark in the second is a hit. Or say that we have the following list of observations:
Then we could write this as:
because there are six 1s observed, four 2s observed, and two 3s observed. We call this rank format, because 1 (or zero) is typically the most common, 2 is second most common, et cetera.
This function takes in a list of observations, and aggregates them into a single row in rank format.
0 0 1 1 0
, then I won't know to generate results with three bins where the last bin has probability zero.The complement to this is apop_data_rank_compress; see that function's documentation for the story and an example.
This function takes in a data set where the zeroth column includes the count(s) of times that zero was observed, the first gives the count(s) of times that one was observed, et cetera. It outputs a data set whose vector element includes a list that has exactly the given frequency of zeros, ones, et cetera.
apop_data* apop_db_to_crosstab | ( | char * | tabname, |
char * | r1, | ||
char * | r2, | ||
char * | datacol | ||
) |
Give the name of a table in the database, and names of three of its columns: the x-dimension, the y-dimension, and the data. the output is a 2D matrix with rows indexed by r1 and cols by r2.
tabname | The database table I'm querying. Anything that will work inside a from clause is OK, such as a subquery in parens. |
r1 | The column of the data set that will indicate the rows of the output crosstab |
r2 | The column of the data set that will indicate the columns of the output crosstab |
datacol | The column of the data set holding the data for the cells of the crosstab |
NULL
data set and if apop_opts.verbosity >= 1
print a warning.select
query to generate the data. One is to specify an ad hoc table to pull from:The other is to use the fact that the table name will be at the end of the query, so you can add conditions to the table:
out->error='n' | Name not found error. |
out->error='q' | Query returned an empty table (which might mean that it just failed). |
char* prep_string_for_sqlite | ( | int | prepped_statements, |
char const * | astring | ||
) |
–If the string has zero length, then it's probably a missing value. –If the string isn't a number, it needs quotes