#' Fit Curve
#'
#' @param x
#' @param mode
#' @param config
#'
#' @return
#' @export
#'
#' @examples
fit.curve <- function(x, mode = 'fit.smooth', config) {
# Ver 3.1
curve <- NULL
if (mode == 'fit.norm') {
para <-
c(config$mu1, config$sigma1, config$k1, config$a, config$b)
curve <- fit.norm(x, para = para)
} else if (mode == 'fit.smooth') {
curve <- fit.smooth(x)
} else if (mode == 'fit.2norm') {
para <- c(
config$mu1, config$sigma1, config$k1,
config$mu2, config$sigma2, config$k2,
config$a, config$b
)
curve <- fit.2norm(x, para = para)
} else {
cat('curve fit model does not exist\n')
return(NULL)
}
# return NULL if no peaks or no velleys
if (is.null(curve)) {
warning('Curve not fit\n')
return(NULL)
} else {
return(curve)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.