Fixing Error: undefined columns selected

As indicated, this error is prompted when R cannot find the column you think you’re asking for within the dataset. This generally occurs as a result of one of several things:

  • The column in question is not in the data set. Use the names() function to interrogate the dataset to see which columns are present.
  • You’re selecting specific rows or columns from a dataset and forgot to include the comma after the condition.

From experience, this generally tends to show up when you’ve done the latter. Check the syntax of your column selection criteria or row selection condition and see if you need to add a column after that..

Error: undefined columns selected