 It's LinkedIn Learning author Monica Wahee with today's data science makeover. Watch while Monica Wahee demonstrates how to use the witch command to find the number of a column in a data frame in R. And we are back in R Windows GUI. And we are back with the line items data set. See how I read in the line items data frame, which is an RDS format with a read RDS command. And then I found out the column names of this line items data frame with the call names command. See how the code ran and the results are up here. I can tell you nothing makes me happier than the code running without any errors. So those of you who are curious about these commands, read RDS and this call names command, just look in the description. I gave you a few links. What we're going to do today is use the witch command to figure out the column number of one of these columns in this data frame line items. You might be wondering why you would ever want to do that. I thought that until the date came when I had to do it. My experience is that when I'm trying to automate editing of data frames, like let's say I want to run a loop to update a bunch of fields in the data frame, it's way, way, way easier to refer to the field names by their numbers and not their names. So for that reason, I'm using the witch command all the time. And actually, let me also link you to a video where I show you how to refer to a column by number encoding rather than using the name. Oh, and thank goodness for stack overflow. I actually learned how to do this particular maneuver from a stack overflow post, which I'll link to in the description so you can read it too. Thanks, REB Friedman for answering that question for me. Okay, see this? This is the cost row ID column. And there are only five columns in this line items data frame. As you can see, cost row ID is the fourth column. So we are going to use the witch command on cost row ID and see if it gets it right and says that cost row ID is the fourth column. Okay, this command is super crazy, like my friend says, I'm going to unpack it from the inside. First, let's look at this double equals. Something has to equal the character string cost row ID. And what has to equal that? The call names of the line items. So this is basically saying where the column name of line items totally equals cost row ID, that's what we care about. And that is what we care about where that column is numerically the command that says what we want to know about the column names of line items that equals cost row ID is the witch command. That means what we want to know is what the column number is. I don't know why they picked which, which, which, which, which, whatever tomato to model. Let's run this puppy and see what happens. Did it or ran it. See that see that for it worked. Yay. I'm sorry. Programming is really hard for me. I'm so happy when anything goes right. As I said before, often you want to use this column number in automated processing. So you might want to store the value into a variable. See what I did here to save it as the variable cost row ID underscore CN. The CN stands for column number. I just put an arrow to that name cost row ID underscore CN. And on the right side of the arrow, I put the code above that makes the four here. I'll run this code for you. And then I'll run this new object I made called cost row ID underscore CN that should hold that value of four in it. And how about that? It came out really nice. Just gorgeous. Now we can use it in processing. All right. That's all for today. I hope today's data science makeover makes your day. Thank you for watching this data science makeover with LinkedIn Learning author Monica Wahee. Remember to check out Monica's data science courses on LinkedIn Learning. Click on the link in the description.