text: user6829: I am following an example from ‘Analysis of Phylogenetics Second Edition and Evolution with R’ from Emmanuel Paradis.
  He is doing:
  
  I am doing pretty much the same:
  x=c('garras','garras','garras', 'tejido','tejido','tejido')
  y <- phyDat(matrix(x), "USER", levels = unique(x))
  
  but I get:
  
  Error in phyDat.default(data, levels = levels, return.index =
  return.index, : data object must contain taxa names
  
  Screenshot:
  
  What am I doing wrong? how come the example from the book works...
  
  user5077: I cannot access the book, it might be an older version or there are some steps in between. The screen shot doesn't help.
  If you look at the vignette and the error, what you need to provide is a matrix of characters with defined row names, for example:
  set.seed(111)
  x = sample(letters,100,replace=TRUE)
  phyDat(matrix(x),"USER",levels=unique(x))
  
  Error in phyDat.default(data, levels = levels, return.index = return.index,  : 
    data object must contain taxa names
  
  mat = matrix(x,10,10,dimnames=list(paste0("t",1:10),NULL))
  phyDat(mat,"USER",levels=unique(x))
  10 sequences with 10 character and 10 different site patterns.
  The states are n t s o y e c h z q m j d o h n z y x p q g u o a i h y c g t d f y t d f e u e f d i j r z x w u m a j p j g d t q y v o x p m s o z x z a y j z r u s a y k l f g l f r i l r f m t t e f x v f g q j 
  
  
original_text: 6829: <p>I am following an example from ‘Analysis of Phylogenetics Second Edition and Evolution with R’ from Emmanuel Paradis.</p>
  <p>He is doing:</p>
  <p><a href="https://i.stack.imgur.com/7uTVB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7uTVB.png" alt="enter image description here" /></a></p>
  <p>I am doing pretty much the same:</p>
  <pre><code>x=c('garras','garras','garras', 'tejido','tejido','tejido')
  y &lt;- phyDat(matrix(x), &quot;USER&quot;, levels = unique(x))
  </code></pre>
  <p>but I get:</p>
  <blockquote>
  <p>Error in phyDat.default(data, levels = levels, return.index =
  return.index, : data object must contain taxa names</p>
  </blockquote>
  <p>Screenshot:</p>
  <p><a href="https://i.stack.imgur.com/bIRKC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bIRKC.png" alt="enter image description here" /></a></p>
  <p>What am I doing wrong? how come the example from the book works...</p>
   5077: <p>I cannot access the book, it might be an older version or there are some steps in between. The screen shot doesn't help.</p>
  <p>If you look at the <a href="https://cran.r-project.org/web/packages/phangorn/vignettes/phangorn-specials.pdf" rel="nofollow noreferrer">vignette</a> and the error, what you need to provide is a matrix of characters with defined row names, for example:</p>
  <pre><code>set.seed(111)
  x = sample(letters,100,replace=TRUE)
  phyDat(matrix(x),&quot;USER&quot;,levels=unique(x))
  
  Error in phyDat.default(data, levels = levels, return.index = return.index,  : 
    data object must contain taxa names
  
  mat = matrix(x,10,10,dimnames=list(paste0(&quot;t&quot;,1:10),NULL))
  phyDat(mat,&quot;USER&quot;,levels=unique(x))
  10 sequences with 10 character and 10 different site patterns.
  The states are n t s o y e c h z q m j d o h n z y x p q g u o a i h y c g t d f y t d f e u e f d i j r z x w u m a j p j g d t q y v o x p m s o z x z a y j z r u s a y k l f g l f r i l r f m t t e f x v f g q j 
  </code></pre>
  