This library provides predicates for creating and fetching R data
frames. R data frames are typically 2-dimensional arrays where the data
is organised in columns. In Prolog, data is typically organised in
rows (or records).
- r_data_frame(+Rvar, +Columns, :Goal) is det
- Create an R data.frame from the solutions of Goal. The resulting
data frame is bound to the R variable Rvar. For example:
?- r_data_frame(movieyear,
[movie=Name, year=Year],
movie(Name, Year)).
- Arguments:
-
Rvar | - is the name of the R output variable |
Columns | - is a list Name=Var |
- r_data_frame_to_dicts(+DataFrame, -Dicts) is det
- Translate a DataFrame into a list of dicts, where each dict
represents a row. The keys of the dicts are fetched from
colnames(DataFrame)
. For example:
?- r_data_frame_to_dicts(mtcars, Dicts).
Dicts = [ row{am:1, carb:4, cyl:6, disp:160.0, drat:3.9,
gear:4, hp:110, mpg:21.0, qsec:16.46, vs:0,
wt:2.62},
...
]
- r_data_frame_to_rows(+DataFrame, +Functor, -Rows) is det
- Translate a 2-dimensional R dataframe into a list of compound
terms, each representing a row. The functor of each row is
Functor. For example:
?- r_data_frame_to_rows(mtcars, car, Rows).
Rows = [ car(21.0, 6, 160.0, 110, 3.9, 2.62, 16.46, 0, 1, 4, 4),
...
].
- r_data_frame_from_dicts(+DataFrame, +Rows) is det
- Assign the R variable DataFrame the content of Rows. Rows is a
list of dicts that must all have the same set of keys. The keys
are used as column names.
- See also
- - dicts_to_same_keys/3 to align the set of keys for each dict
- r_data_frame_from_rows(+DataFrame, +Rows) is det
- Assign the R variable DataFrame the content of Rows. Rows is a
list of compound terms.
- r_data_frame_colnames(+DataFrame, -ColNames:list(atom)) is det
- ColNames are the column names for DataFrame as a list of atoms.
- r_data_frame_rownames(+DataFrame, -RowNames:list(atom)) is det
- RowNames are the row names for DataFrame as a list of atoms.