Learn R Programming

criticalpath (version 0.2.1)

sch_add_activities: Add Activities

Description

Combine several vectors for activities and their attributes into a tibble, which can be combined with other similarly-generated tibbles, resulting in unique tibble to be added in a schedule. If the schedule already contain some activities, the new activities will be added in the end.

Usage

sch_add_activities(sch, id, name, duration, ...)

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.

...

One or more vectors for associated activity attributes.

Value

A schedule with a activity tibble (atb) added.

Details

A activity tibble, or atb, has at least the following columns:

  • id (of type integer): Activity id. It is an integer number that must be unique within a schedule.

  • name (of type character): Activity name. It may be empty string.

  • duration (of type integer): Activity duration. It is integer number without unit time. It may be zero.

An arbitrary number of additional columns containing data attributes can be part of the atb, so long as they follow the aforementioned columns.

See Also

sch_reference(), sch_add_relations(), sch_add_activity(), sch_title(), sch_nr_activities(), sch_new(), sch_plan(), sch_get_activity(), sch_has_any_activity(), sch_change_activities_duration().

Examples

Run this code
# NOT RUN {
# Example #1
sch <- sch_new() %>%
  sch_add_activities(
    id        = 1:17,
    name      = paste("a", as.character(1:17), sep=""),
    duration  = c(1L,2L,2L,4L,3L,3L,3L,2L,1L,1L,2L,1L,1L,1L,1L,2L,1L)
  ) %>%
  sch_plan()
sch_duration(sch)
sch_activities(sch)

# Example #2
sch <- sch_new() %>%
  sch_add_activities(
    id        = 1:17,
    name      = paste("a", as.character(1:17), sep=""),
    duration  = c(1L,2L,2L,4L,3L,3L,3L,2L,1L,1L,2L,1L,1L,1L,1L,2L,1L),
    resource  = "Rubens",
    cost      = 123.45
  ) %>%
  sch_plan()
sch_duration(sch)
atb <- sch_activities(sch)
atb$resource
atb$cost

# Example #3
sch <- sch_new() %>%
  sch_add_activities(
    id        = 1:17,
    name      = paste("a", as.character(1:17), sep=""),
    duration  = c(1L,2L,2L,4L,3L,3L,3L,2L,1L,1L,2L,1L,1L,1L,1L,2L,1L),
    resource  = c(
      "Rubens", "Jose", "Rosa", "Rodrigues", "Silva",
      "Rubens", "Jose", "Rosa", "Rodrigues", "Silva",
      "Rubens", "Jose", "Rosa", "Rodrigues", "Silva",
      "Rubens", "Jose"),
    cost      = c(
      123.45, 234.56, 345.56, 456.78, 567.89,
      123.45, 234.56, 345.56, 456.78, 567.89,
      123.45, 234.56, 345.56, 456.78, 567.89,
      123.45, 234.56)
  ) %>%
  sch_plan()
sch_duration(sch)
atb <- sch_activities(sch)
atb$resource
atb$cost

# }

Run the code above in your browser using DataLab