--
Check out our R resources at http://d-rug.github.io/
---
You received this message because you are subscribed to the Google Groups "Davis R Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to davis-rug+...@googlegroups.com.
Visit this group at https://groups.google.com/group/davis-rug.
For more options, visit https://groups.google.com/d/optout.
> class(huc_data) [1] "sf" "data.frame"
> class(data_of_interest) # this is the variable that's actually being passed into the filter call, but I kept it simpler in my question [1] "data.frame"
To unsubscribe from this group and stop receiving emails from it, send an email to davis-rug+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/davis-rug.
For more options, visit https://groups.google.com/d/optout.
--
Check out our R resources at http://d-rug.github.io/
---
You received this message because you are subscribed to the Google Groups "Davis R Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to davis-rug+unsubscribe@googlegroups.com.
Hi Nick,
I agree with Scott. The following example with a numerical factor like yours works fine both ways. Also, always good to call the function from within the packages like Scott did, when things aren’t behaving as expected (e.g. dplyr::filter). That way you are sure you aren’t using a function masked from another package. Best, Katie
library(tidyverse)
glimpse(mtcars)
# make a numerical factor group variable
mtcars$carb <- as.factor(mtcars$carb)
glimpse(mtcars)
class(mtcars)
group1 <- mtcars %>%
filter(carb == 1)
group <- c("1")
group1 <- mtcars %>%
filter(carb == group)
dplyr::filter_(paste(field_name, "==", as.character(group)))
This StackOverflow answer has a few other options too.
Thanks
for taking the time to provide suggestions to me here - definitely led
me to the solution and I learned quite a bit from each of your
suggestions.