refine_add_column: Add column to OpenRefine project

View source: R/refine_operations.R

refine_add_columnR Documentation

Add column to OpenRefine project

Description

This function will add a column to an existing OpenRefine project via an API query to /command/core/apply-operations and the core/column-addition operation. The value for the new column can be specified in this function either based on value of an existing column. The value can be defined using an expression written in General Refine Expression Language (GREL) syntax.

Usage

refine_add_column(
  new_column,
  new_column_index = 0,
  base_column = NULL,
  value,
  mode = "row-based",
  on_error = "set-to-blank",
  project.name = NULL,
  project.id = NULL,
  verbose = FALSE,
  validate = TRUE,
  ...
)

Arguments

new_column

Name of the new column

new_column_index

Index at which the new column should be placed in the project; default is 0 to position the new column as the first column in the project

base_column

Name of the column on which the value will be based; default is NULL, which means that the value will not be based off of a value in an existing column

value

Definition of the value for the new column; can accept a GREL expression

mode

Mode of operation; must be one of "row-based" or "record-based"; default is "row-based

on_error

Behavior if there is an error on new column creation; must be one of "set-to-blank", "keep-original", or "store-error"; default is "set-to-blank"

project.name

Name of project

project.id

Unique identifier for project

verbose

Logical specifying whether or not query result should be printed; default is FALSE

validate

Logical as to whether or not the operation should validate parameters against existing data in project; default is TRUE

...

Additional parameters to be inherited by refine_path; allows users to specify host and port arguments if the OpenRefine instance is running at a location other than http://127.0.0.1:3333

Value

Operates as a side-effect passing operations to the OpenRefine instance. However, if verbose=TRUE then the function will return an object of the class "response".

Examples

## Not run: 
fp <- system.file("extdata", "lateformeeting.csv", package = "rrefine")
refine_upload(fp, project.name = "lfm")

refine_add_column(new_column = "date_type",
                 value = "grel:value.type()",
                 base_column = "theDate",
                 project.name = "lfm")

refine_add_column(new_column = "example_value",
                 new_column_index = 0,
                 value = "1",
                 project.name = "lfm")

## End(Not run)

vpnagraj/rrefine documentation built on Nov. 21, 2022, 12:20 a.m.