where data_df is the data.frame I want to save and vartypes is obtained following the tip given here
Useful Tips for RODBC
Two columns have a bigint unsigned type.
The first contains numbers with 11 figures (like 20015301001)
The second colums has numbers with 13 figures (like 2002000103651)
First column are well saved in the database but, even with the same type, numbers of the second one are truncated (this was not observed with RMySQL package)
2002000103651 become 2002000103000
The only solution I found at the moment, is to change the type of the second column in the data.frame and in the database, that is use a char(13) instead of bigint unsigned.
But it is not satisfactory.
Thanks in advance for any tip or solution,
Have a good day,
In fact, I always use a string for ID variables because you can get
some funky matching errors due to mismatches in precision.
Bill Gould at Stata Corp said this well in a recent blog post
"1. Use theory to check IDs if they are numeric
One way the id variable can become corrupted is if it is not stored
properly or if it is read improperly. This can happen to both string
and numeric variables, but right now, we are going to emphasize the
Say the identification variable is Social Security number, an example
of which is 888-88-8888. Social Security numbers are invariably stored
in computers as 888888888, which is to say that they are run together
and look a lot like the number 888,888,888. Sometimes they are even
stored numerically. Say you have a raw data file containing perfectly
valid Social Security numbers recorded in just this manner. Say you
read the number as a float. Then 888888888 becomes 888888896, and so
does every Social Security number between 888888865 and 888888927,
some 63 in total. If Bob has Social Security number 888888869 and Mary
has 888888921, and Bob appears in dataset one and Mary in dataset two,
then Bob and Mary will be combined because they share the same rounded
Social Security number.
Always be suspicious of numeric ID variables stored numerically, not
just those stored as floats."