Inactive Tutor answered 09/09/26
This is actually pretty simple! R comes built in with a handy function: as.list.
It looks like you want to extract the first row of this data, but you can do it for any row (just be sure you are calling the correct row number).
Let's say your data frame is called data, and you have your named column headers A, B, C, and want your output list to be called "result"
You just need to code:
result<- as.list(data[1, ])
This will create your list and assign the values of row 1 to list items A, B, C (or whatever the full names may be). Remember when calling for data in the data frame data [x,y], the x is the row or rows and y would be the columns.
*By leaving the column section blank, we are telling R to check that row for all columns, but if you only wanted to call certain columns you can add that to the code