dplyr count and filter functions seem to be evaluating this differently.
I am trying to write a function that takes in 2 column names and one value for each of those columns. df1 has 12 columns and has 3 possible values for each column.
object_name_list<-c("A", "B") ## A and B are column names for df1
values_list<-("C', "D") # C and D are possible values in the two columns
tib2<-df1 %>%
count(!!!syms(object_name_list)) %>%
group_by(!!!syms(object_name_list[1])) %>%
mutate(prop = prop.table(n))
This function works perfectly and outputs the probability table that I want
df2<-df1 %>%
filter(!!!sym(object_name_list[1])==values_list[1] &
!!!sym(object_name_list[2])==values_list[2])
This line of code leaves df2 blank. If I put A or B explicitly in place of !!!sym(object_name_list[1])
this works just fine.
What has confused me even further is when !!!syms(object_name_list)
is run by itself it outputs the error: "invalid argument type". When syms(object_name_list[1])
is run by itself it has no issue. But putting syms(object_name_list[1])
into the first function without !!! causes it to break.
At a total loss to why this is happening.