View source: R/distribution_convertors.R
norm2likert | R Documentation |
Convert normal to likert
norm2likert(x, prob, labels = names(prob), mu = mean(x), sd = stats::sd(x))
x |
the normally distributed vector |
prob |
a vector of probabilities or counts; if named, the output is a factor |
labels |
a vector of values, defaults to names(prob) or 1:length(prob), if numeric, the output is numeric |
mu |
the mean of x (calculated from x if not given) |
sd |
the SD of x (calculated from x if not given) |
a vector with the specified distribution
x <- rnorm(10000)
y <- norm2likert(x, c(.1, .2, .35, .2, .1, .05))
g <- ggplot2::ggplot() + ggplot2::geom_point(ggplot2::aes(x, y))
ggExtra::ggMarginal(g, type = "histogram")
y <- norm2likert(x, c(40, 30, 20, 10))
g <- ggplot2::ggplot() + ggplot2::geom_point(ggplot2::aes(x, y))
ggExtra::ggMarginal(g, type = "histogram")
y <- norm2likert(x, c(lower = .5, upper = .5))
g <- ggplot2::ggplot() + ggplot2::geom_point(ggplot2::aes(x, y))
ggExtra::ggMarginal(g, type = "histogram")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.