title: convert row in data frame to list of lists in r
body: <p>I have a data frame consisting of records like the following. A typical row of the data frame, df[1,] looks as follows</p>
  
  <pre><code>84745,"F",70,7,"Single",2,"N",4,9,1,1,3,4,4,"2 day","&lt;120 and &lt;80",0,8,0,1,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1
  </code></pre>
  
  <p>I want to convert it into a variable like myvar below which is of the following type</p>
  
  <pre><code>myvar = list( list(84745,"F",70,7,"Single",2,"N",4,9,1,1,3,4,4,"2 day","&lt;120 and &lt;80",0,8,0,1,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1))
  </code></pre>
  
  <p>I have tried doing the following, but it doesn't work to convert it to a list of lists.</p>
  
  <pre><code>myvar &lt;- as.list(as.list(as.data.frame(t(df[1,]))))
  </code></pre>
  
  <p>How can I do that?</p>
  
  <p>EDIT : I have tried myvar = list(unclass(df[14,])). It however fails the call since the formatting of the output myvar is slightly different.</p>
  
  <p>Format of the original line of code</p>
  
  <pre><code>[[1]]
  [[1]][[1]]
  [1] 21408
  
  [[1]][[2]]
  [1] "M"
  
  [[1]][[3]]
  [1] 69
  
  [[1]][[4]]
  [1] 3
  
  [[1]][[5]]
  [1] "Widowed"
  </code></pre>
  
  <p>Format of myvar = list(unclass(df[14,]))</p>
  
  <pre><code>[[1]]
  [[1]]$ID
  [1] "21408"
  
  [[1]]$GenderCD
  [1] "M"
  
  [[1]]$Age
  [1] "69"
  
  [[1]]$LOS
  [1] "3"
  
  [[1]]$MaritalStatus
  [1] "Widowed"
  </code></pre>