title: R create a list of character vectors
body: <p>I'm trying to process an adjacency matrix into a list of communities,
  the output should be a list of vectors (of type character)</p>
  
  <p>For example</p>
  
  <pre><code>l1[1] = c("a","b","c")
  l1[2] = c("d")
  l1[3] = c("e","f")
  </code></pre>
  
  <p>I'm trying to achieve this in a for loop:</p>
  
  <pre><code>l1=vector("list")
  
  for(kn in 1:nrow(adjFinal)){
    temp = c()
  
    for(tm in 1:ncol(adjFinal))
      {
      if(adjFinal[kn,tm]==1)
        temp=c(temp,colnames(adjFinal)[tm])
    }
  
    l1[kn] = temp
  }
  </code></pre>
  
  <p>But I keep getting warning of "number of items to replace is not a multiple of replacement length" , and a list of 3 vectors of length 1
  like:</p>
  
  <pre><code>l1[1] = "a"
  l1[2] = "d"
  l1[3] = "e"
  </code></pre>
  
  <p><strong>Update:</strong>
  this is the adjFinal:</p>
  
  <pre><code>3 x 6 sparse Matrix of class "dgCMatrix"
    a b c d e f
  b 1 1 1 . . .
  d . . . 1 . .
  e . . . . 1 1
  </code></pre>
  
  <p>and dput(adjFinal):</p>
  
  <pre><code>new("dgCMatrix"
      , i = c(0L, 0L, 0L, 1L, 2L, 2L)
      , p = 0:6
      , Dim = c(3L, 6L)
      , Dimnames = list(c("b", "d", "e"), c("a", "b", "c", "d", "e", "f"))
      , x = c(1, 1, 1, 1, 1, 1)
      )
  </code></pre>
  
  <p>Thank you in advance.</p>