in R

R dplyr error ‘Each argument must yield either positive or negative integers’

It’s quite common in R to use the dplyr package for handling of dataframes.

I encountered an error that was not so obvious at first sight when using the select() to get a set of columns from the dataframe together with one_of(), which is passed a list of column names to return:

Error: Each argument must yield either positive or negative integers

The problem was: one of the column┬ánames was not spelled correctly and therefore not existing in the dataframe. So when select() tried to get the position indices of the columns requested, one returned NA… hence the message about integers.

Print Friendly, PDF & Email



Time limit is exhausted. Please reload CAPTCHA.

  • Anderer Inhalt mit diesem Tag