Add convenience function for conversion to ipm

Change-Id: I2b9138322558fc1a2da2f9877cefe3d2268d2412
diff --git a/DESCRIPTION b/DESCRIPTION
index c39776f..5e2ddf4 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -31,4 +31,5 @@
     'RKorAPClient.R'
     'KorAPQuery.R'
     'ci.R'
+    'misc.R'
     'reexports.R'
diff --git a/NAMESPACE b/NAMESPACE
index 4c3ff8f..bb3fd5f 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -7,7 +7,9 @@
 export(ci)
 export(complete)
 export(expand_grid)
+export(geom_freq_by_year_ci)
 export(group_by)
+export(ipm)
 export(mutate)
 export(select)
 export(summarise)
@@ -31,6 +33,7 @@
 import(methods)
 import(utils)
 importFrom(broom,tidy)
+importFrom(dplyr,.data)
 importFrom(dplyr,bind_cols)
 importFrom(dplyr,bind_rows)
 importFrom(dplyr,enquo)
diff --git a/R/misc.R b/R/misc.R
new file mode 100644
index 0000000..50b8821
--- /dev/null
+++ b/R/misc.R
@@ -0,0 +1,24 @@
+
+#' Convert corpus frequency table to instances per million.
+#'
+#' Convenience function for converting frequency tables to instances per
+#' million.
+#'
+#' Given a table with columns \code{f}, \code{conf.low}, and \code{conf.high}, \code{ipm} ads a \code{column ipm}
+#' und multiplies conf.low and \code{conf.high} with 10^6.
+#'
+#' @param df table returned from \code{\link{frequencyQuery}}
+#'
+#' @return original table with additional column \code{ipm} and converted columns \code{conf.low} and \code{conf.high}
+#' @export
+#'
+#' @importFrom dplyr .data
+#'
+#' @examples
+#' new("KorAPConnection") %>% frequencyQuery("Test", paste0("pubDate in ", 2000:2002)) %>% ipm()
+ipm <- function(df) {
+  df %>%
+    mutate(ipm = .data$f * 10^6, conf.low = .data$conf.low * 10^6, conf.high = .data$conf.high * 10^6)
+}
+
+
diff --git a/man/ipm.Rd b/man/ipm.Rd
new file mode 100644
index 0000000..ed82d36
--- /dev/null
+++ b/man/ipm.Rd
@@ -0,0 +1,25 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/misc.R
+\name{ipm}
+\alias{ipm}
+\title{Convert corpus frequency table to instances per million.}
+\usage{
+ipm(df)
+}
+\arguments{
+\item{df}{table returned from \code{\link{frequencyQuery}}}
+}
+\value{
+original table with additional column \code{ipm} and converted columns \code{conf.low} and \code{conf.high}
+}
+\description{
+Convenience function for converting frequency tables to instances per
+million.
+}
+\details{
+Given a table with columns \code{f}, \code{conf.low}, and \code{conf.high}, \code{ipm} ads a \code{column ipm}
+und multiplies conf.low and \code{conf.high} with 10^6.
+}
+\examples{
+new("KorAPConnection") \%>\% frequencyQuery("Test", paste0("pubDate in ", 2000:2002)) \%>\% ipm()
+}