r - 如何在 R 或 sqldf 中获取部分匹配的计数
问题描述
我的数据框中有部分文本。如何获得他们的计数示例:
t=data.frame(x=c('I want to go there','I want to go here','I don't want to go'))
预期:由于前两个是部分的 - 我希望它们计为 2
解决方案
如果我理解的很好,你要不要数一下“我要”这两个字出现了多少次。
library(stringr)
t=c('I want to go there','I want to go here',"I don't want to go")
x <- str_count(t, "I want")
print(x)
推荐阅读
- uwp - WNS 中基于标签的广播通知
- javascript - 类型“CombinedVueInstance”上不存在属性“XXX”
>>' - php - PayPal 自动返回脚本总是被调用两次
- maven-3 - 如何加快 Maven 全新安装?耗时2小时完成
- python - PyMC3 在 Possion 模型创建期间产生错误
- python-3.x - 未定义符号:导入张量流时的_PyThreadState_Current
- thymeleaf - 使用 thymeleaf 从字符串中删除单引号字符
- python - 在python中转换为纪元
- php - 匹配PHP中多行字符串中每行开头的任何水平空白字符
- javascript - 如何将迭代器添加到 cloneNode 中每个元素的每个名称值?