sch_add_activity {criticalpath}R Documentation

Add Activity

Description

Add an activity and her relations to a schedule. The relations are optional. They will be included if a set of activity id is informed, after activity duration.

Usage

sch_add_activity(sch, id, name, duration, ..., direction = "succ")

Arguments

sch

A schedule object.

id

Activity id that will be used to make relation between activities. It must be unique.

name

The name of activity.

duration

A number that represents the activity's duration. It must be equal or greater than zero.

...

A set of activity id relation such that will be linked with activity id. It may be relations of successor or predecessors.

direction

Direction of relations: It may be "succ" or "pred".

  • succ: The relations_id will be the successor of the activity.

  • pred: The relations_id will be the predecessor of the activity.

Value

A Schedule object with an activity added to it. If relations id is present, it will be included to the schedule.

See Also

sch_change_activities_duration(), sch_has_any_activity(), sch_new(), sch_add_activities(), sch_get_activity(), sch_plan(), sch_nr_activities(), sch_add_relation().

Examples

# Example #1: Only with activities
sch <- sch_new() %>%
  sch_add_activity(1L, "Task 1", 5L) %>%
  sch_add_activity(2L, "Task 2", 6L) %>%
  sch_add_activity(3L, "Task 3", 8L) %>%
  sch_add_activity(4L, "Task 4", 6L) %>%
  sch_add_activity(5L, "Task 5", 9L) %>%
  sch_add_activity(6L, "Task 6", 3L) %>%
  sch_add_activity(7L, "Task 7", 4L) %>%
  sch_plan()
sch_duration(sch)
sch_activities(sch)

# Example #2: With activities and relations.
sch <- sch_new() %>%
  sch_add_activity(1L, "Task 1", 5L, 2L, 3L) %>%
  sch_add_activity(2L, "Task 2", 6L, 4L) %>%
  sch_add_activity(3L, "Task 3", 8L, 5L) %>%
  sch_add_activity(4L, "Task 4", 6L, 6L) %>%
  sch_add_activity(5L, "Task 5", 9L, 6L) %>%
  sch_add_activity(6L, "Task 6", 3L, 7L) %>%
  sch_add_activity(7L, "Task 7", 4L) %>%
  sch_plan()
sch_duration(sch)
sch_activities(sch)
sch_relations(sch)



[Package criticalpath version 0.2.1 Index]