title: Access transition matrix from markovchainFit object
body: <p>I want to first calculate a markov transition matrix and then take exponent of it. To achieve the first goal I use the <code>markovchainFit</code> function inside <code>markovchain</code> package and it return me a data.frame , rather than a matrix. So I need to convert it to matrix before I take exponent.
  My R code snippet is like</p>
  
  <pre><code>#################################
  #  Estimate Transition Matrix   #
  #################################
  setwd("G:/Data_backup/GDP_per_Capita")
  
  library("foreign")
  library("Hmisc")
  mydata &lt;- stata.get("G:/Data_backup/GDP_per_Capita/states.dta")
  mydata
  
  library(markovchain)
  library(expm)
  
  rgdp_e=mydata[,2:7]
  rgdp_o=mydata[,8:13]
  createSequenceMatrix(rgdp_e)
  rgdp_e_trans&lt;-markovchainFit(data=rgdp_e,,method="bootstrap",nboot=5, name="Bootstrap Mc")
  rgdp_e_trans&lt;-as.numeric(unlist(rgdp_e_trans))
  rgdp_e_trans&lt;-as.matrix(rgdp_e_trans)
  is.matrix(rgdp_e_trans)
  rgdp_e_trans %^% 1/5
  </code></pre>
  
  <p>the <code>rgdp_e_trans</code> is a data frame, and I try to convert it to a numeric matrix. It seems work when I test it using <code>is.matrix</code> command. However, the final line give me an error said</p>
  
  <pre><code>Error in rgdp_e_trans %^% 2 : 
    (list) object cannot be coerced to type 'double'
  </code></pre>
  
  <p>After some searching work in stackoverflow, I find <a href="https://stackoverflow.com/questions/12384071/how-to-coerce-a-list-object-to-type-double">this question</a> sharing the similar problem and use <code>rgdp_e_trans&lt;-as.numeric(unlist(rgdp_e_trans))</code> to coerce the object to be `double', but it seems not work.
  Besides, the data.frame rgdp_e_trans contains no factor or characters
  The output in the console is like</p>
  
  <pre><code>&gt; rgdp_e=mydata[,2:7]
  &gt; rgdp_o=mydata[,8:13]
  &gt; createSequenceMatrix(rgdp_e)
  Error: not compatible with STRSXP
  &gt; rgdp_e_trans&lt;-markovchainFit(data=rgdp_e,,method="bootstrap",nboot=5, name="Bootstrap Mc")
  &gt; rgdp_e_trans
  $estimate
            1          2          3           4          5
  1 0.6172840 0.18930041 0.09053498 0.074074074 0.02880658
  2 0.1125828 0.59602649 0.28476821 0.006622517 0.00000000
  3 0.0000000 0.03846154 0.60256410 0.358974359 0.00000000
  4 0.0000000 0.01162791 0.03488372 0.691860465 0.26162791
  5 0.0000000 0.00000000 0.00000000 0.044247788 0.95575221
  
  
  &gt; rgdp_e_trans&lt;-as.numeric(unlist(rgdp_e_trans))
  Error: (list) object cannot be coerced to type 'double'
  &gt; rgdp_e_trans&lt;-as.matrix(rgdp_e_trans)
  &gt; is.matrix(rgdp_e_trans)
  [1] TRUE
  &gt; rgdp_e_trans %^% 1/5
  Error in rgdp_e_trans %^% 1 : 
    (list) object cannot be coerced to type 'double'
  &gt; 
  </code></pre>
  
  <p>Any suggestion to fix the problem, or alternative way to calculate the exponent ? Thank you.</p>
  
  <hr>
  
  <p>Additional：</p>
  
  <pre><code>&gt; str(rgdp_e_trans)
  List of 1
   $ estimate:Formal class 'markovchain' [package "markovchain"] with 4 slots
    .. ..@ states          : chr [1:5] "1" "2" "3" "4" ...
    .. ..@ byrow           : logi TRUE
    .. ..@ transitionMatrix: num [1:5, 1:5] 0.617 0.113 0 0 0 ...
    .. .. ..- attr(*, "dimnames")=List of 2
    .. .. .. ..$ : chr [1:5] "1" "2" "3" "4" ...
    .. .. .. ..$ : chr [1:5] "1" "2" "3" "4" ...
    .. ..@ name            : chr "Bootstrap Mc"
  </code></pre>
  
  <p>and I comment out the as.matrix part</p>
  
  <pre><code>rgdp_e=mydata[,2:7]
  rgdp_o=mydata[,8:13]
  createSequenceMatrix(rgdp_e)
  rgdp_e_trans&lt;-markovchainFit(data=rgdp_e,,method="bootstrap",nboot=5, name="Bootstrap Mc")
  rgdp_e_trans
  str(rgdp_e_trans)
  # rgdp_e_trans&lt;-as.numeric(unlist(rgdp_e_trans))
  # rgdp_e_trans&lt;-as.matrix(rgdp_e_trans)
  # is.matrix(rgdp_e_trans)
  rgdp_e_trans$estimate %^% 1/5
  </code></pre>