Skip to content
Advertisement

Tag: r

In R how to make a string of fields in to a SQL join

In R given a string like “fld1,fld2” how can I get something like “b.fld1=v.fld1 and b.fld2=v.fld2” for a SQL query. The string may have up to 10 distinct elements. This is for trying to build a join on the fly. b and v are the aliases for two tables. There willo only be two tables. Answer String interpolation with stringr::str_glue

Merge tables in R and update rows where dates overlap

I hope this makes sense – it’s my first post here so I’m sorry if the question is badly formed. I have tables OldData and NewData: I need merge these tables as below. Where IDs match, dates overlap, and Priority is higher in NewData, I need to update the dates in OldData to reflect NewData. I first tried to run

Importing JSON data from SQL DB to an R dataframe

I would like to know whether there is a way of importing JSON data from a MySQL DB to an R dataframe. I have a table like this: I would like to get the columns ‘id’ and ‘json’. I am using RMySQL package for getting the data from the db to an R dataframe but this gives me only the

Advertisement