#' Go through all observations in the matrix and list them
#' in a 'long' style
#' @noRd
# @export
fc.wide2long = function(X, time = NULL, ids = NULL, value = "value")
{
# TODO: This function should be optimized
if (is.null(time))
time = as.numeric(colnames(X))
if (is.null(ids))
ids = rownames(X)
long = data.frame(id = c(), time = c(), value=c())
for (i in 1:length(ids)){
observed = X[i,!is.na(X[i,])]
id = rep(ids[i], length(observed))
tm = time[!is.na(X[i,])]
toadd = data.frame(id=id,
time=tm,
value=observed)
long = rbind(long,toadd)
}
rownames(long) = NULL
colnames(long)[3] = value
long
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.