Why is my dplyr::filter() command not working with error saying x` must be a vector, not a <ODBC_binary> object?

65 views Asked by At

I have read in some data from an SQL server database using the sqlFetch function from the RODBC package. The data reads in correctly (as far as I can see). However when I try to apply a simple dplyr::filter() using the syntax:

filtered_data<- original_data %>%
  filter(character_vector== "character I want to keep")

I get the following error:

Error in `vec_size()`:
! `x` must be a vector, not a <ODBC_binary> object.

I assume this means the column I want to filter on is type ODBC_binary and so the function doesn't work. However I have checked the class of the column and it returns the class as 'character'.

Can anyone help?

1

There are 1 answers

0
Mike H On

I have encountered this error as well, in my case it was due to a different column in the data frame (not the filtered column) being of the 'ODBC_binary' datatype. Try checking the datatypes of all your columns.