title: How can I calculate cosine similarity between first row of my matrix with each other rows in R?
body: <p>this is my_matrix :</p>
  
  <pre><code>ui 194635691 194153563 177382028 177382031 195129144 196972549 196258704   194907960 196950156 194139014 153444738 192982501 192891196
  1 237      0.00      0.00      0.00      0.00      0.00      0.00         0      0.01         0         0         0         0         0
  2 261      0.01      0.00      0.00      0.00      0.00      0.00         0      0.00         0         0         0         0         0
  3 290      0.00      0.00      0.01      0.01      0.00      0.00         0      0.00         0         0         0         0         0
  4 483      0.00      0.00      0.00      0.00      0.00      0.01         0      0.00         0         0         0         0         0
  5 533      0.00      0.01      0.00      0.00      0.00      0.00         0      0.00         0         0         0         0         0
  6 534      0.00      0.00      0.00      0.00      0.01      0.00         0      0.00         0         0         0         0         0
  </code></pre>
  
  <p>these are my codes are following:</p>
  
  <pre><code>b=my_matrix[1,2:length(my_matrix)]
  
  for (i in nrow(my_matrix)) {
   res[i]=cosine(b,my_matrix[i,2:length(my_matrix)])
  }
  </code></pre>
  
  <p>I used "lsa" package and
  I want to get a cosine similarity matrix that calculate b vector with every other vectors from matrix a  but my codes throw a error that says :</p>
  
  <pre><code>argument mismatch. Either one matrix or two vectors needed as input.
  </code></pre>
  
  <p>What Should I do to fix my problem?
  many thanks in advance</p>