Marc Kupietz | bb7d232 | 2019-10-06 21:42:34 +0200 | [diff] [blame^] | 1 | |
| 2 | #' Convert corpus frequency table to instances per million. |
| 3 | #' |
| 4 | #' Convenience function for converting frequency tables to instances per |
| 5 | #' million. |
| 6 | #' |
| 7 | #' Given a table with columns \code{f}, \code{conf.low}, and \code{conf.high}, \code{ipm} ads a \code{column ipm} |
| 8 | #' und multiplies conf.low and \code{conf.high} with 10^6. |
| 9 | #' |
| 10 | #' @param df table returned from \code{\link{frequencyQuery}} |
| 11 | #' |
| 12 | #' @return original table with additional column \code{ipm} and converted columns \code{conf.low} and \code{conf.high} |
| 13 | #' @export |
| 14 | #' |
| 15 | #' @importFrom dplyr .data |
| 16 | #' |
| 17 | #' @examples |
| 18 | #' new("KorAPConnection") %>% frequencyQuery("Test", paste0("pubDate in ", 2000:2002)) %>% ipm() |
| 19 | ipm <- function(df) { |
| 20 | df %>% |
| 21 | mutate(ipm = .data$f * 10^6, conf.low = .data$conf.low * 10^6, conf.high = .data$conf.high * 10^6) |
| 22 | } |
| 23 | |
| 24 | |