Skip to content
Prev 1551 / 1559 Next

[EXTERNAL] Importing data into a MySQL table from a data.frame with R

Luis--
Unless I'm missing something, that's not specifically a MySQL or database
issue.  For any form of update or append you need to make your "records"
object have the same variables (columns) in the same order as the table
you're updating.

If your table has 5 variables and your update dataframe only has 3, do you
want the other 2 variables to have missing values?
records <- newdf
records$AA_CLONETYPE <- NA   # probably needs to match type, so
na_character_ or na_numeric_
records$COUNT <- na_integer_  # assuming COUNT is integer type
records <- records[,c("INTERNAL_ID", "AA_CLONOTYPE", "NT_CLONOTYPE",
"COUNT", "SAMPLE_ID")]
dbxUpsert(conx, table, records, where_cols = c("INTERNAL_ID"))

Tom
On Wed, May 8, 2019 at 6:53 AM Luis Aparicio <aparicio2457 at gmail.com> wrote: