| ci | R Documentation |
Using prop.test(), ci adds three columns to a data frame:
relative frequency (f)
lower bound of a confidence interval (ci.low)
upper bound of a confidence interval
Convenience function for converting frequency tables to instances per million.
Convenience function for converting frequency tables of alternative variants
(generated with as.alternatives=TRUE) to percent.
Converts a vector of query or vc strings to typically appropriate legend labels by clipping off prefixes and suffixes that are common to all query strings.
Experimental convenience function for plotting typical frequency by year graphs with confidence intervals using ggplot2. Warning: This function may be moved to a new package.
ci(df, x = totalResults, N = total, conf.level = 0.95)
ipm(df)
percent(df)
queryStringToLabel(data, pubDateOnly = FALSE, excludePubDate = FALSE)
geom_freq_by_year_ci(
mapping = aes(ymin = conf.low, ymax = conf.high),
showCI = TRUE,
smooth = FALSE,
...
)
df |
table returned from |
x |
column with the observed absolute frequency. |
N |
column with the total frequencies |
conf.level |
confidence level of the returned confidence interval. Must be a single number between 0 and 1. |
data |
string or vector of query or vc definition strings |
pubDateOnly |
discard all but the publication date |
excludePubDate |
discard publication date constraints |
mapping |
Set of aesthetic mappings created by aes() or aes_(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping. |
showCI |
Show confidence bands (default TRUE). FALSE retains only the frequency curves and points and does not require interval bounds. |
smooth |
Draw curved connections between annual observations (default FALSE). Uses natural cubic spline interpolation within each group and facet, on the plot's transformed scales. Missing values and missing calendar years break the curves. Points remain at the observed years. |
... |
Other arguments passed to geom_ribbon, geom_line, and geom_click_point. |
Given a table with columns f, conf.low, and conf.high, ipm ads a column ipm
und multiplies conf.low and conf.high with 10^6.
With smooth = TRUE, map numeric calendar years to x and frequency to y.
Interpolation is only a display aid, not a fitted trend or a trend test.
Confidence-band boundaries are interpolated between the supplied annual
limits; they are not confidence intervals for unobserved dates. Observed
annual values and limits are retained. As with other ggplot2 statistics,
interpolation follows the axis scales, including logarithmic scales.
Cubic curves can overshoot between annual values; use straight connections
when the exact shape matters. Negative interpolated frequencies are clipped
at zero (on a log axis, zero is outside the displayed range).
Each group needs at most one observation per year; use colour, fill or group
to distinguish expressions or corpora. No extrapolation is performed.
The interpolation used by Highcharts may give a different curve between
the same annual observations.
original table with additional column ipm and converted columns conf.low and conf.high
original table with converted columns f, conf.low and conf.high
string or vector of strings with clipped off common prefixes and suffixes
ci is already included in frequencyQuery()
## Not run:
library(ggplot2)
kco <- KorAPConnection(verbose=TRUE)
expand_grid(year=2015:2018, alternatives=c("Hate Speech", "Hatespeech")) %>%
bind_cols(corpusQuery(kco, .$alternatives, sprintf("pubDate in %d", .$year))) %>%
mutate(total=corpusStats(kco, vc=vc)$tokens) %>%
ci() %>%
ggplot(aes(x=year, y=f, fill=query, color=query, ymin=conf.low, ymax=conf.high)) +
geom_point() + geom_line() + geom_ribbon(alpha=.3)
## End(Not run)
## Not run:
KorAPConnection() %>% frequencyQuery("Test", paste0("pubDate in ", 2000:2002)) %>% ipm()
## End(Not run)
## Not run:
KorAPConnection() %>%
frequencyQuery(c("Tollpatsch", "Tolpatsch"),
vc=paste0("pubDate in ", 2000:2002),
as.alternatives = TRUE) %>%
percent()
## End(Not run)
queryStringToLabel(paste("textType = /Zeit.*/ & pubDate in", c(2010:2019)))
queryStringToLabel(c("[marmot/m=mood:subj]", "[marmot/m=mood:ind]"))
queryStringToLabel(c("wegen dem [tt/p=NN]", "wegen des [tt/p=NN]"))
## Not run:
library(ggplot2)
kco <- KorAPConnection(verbose=TRUE)
expand_grid(condition = c("idsColumn = /Wirtschaft.*/", "idsColumn != /Wirtschaft.*/"),
year = (2005:2011)) %>%
cbind(frequencyQuery(kco, "[tt/l=Heuschrecke]",
paste0(.$condition," & pubDate in ", .$year))) %>%
ipm() %>%
ggplot(aes(year, ipm, fill = condition, color = condition)) +
geom_freq_by_year_ci()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.