我有一个包含字符串的列。我想从中提取一个特定的单词,如果找到该单词,则为其分配一个值。这适用于其中的所有字符串。下面是一个包含字符串的向量(从数据框中提取 - 数据)
[1] "What is TRAP"
[2] "What are the limitations of SNMP v1"
[3] "Compare between CMIS/CMIP and SNMP"
[4] "Describe RMON standard"
[5] "What is ATM remote monitoring"
[6] "Describe ADSL configuration management"
[7] "Describe different network management models and standards."
[8] "What are the functional requirements of NMS Design"
[9] "Explain with neat diagram SNMP v1 PDU format"
[10] "Compare between SNMP vl, SNMP v2 and SNMP v3"
[11] "Describe the capabilities of RMON2 in Enterprise network management."
[12] "Describe the serivices offered by CMISE"
[13] "SNMP proxy server "
[14] "TMN conceptual model"
[15] "Management Information Tree (MIT)"
[16] "Explain ADSL configuration management"
[17] "Describe RMON standard"
[18] "Describe various parameters of managed objects"
[19] "What are challenges faced by network managers while managing a network"
[20] "What is fault management? Describe five steps process in fault management."
[21] "Explain physical architecture of TMN "
[22] " Explain all CMISE services in following categories: (i) Management association services (ii). Management notification services"
[23] "Write a note on management information tree (MIT)"
[24] "Explain user security model of SNMPv3"
[25] "Discuss Network management tools "
[26] "Discuss Ml, M2 and M4 interface in ATM network management"
[27] "List various event correlation techniques and explain an one in detail"
[28] "Explain configuration management with respect to network provisioning and network topology."
[29] "Explain role of ADSL access network in overall network "
[30] "Semi formal and formal notations"
[31] "SNMPv3 applications"
查看[2], [3], [9] ,[10]
等等,我们看到" SNMP"这是常用术语。我想创建另一个列并对应于具有" SNMP"将分配一个整数值。
我使用了grep函数,但它只返回索引
> grep("SNMP",data$Questions)
[1] 2 3 9 10 13 24 31
我想创建一个向量(让我们说Value),这些索引分配了相同的值。我怎么能在一个声明中做到这一点?