This function helps to add certain statements. A statement consists of a PID-QID combination that is added to a dataframe. The PID will be the column name, QID the row content. It assumes there is a dataframe that has at least three columns: (1) statements, (2) pid, (3) qid.

add_statement(
  data = NULL,
  available_statements = statements,
  new_statement = NULL,
  verbose = TRUE,
  qid_from_row = FALSE,
  col_for_row_content = NULL
)

Arguments

data

dataframe to add the new column

available_statements

dataframe with all statements that can be added with this method. It assumes there is a dataframe that has at least three columns: (1) statement, (2) pid, (3) qid.

new_statement

string of new statement. Must exist in available_statements$statement. If statement is coordinates, then a column longitude and a column latitude is expected.

verbose

show in terminal what was added

qid_from_row

boolean; default FALSE - then QID is taken from dataframe statements, if TRUE id QID value should be taken from another row

col_for_row_content

string; name of column in dataframe data that contains the QID values

Examples

statements <- data.frame(statement = c("my_statement"), pid = c("P2"), qid = c("Q1"))
data <- data.frame(item = "my item")
data %>% add_statement(available_statements = statements, new_statement = "my_statement")
#> 
#> ── add "my_statement" statement ────────────────────────────────────────────────
#>  PID = P2
#>  QID = Q1
#>      item P2
#> 1 my item Q1