Skip to content

Commit

Permalink
Split up some parts of the configuration function as configuration.in…
Browse files Browse the repository at this point in the history
…t() #62
  • Loading branch information
Nils Reiter committed Nov 4, 2017
1 parent 055e94e commit c3e89ca
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions R/configuration.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ configuration <- function(mtext,
if (mode == "Passive") {
words.per.segment <- na.omit(words.per.segment)
}
cfg <- stats::reshape(words.per.segment, direction="wide",
idvar = c("corpus","drama","characterColumn"),
timevar = "segmentColumn")

cfg[is.na(cfg)] <- 0
cfg <- configuration.int(t, characterColumn, segmentColumn, ifelse(mode=="Passive",na.omit,identity))
colnames(cfg)[3:(ncol(cfg))] <- c("figure",seq(1,ncol(cfg)-3))

if (onlyPresence) {
Expand All @@ -77,3 +73,14 @@ configuration <- function(mtext,
}
}

configuration.int <- function(t, characterColumn, segmentColumn, postFun=identity) {
words.per.segment <- postFun(t[,.N,.(corpus,drama, eval(characterColumn), eval(segmentColumn))])

cfg <- stats::reshape(words.per.segment, direction="wide",
idvar = c("corpus","drama","characterColumn"),
timevar = "segmentColumn")

cfg[is.na(cfg)] <- 0

cfg
}

0 comments on commit c3e89ca

Please sign in to comment.