title: how to extract an item from a level of factor if a single level has multiple items in t
body: I have a column in my dataframe - FD which is Factor with 6 levels as below
  
  <p>Levels: [1, 4, 5] [1,5] [1] [2, 4] [2] [3, 5]</p>
  
  <p>but each level has more than one element in it. So how to extract/access elements/items from and individual level</p>
  
  <pre><code>sample&lt;-read.csv(file.choose(), header=T)
  df&lt;-as.data.frame(sample)
  df
  
  v&lt;-df$Nodes[]
  
  w&lt;-df$FirstDegree[]
  for (i in v) {
    t&lt;-c(1:5)
    if (df$FirstDegree[t][2]==i){
      print(1)
      }
    else {
      print(0)
      }
    }
  </code></pre>
  
  <h3>I need to create a matrix with 1's and 0's where 1 represent whether the selected node value is present in FirstDegree, else zero. For which i am trying to access the items inside a level</h3>