How to generate a variable that only contain the "name" of legislators who mentioned "health insurance"? #1
Replies: 1 comment 2 replies
-
library(legisTaiwan) question_8 <- get_parlquestions(term = 8) x <- df$item |> df["legislators"] <- x
A tibble: 14 × 2legislators item |
Beta Was this translation helpful? Give feedback.
-
I want to generate a variable that identifies "legislators' names" who have mentioned "health insurance" from the get_parlquestions(). Does anyone know how to do it? There is a pattern in the "item" from the get_parlquestions().
"本院.委員..", so I thought I could use str_extract and regular expression to extract this "name" variable. However, the following code is not working. Any suggestion
`question_8 <- get_parlquestions(term = 8)
onlydf_not_onlyfan <- question_8$data
df <- onlydf_not_onlyfan[str_detect(onlydf_not_onlyfan[["item"]], "健康保險", negate = FALSE),]
df<- as.data.frame(df)
str_extract(regexpr("本院", df$item), df$item)
`
Beta Was this translation helpful? Give feedback.
All reactions