I have a list of values that I want to parse through in the future. For the time being to ensure that I have the format correct for this query. I have this query:
var2 = "Application Maintenance"
r = fn$sqldf("Select Iteration, (SUM(Hours) / SUM(Effort)) as Efficiency
From df WHERE Iteration = $var2")
query = sprintf('Select Iteration, (SUM(Hours) / SUM(Effort))
as Efficiency from df WHERE Iteration = %s', var2)
q = sqldf(query)
I am getting the error in both attempts: Error in result_create(conn@ptr, statement) : near "Maintenance": syntax error
I have only used sqldf once in the past so I am still new to the syntax. The query worked just fine when I changed $var2 to "Application Maintenance" but is not working when I use a user defined variable.
I've tried solutions from other Stackoverflow posts, but I kept getting the same error above.
Any help would be much appreciated!
Edit: Code for list iteration (path_list is a list of strings): getting NULL 'Error in tcltk::as.tclObj(X) : cannot handle object of mode 'list''
for (var1 in path_list){
query = fn$sqldf("Select Iteration, (SUM(Hours) / SUM(Effort)) as Efficiency
From df WHERE Iteration = '$var1'")
print(query)
}
Edit 2: The path_list is contained in this format (when clicking on the list in RStudio:
Iteration
'Application Maintenance'
'Task'
'QA'
Edit 3: Included Example of first 15 rows. There are thousands in this data set. Changed 'Iteration' column names for confidentiality reasons:

path_list? Is it alistIn that case you have to use[[for extraction