Top |
gretl_string_table *
gretl_string_table_new (const int *list
);
These values in list
should correspond to the 0-based indices
of the series in question within the dataset. For example,
if strings are to be recorded for variables 2, 5 and 10 the
list
argument would be {3, 2, 5, 10}. If NULL is passed for
list
the return value is an initialized, empty string table.
int gretl_string_table_index (gretl_string_table *gst
,const char *s
,int col
,int addcol
,PRN *prn
);
This function has two main uses: for lookup in the context of
a completed string table, or for constructing such a
table (with addcol
non-zero). The returned index reflects
any additions to the table that may be required (if column
col
does not already exist, or if string s
is not already
stored for column col
).
gst |
a gretl string table. |
|
s |
the string to look up or add. |
|
col |
index of the column to be accessed or created. |
|
addcol |
non-zero to indicate that a column should be added if it's not already present. |
|
prn |
gretl printer (or |
int gretl_string_table_finalize (gretl_string_table *gst
,DATASET *dset
);
Attaches the string-value information in gst
to the dataset
dset
. However, if one or more of the series referenced by gst
are deemed to be integer codes or misclassified numeric data,
their "series tables" are commuted into numeric form.
int gretl_string_table_validate (gretl_string_table *gst
,gretlopt opt
);
Checks that the "string values" in gst
are not in fact
undigested quasi-numerical values. We run this on
imported CSV data to ensure we don't produce
misleading results. In the spreadsheet case we're on
the lookout for purely numerical data wrongly identified
as strings; we don't treat that as fatal but mark the
series table(s) for conversion to numeric.
int gretl_string_table_save (gretl_string_table *gst
,DATASET *dset
);
Attaches the content of gst
to dset
.
void
gretl_string_table_destroy (gretl_string_table *gst
);
Frees all resources associated with gst
.
void gretl_string_table_add_extra (gretl_string_table *gst
,PRN *prn
);
Steals the printing buffer from prn
and adds it to gst
.
The buffer will be appended when gst
is printed via
gretl_string_table_finalize()
.
int gretl_string_table_reset_column_id (gretl_string_table *gst
,int oldid
,int newid
);
series_table * gretl_string_table_detach_col (gretl_string_table *gst
,int col
);
void
series_table_destroy (series_table *st
);
Frees all resources associated with st
.
double series_table_get_value (series_table *st
,const char *s
);
the numerical value associated with s
in the
given series table, or NADBL in case there is no match.
int * series_table_map (series_table *st_from
,series_table *st_to
);
Constructs a mapping from the integer codes in st_from
to those in st_to
. For example, if the string "foo"
has code 3 in st_from
and code 12 in st_to
, then
element 3 in the mapping array will have value 12.
For any strings in st_from
that are not matched
in st_to
, the associated element of the map is set
to -1.
Element 0 of the map holds the number of following
elements, which is the same as the number of strings in
st_from
.
void gretl_insert_builtin_string (const char *name
,const char *s
);
Inserts value s
for string name
in gretl's table
of built-in string variables.
int process_string_command (const char *line
,double ***pZ
,DATASET *dset
,PRN *prn
);
gretl_array * retrieve_date_strings (const gretl_vector *v
,const DATASET *dset
,int *err
);
char * retrieve_file_content (const char *fname
,const char *codset
,int *err
);