#' Table of Scores for the New Sequence
#'
#' @param regseqscore Regular sequence scores.
#' @param newseq New sequence to be tested.
#' @param seqlist List of sequences separated by time window.
#' @param allsqs Matrix containing all the possible SQS for the possible categories.
#' @param newsqsindex Index Matrix indicating whether the new sequence has certain SQS's.
#' @param sqsindex Index Matrix indicating which regular sequences have which SQS's.
#' @param catvec Vector of the different categories found in the sequences.
#' @param probabilities Estimated proportion of each category seen in the sequences.
#' @param k Maximum length of sequence silhouette.
#' @param beta Score parameter.
#' @param lam Score parameter.
#'
#' @return Table of scores for the new sequence.
#' @export
#'
#' @examples
#' df<-data.frame(Time=c("2020-01-01 00:10:09", "2020-01-01 01:12:34" , "2020-01-02 06:38:09",
#' "2020-01-02 07:21:51"),Cat=c('A','B','A','C'))
#' newdf<-data.frame(Time=c("2020-01-03 01:30:20", "2020-01-03 04:19:14" , "2020-01-03 06:51:29"),
#' Cat=c('A','B','A'))
#' #For daily data:
#' seqlist<-SeqList(df,'%Y-%m-%d')
#' sqslist<-SQSList(seqlist,2)
#' newseqlist<-SeqList(newdf,'%Y-%m-%d')
#' newsqslist<-SQSList(newseqlist,2)
#' allsqs<-AllSQS(c('A','B','C'),2)
#' sqsindex<-SQSIndex(allsqs,sqslist)
#' newsqsindex<-SQSIndex(allsqs,newsqslist)
#' regseqscore<-RegSeqScore(seqlist,allsqs,sqsindex,c('A','B','C'),c(0.5,0.25,0.25),2,1,0.5)
#' ScoreTable(regseqscore, newseqlist[[1]], seqlist, allsqs, newsqsindex, sqsindex,
#' c('A','B','C'),c(0.5,0.25,0.25), 2, 1, 0.5)
ScoreTable <- function(regseqscore, newseq, seqlist, allsqs, newsqsindex, sqsindex, catvec, probabilities, k, beta, lam) {
lengthofregset <- length(seqlist)
Newseqscore <- TestSeqScore(newseq, seqlist, allsqs, newsqsindex, sqsindex, catvec, probabilities, k, beta, lam)
RegScores <- (regseqscore[[1]] - regseqscore[[2]]) / (regseqscore[[3]] - regseqscore[[2]])
NewSeq <- (Newseqscore[[1]] - Newseqscore[[2]]) / (Newseqscore[[3]] - Newseqscore[[2]])
timeseq <- paste0("Day", 1:(lengthofregset + 1))
GamTable <- as.data.frame(cbind(RegScores, NewSeq))
colnames(GamTable) <- timeseq
TableincDif <- dplyr::mutate(GamTable, Difference = allsqs[, 3], SQS = paste0(allsqs[, 1], allsqs[, 2], allsqs[, 3]))
return(TableincDif)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.