Skip to content

Commit

Permalink
rename plot function and use geoms
Browse files Browse the repository at this point in the history
  • Loading branch information
bvreede committed Jan 9, 2024
1 parent e1f4ba3 commit a6213f3
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 33 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export(GeomToken)
export(GeomTurn)
export(init)
export(inspect_language)
export(plot_convo_lines)
export(plot_quality)
export(plot_turns_tokens)
export(report_stats)
export(theme_turnPlot)
export(tokenize)
Expand Down
32 changes: 0 additions & 32 deletions R/plot_conversation.R

This file was deleted.

38 changes: 38 additions & 0 deletions R/plot_turns_tokens.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#' Plot conversation
#'
#' @param data a talkr dataset
#' @param source a sourcename to extract; default is NULL, then the first source will be picked
#'
#' @return plot object
#' @export
plot_turns_tokens <- function(data, sourcecount = 1){
check_talkr(data)

Check warning on line 9 in R/plot_turns_tokens.R

View check run for this annotation

Codecov / codecov/patch

R/plot_turns_tokens.R#L9

Added line #L9 was not covered by tests

window_length = 60 * 1000 # one minute, in milliseconds. The duration of a single line.

Check warning on line 11 in R/plot_turns_tokens.R

View check run for this annotation

Codecov / codecov/patch

R/plot_turns_tokens.R#L11

Added line #L11 was not covered by tests

sourcecount <- max(sourcecount, length(unique(data$source)))
source <- unique(data$source)[sourcecount]

Check warning on line 14 in R/plot_turns_tokens.R

View check run for this annotation

Codecov / codecov/patch

R/plot_turns_tokens.R#L13-L14

Added lines #L13 - L14 were not covered by tests

data <- data[data$source == source,]
data <- data[data$end < window_length,]

Check warning on line 17 in R/plot_turns_tokens.R

View check run for this annotation

Codecov / codecov/patch

R/plot_turns_tokens.R#L16-L17

Added lines #L16 - L17 were not covered by tests

tokens <- data |>
tokenize()

Check warning on line 20 in R/plot_turns_tokens.R

View check run for this annotation

Codecov / codecov/patch

R/plot_turns_tokens.R#L19-L20

Added lines #L19 - L20 were not covered by tests

p <- data |>
ggplot2::ggplot(aes(x = end, y = participant)) +
talkr::geom_turn(aes(
begin = begin,
end = end)) +
talkr::geom_token(data = tokens,
aes(x = relative_time,
y = participant)) +
talkr::theme_turnPlot() +
ggplot2::xlab("time (ms)") +
ggplot2::ggtitle(source)

Check warning on line 32 in R/plot_turns_tokens.R

View check run for this annotation

Codecov / codecov/patch

R/plot_turns_tokens.R#L22-L32

Added lines #L22 - L32 were not covered by tests


return(p)

Check warning on line 35 in R/plot_turns_tokens.R

View check run for this annotation

Codecov / codecov/patch

R/plot_turns_tokens.R#L35

Added line #L35 was not covered by tests
}


19 changes: 19 additions & 0 deletions man/plot_turns_tokens.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a6213f3

Please sign in to comment.