Description Usage Arguments Value References See Also Examples
Produce a tbl_df
data frame of repeated measures from a
wakefield variable function.
1 |
fun |
A wakefield variable function. |
j |
The number of columns to produce. |
n |
The number of rows to produce. |
integer |
logical. If |
relate |
Allows the user to specify the relationship between columns.
May be a named list of |
rep.sep |
A separator to use for repeated variable names. For example
if the |
... |
Additional arguments passed to |
Returns a tbl_df
.
https://github.com/trinker/wakefield/issues/1/#issuecomment-96166910
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | r_series(grade, 5, 10)
## Custom name prefix
r_series(likert, 5, 10, name = "Question")
## Convert factors to integers
r_series(likert_7, 5, 10, integer = TRUE)
## Related variables
r_series(likert, 10, 200, relate = list(operation = "*", mean = 2, sd = 1))
r_series(likert, 10, 200, relate = "--3_1")
r_series(age, 10, 200, relate = "+5_0")
## Change sd to reduce/increase correlation
round(cor(r_series(grade, 10, 10, relate = "+1_2")), 2)
round(cor(r_series(grade, 10, 10, relate = "+1_0")), 2)
round(cor(r_series(grade, 10, 10, relate = "+1_.5")), 2)
round(cor(r_series(grade, 10, 10, relate = "+1_20")), 2)
## Plot Example 1
library(dplyr); library(ggplot2)
dat <- r_data_frame(12,
name,
r_series(likert, 10, relate = "+1_.5")
)
# Suggested use of tidyr or reshape2 package here instead
dat <- data.frame(
ID = rep(dat[[1]], ncol(dat[-1])),
stack(dat[-1])
)
dat[["Time"]] <- factor(sub("Variable_", "", dat[["ind"]]), levels = 1:10)
ggplot(dat, aes(x = Time, y = values, color = ID, group = ID)) +
geom_line(size=.8)
## Plot Example 2
dat <- r_data_frame(12,
name,
r_series(grade, 100, relate = "+1_2")
)
# Suggested use of tidyr or reshape2 package here instead
dat <- data.frame(
ID = rep(dat[[1]], ncol(dat[-1])),
ind = rep(colnames(dat[-1]), each = nrow(dat)),
values = unlist(dat[-1])
)
dat[["Time"]] <- as.numeric(sub("Grade_", "", dat[["ind"]]))
ggplot(dat, aes(x = Time, y = values, color = ID, group = ID)) +
geom_line(size=.8) + theme_bw()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.