Skip to content

Instantly share code, notes, and snippets.

@JoFrhwld
Last active October 7, 2015 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoFrhwld/0b0f69ca1a341f38f275 to your computer and use it in GitHub Desktop.
Save JoFrhwld/0b0f69ca1a341f38f275 to your computer and use it in GitHub Desktop.
list2fd <- function(list, basis){
if(class(list[[1]]) == "fdSmooth"){
coef_list <- lapply(list, function(x)x$fd$coefs)
}else if(class(list[[1]]) == "fd"){
coef_list <- lapply(list, function(x)x$coefs)
}
n_coefs <- unlist(lapply(coef_list, length))
if(!all(n_coefs == max(n_coefs))) stop()
coef_mat <- matrix(unlist(coef_list), nrow = max(n_coefs))
out_fd <- fd(coef_mat, basis)
return(out_fd)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment