quadrama / DramaAnalysis

An R package for analysis of dramatic texts
GNU General Public License v3.0
15 stars 2 forks source link

Add functions to extract the first or last scenes or acts #37

Closed nilsreiter closed 7 years ago

nilsreiter commented 7 years ago

Add functions head() and tail() to get the first/last n acts or scenes

nilsreiter commented 7 years ago

Implementation for the very last act/scene:

tail <- function(input, by="act") {
  if (by == "act") {
    input[,.SD[begin.Act == max(begin.Act)],.(corpus,drama)][]
  } else if (by == "scene") {
    input[,.SD[begin.Scene == max(begin.Scene)],.(corpus,drama)][]
  }
}