Closed krbrick closed 2 years ago
@krbrick I ran your non-working code, I am not getting the same error message, it returns (43 + 237) rows. Do you have library(stringr) loaded?
Hi! yeah it is loaded did it work for you?
@krbrick I copied your exact code, it worked for me.
thank you, something is wrong with my here() setting and i think that is giving me issues.
I was able to write a function for time by first wrangling time period variables, but I am struggling to write a function for finding strings in data.
here is my (nonworking) function:
`find.variables.for.string <- function(variable.string) { test.term <- str_detect(dd$definition,"variable.string") test.term.l <- cbind (dd,test.term) %>% filter(test.term == T) return(test.term.l) }
find.variables.for.string(asian)`
my return gives me
same with: find.string <- function(string) { variable.string <- dd %>% filter(str_detect(definition, "string")) return(variable.string) }
find.string(poverty)
the inside bits of the functions work on their own, giving a datatable:
`asian.test <- str_detect(dd$definition,"Asian") asian.test.2 <-cbind(dd,asian.test) %>% filter(asian.test == T) View(asian.test.2)
and
dd %>% filter(str_detect(definition, "string"))`
any thoughts on where I'm going wrong? thanks in advance