我有两个数据集,需要将一个数据集列中的字符串与R中的另一个数据集列进行比较
我有两个数据集,需要将一个数据集列中的字符串与R中的另一个数据集列进行比较: 详情如下。这种情况可以忽略不计 谁能帮我一下吗 第一个数据集:我有两个数据集,需要将一个数据集列中的字符串与R中的另一个数据集列进行比较,r,R,我有两个数据集,需要将一个数据集列中的字符串与R中的另一个数据集列进行比较: 详情如下。这种情况可以忽略不计 谁能帮我一下吗 第一个数据集: InstanceNameHostNameId instance1server1 sid1instance2server2 sid2instance3server3 sid3instance4server4 sid4instance5server5 sid5instance6server6 sid6由于您以html格式提供了数据,因此我必须将其读入r中作为
InstanceNameHostNameId instance1server1 sid1instance2server2 sid2instance3server3 sid3instance4server4 sid4instance5server5 sid5instance6server6 sid6
由于您以html格式提供了数据,因此我必须将其读入r中作为一个表:
b ="<table><tbody><tr><th>short_description</th><th>description</th></tr><tr><td>Kindly activate Server1 information</td><td>Kindly activate all sid3 and there is issue with instance3</td></tr><tr><td>server2: issue on instance2</td><td>find a sloution for this issue</td></tr><tr><td>Please fix the issue</td><td>issue is on Sid6</td></tr><tr><td>can you please check instance5 on server5</td><td>Sid5. Please look into this issue asap.</td></tr><tr><td>sid1: performance issue</td><td>server1 and sid1. Performance issue</td></tr><tr><td>Can you please check the issue</td><td>Can you please check the issues</td></tr></tbody></table>"
dat2= xml2::as_xml_document(paste0("<body>",b,"</body>"))%>%
rvest::html_table()%>%
{.[[1]]}
serv_instance = gsub("(?|.*?((?i)server\\d+|instance\\d+|sid\\d+)|.+)","\\1",do.call(paste,dat2),perl=T)
final_output = replace(gsub("(?<=\\d)(?=[A-Za-z])",", ",serv_instance,perl=T),!nchar(serv_instance),"No match found")
cbind(dat2,final_output)
short_description description final_output
1 Kindly activate Server1 information Kindly activate all sid3 and there is issue with instance3 Server1, sid3, instance3
2 server2: issue on instance2 find a sloution for this issue server2, instance2
3 Please fix the issue issue is on Sid6 Sid6
4 can you please check instance5 on server5 Sid5. Please look into this issue asap. instance5, server5, Sid5
5 sid1: performance issue server1 and sid1. Performance issue sid1, server1, sid1
6 Can you please check the issue Can you please check the issues No match found
b=“简短描述说明请激活服务器1信息请激活所有sid3,实例3存在问题服务器2:实例上存在问题找到解决此问题的方法请修复问题SID6是否可以检查服务器5SID5上的实例5。请尽快研究此问题。sid1:性能问题服务器1和sid1。性能问题能否请您检查问题能否请您检查问题“
dat2=xml2::作为xml文档(粘贴0(“,b)”)%>%
rvest::html_table()%>%
{.[[1]]}
serv|u instance=gsub((?|.*(?i)server\\d+| instance\\d+| sid\\d+),“\\1”,do.call(粘贴,dat2),perl=T)
最终输出=更换(gsub(“(?读取您的数据集不容易。请查看此帖子以获取帮助。您的屏幕截图丢失了第二个数据集在哪里?dput
您的第二个数据集。很抱歉,添加了第二个数据集。请以易于复制的方式添加。谢谢您的帮助。我刚刚编辑了我的确切要求,您能帮助我吗?@user3061575您是否正在废弃一个网站?您应该使用rvest