Skip to contents

Save a dictionary or equation data frame in a text file format that can be copied and pasted into the Java version of Interact for analysis using that program. This allows users to create desired data subsets using this package rather than manually adding and removing lines from datasets Interact provides, facilitating more reproducible workflows using Interact Java. This may also help users reformat their own imported datasets for use in Interact.

Usage

save_for_interact(
  data,
  type = "dict",
  group = "none",
  filename = paste0(deparse(substitute(data)), ".txt"),
  savefile = TRUE
)

Arguments

data

data frame to save

type

string ("dict" or "eqn") indicating type of data

group

string indicating the name or numeric index of a column to group on. This column must contain only two values and each term must have one entry for each

filename

string. the filepath at which to save (must end in .txt)

savefile

logical. that denotes whether to actually save the file (FALSE is primarily useful for testing purposes). Default is TRUE.

Value

the dataframe that is written to file

Details

Provided data must contain a column titled "term" and either three or six numeric columns with EPA values that start with "E", "P", and "A". These requirements are generally satisfied by dataframes produced by epa_subset().

If three numeric columns are provided, the function can accept an optional "group" argument that is the name of a column that contains two values. This column will be used to "widen" the data to two sets of EPA columns. The first set will correspond with the first value in the group column and the second set will correspond with the second value. This is useful when you wish to allow Interact to take two different sets of values depending on which of two groups an actor is a part of. This is most frequently used to provide gendered data, but it has other applications as well--for example, if you wish to allow students and teachers to have different meanings for the same terms.

Note that Interact requires identity, behavior, setting, and modifier data to be loaded separately, meaning that prior to using this function, users should ensure that only one component is represented per file.

Examples

if (FALSE) {
save_for_interact(data = epa_subset(dataset = "household1997", component = "behavior"),
    filename = "household1997behavior.txt")
}