split_speaker: Break and Stretch if Multiple Persons per Cell

split_speakerR Documentation

Break and Stretch if Multiple Persons per Cell

Description

Look for cells with multiple people and create separate rows for each person.

Usage

split_speaker(dataframe, speaker.var = 1, sep = c("and", "&", ","), ...)

Arguments

dataframe

A dataframe that contains the person variable.

speaker.var

The person variable to be stretched.

sep

The separator(s) to search for and break on. Default is: c("and", "&", ",")

...

Ignored.

Value

Returns an expanded dataframe with person variable stretched and accompanying rows repeated.

Examples

## Not run: 
DATA$person <- as.character(DATA$person)
DATA$person[c(1, 4, 6)] <- c("greg, sally, & sam",
    "greg, sally", "sam and sally")

split_speaker(DATA)

DATA$person[c(1, 4, 6)] <- c("greg_sally_sam",
    "greg.sally", "sam; sally")

split_speaker(DATA, sep = c(".", "_", ";"))

DATA <- textshape::DATA  #reset DATA

## End(Not run)

trinker/textshape documentation built on April 5, 2024, 11:39 a.m.