blob: e4f7e54ca5d2486464a7de29d989d46f2d869af0 [file] [log] [blame]
Marc Kupietzdcc1de62019-10-04 09:10:36 +02001% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/ci.R
3\name{ci}
4\alias{ci}
5\title{Add confidence interval and relative frequency variables}
6\usage{
7ci(df, x = totalResults, N = tokens, conf.level = 0.95)
8}
9\arguments{
10\item{df}{table with columns for absolute and total frequencies.}
11
12\item{x}{column with the observed absolute frequency.}
13
14\item{N}{column with the total frequncies}
15
16\item{conf.level}{confidence level of the returned confidence interval. Must
17be a single number between 0 and 1.}
18}
19\description{
20Using \code{\link{prop.test}}, \code{ci} adds three columns to a data frame:
211. relative frequency (\code{f}) 2. lower bound of a confidence interval
22(\code{ci.low}) 3. upper bound of a confidence interval
23}
24\examples{
25library(ggplot2)
26kco <- new("KorAPConnection", verbose=TRUE)
27expand_grid(year=2015:2018, alternatives=c("Hate Speech", "Hatespeech")) \%>\%
28 bind_cols(corpusQuery(kco, .$alternatives, sprintf("pubDate in \%d", .$year))) \%>\%
29 mutate(tokens=corpusStats(kco, vc=vc)$tokens) \%>\%
30 ci() \%>\%
31 ggplot(aes(x=year, y=f, fill=query, color=query, ymin=conf.low, ymax=conf.high)) +
32 geom_point() + geom_line() + geom_ribbon(alpha=.3)
33
34}