I am trying to run the code below and RStudio and R go crazy. I imagine that there is some way to do this out = dat[, cc[nn1] but I cannot even think of any search terms

Ah, I think I see but I'm going have to think about it. I still do not understand why 2, 1. I think I've got a mental block in trying to visualize what it is defining.

Since the example data frame has two columns, only the indexes 1 and 2 are possible. (-1 and -2 also work if you want to exclude columns rather than include them.) I chose the order c(2,1) to show that passing 1 to the argument nn1 selects the first element of xxx, which is 2, so the second column of the data frame gets chosen.