I'm trying to filter my data frame using a variable as the column name and another variable as the filter value. I've used filter_ in the past but where only the value i'm looking to filter was variable.
Here's some example code
#Create data frame
Code <- c("A12561", "B12817")
Value <- c(100,200)
df <- data.frame(Code, Value)
#Normal filter - WORKS
filter(df, Code == "A12561")
#Variable for column and value
Col.Var <- "Code"
Test.Val <- "A12561"
#Filter with only the number coming from a variable - WORKS
filter_(df, ~Code == Test.Val)
#Filter_ Returns nothing - DOESN'T WORK
filter_(df, Col.Var == Test.Val)
#Pasting a string - returns an error - DOESN'T WORK
filter_(df, paste(Col.Var, "==", Test.Val))