Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent RMySQL warnings "Unsigned INTEGER in col imported as numeric"?

Tags:

r

dplyr

rmysql

When loading data from a MySQL table there are often warnings such as :

unrecognized MySQL field type 7 in column 26 imported as character

Unsigned INTEGER in col 3 imported as numeric

How can I correctly load the database table into a dataframe so that these warnings are not shown?

I see the function RMySQL::dbDataType() can "Determine the SQL Data Type of an S object". Is there a way to tell it which MySQL data type matches which vector type in a data frame?

like image 357
Paul Rougieux Avatar asked Dec 21 '15 15:12

Paul Rougieux


2 Answers

You're not doing anything incorrectly--RMySQL "helpfully" gives you all those warnings just in case that wasn't what you want (it almost always is). @hadley recommends installing the development version (0.11.x) in which this annoyance is reportedly solved. Otherwise, you can use suppressWarnings(...), where ... is the statement for which you want to hide warnings. Or just live with it till version 0.11 hits CRAN.

like image 72
crazybilly Avatar answered Oct 03 '22 03:10

crazybilly


Switching from RMySQL to RMariaDB also removes the warnings, see https://github.com/r-dbi/RMySQL/issues/37.

like image 24
sgrubsmyon Avatar answered Oct 03 '22 03:10

sgrubsmyon