Skip to content
Advertisement

How to send varying number of variables in R function to be used by sql query

I’m writing a R code which will pull data from a data frame using sql query. My function looks like

Here I’m using 2 variables in function Now for some cases I will have multiple variables for the same sql query. How do I write my formatData function dynamically so that it can take variables dynamically Let’s assume in future I will have 3 variables. Then my query will be

Similar way for more than 3 variables & my variable count can go to around 80

Advertisement

Answer

Questions to SO r tag should have a complete minimal reproducible example which the question did not include so this is untested but hopefully gives the basic idea.

giving:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement