View source: R/epi_clean_spread_repeated.R
epi_clean_spread_repeated | R Documentation |
Create a single data frame with unique rows (individuals) and repeated observations across columns. A column with the replicate/repeated observation/time-point number for each row must be provided.
epi_clean_spread_repeated(df = NULL, rep_col = "", id_col_num = 1)
df |
A dataframe in long format |
rep_col |
Column index or string to use to base spread on. |
id_col_num |
Column index with ID values. Default is 1. |
a nested list with as many sub-lists as unique values contained in the
column passed as rep_col. Column headers are renamed using
epi_clean_add_colname_suffix
and will contain suffixes taken from
the unique values in rep_col.
The ID column passed as id_col_num is included in each sub-list.
Antonio Berlanga-Taylor <\url{https://github.com/AntonioJBT/episcout}>
epi_clean_add_colname_suffix
, epi_clean_merge_nested_dfs
,
epi_clean_transpose
## Not run:
n <- 20
df <- data.frame(
var_id = rep(1:(n / 2), each = 2),
var_to_rep = rep(c('Pre', 'Post'), n / 2),
x = rnorm(n),
y = rbinom(n, 1, 0.50),
z = rpois(n, 2)
)
df
df_spread <- epi_clean_spread_repeated(df, 'var_to_rep', 1)
# Returns a nested list:
df_spread
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.