add_entity: Add new records to an Entity object

Description Usage Arguments Value Examples

View source: R/add_entity.R

Description

This function allows new records to be added to an Entity object stored inside a World object. This is one of the pipe-friendly functions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
add_entity(
  world,
  entity,
  newdata,
  target = NULL,
  weight_col = NULL,
  replace = TRUE,
  check_relationship_id_cols = FALSE,
  condition = TRUE
)

Arguments

world

(World)
A World object.

entity

(character(1))
An Entity's name.

newdata

(data.frame()|data.table::data.table())
A new attribute data to be added to entity. The new data should have all the same columns as the attribute data of entity.

target

(Target|integer(1))
An external target indicating how many new records from newdata should be added. The selection is ramdomised with all records having the same weight. However, if the weight_col is specified then the weight of each record is equal to its value in weight_col.

weight_col

(character(1))
Name of the weight variable in newdata if any. This is only considered when the target is set. Otherwise all records in newdata will be added to the Entity named entity.

replace

(logical(1))
Random draw with replacement. Default as TRUE.

check_relationship_id_cols

(logical(1))
Check other relationship ids of the Entity in entity to see whether they exist in the data of existing entity or not. Default as FALSE.

condition

(any)
This allows a condition to be set whether or not this function should be executed. Default as TRUE. But it actually accepts any object that when is evaulated returns a logical value.

Value

the input World object.

Examples

1
2
3
world <- World$new()
world$add(x = Individual$new(toy_individuals, id_col = "pid"))
add_entity(world, entity = "Individual", newdata = toy_individuals)

dymium-org/dymiumCore documentation built on July 18, 2021, 5:10 p.m.