0

here is my contrived dataset/logic to plot markovchain

sequences <- list(
      c("Opened", "2709342", "END"),
      c("Opened", "3067630", "END")
    )

    sequencesMarkovchainFit <- function(sequences){
      # Create a continuous sequence string with each sequence having START and END
      #
      # sequences <- list( c("A"),
      #                    c("B"))
      # sequence = c("START", "A", "END", "START", "B", "END" ...)
      sequence <- c ()
      for (i in 1:length(sequences)){
        #sequence <- c(sequence, "START", unlist(sequences[i]), "END")
        sequence <- c(sequence, "START", unlist(sequences[i]))
      }
      fit <- markovchainFit(data=sequence)
      chain <- as(fit$estimate, "markovchain")
      return(chain)
    }

    sequencesMC <- sequencesMarkovchainFit(sequences)

    plot(sequencesMC, main="Selected Sequences T (transition matrix)")

and the resulting plot still has the indices (i.e. 0,1,2..) instead of the desired states (names)

plot of markovchain after creating with markovchainFit

Susol
  • 1
  • 2
  • I've tagged this question `r` because in my experience questions with `<-` in the code and no mention of the programming language used tend to be R related. If I'm wrong, please remove it :-) – melpomene May 07 '18 at 18:27
  • oh sorry, thanks. Yes it's R code. – Susol May 07 '18 at 19:55
  • When I run your code, I get the labels "START", "Opened", "2709342", "3067630", "END" Not the numbers that you show. – G5W May 14 '18 at 00:10
  • my apologies...in Rstudio, yes this works. I am actually deploying this in Google's colab – Susol May 15 '18 at 16:30

0 Answers0