asdf¶
Purpose¶
Adds metadata to a matrix or string array and returns a dataframe.
Format¶
-
x_meta =
asdf(x[, varname_1[, varname_2[, ...]]])¶ Parameters: - x (NxK matrix or string array) – data.
- .. (string) – Optional arguments, comma separated list of variable names.
Returns: x_meta (NxK dataframe) – data.
Examples¶
Example 1¶
// Randomly generate linear data
nobs = 100;
x_t = rndn(nobs, 1);
e_t = rndn(nobs, 1);
y_t = 1.3 + 2*x_t + e_t;
// Convert to a dataframe
// and add variable names
linear_data = asdf(y_t ~ x_t ~ e_t, "Y", "X", "Error");
After the above code, linear_data is a dataframe with three numeric variables named Y, X, and Error:
Example 2¶
// Create string array of data
string x_sa = {"cat", "dog", "bird", "cat", "bird", "fish"};
// Convert to a dataframe
// and name the variable `Animals`
x_df = asdf(x_sa, "Animals");
After the above code, x_df is a dataframe with one categorical variable named Animals:
Remarks¶
See also
Functions asMatrix(), asDate(), dfname(), dftype()

