我正在尝试计算此列表中的独特药物数量.
my_drugs=c('a', 'b', 'd', 'h', 'q')
Run Code Online (Sandbox Code Playgroud)
我有以下字典,它给了我药物同义词,但它没有设置,所以定义只适用于独特的药物:
dictionary <- read.table(header=TRUE, text="
drug names
a b;c;d;x
x b;c;q
r h;g;f
l m;n
")
Run Code Online (Sandbox Code Playgroud)
因此,在这种情况下,列表中有2种独特的药物(因为a,直接或间接地具有同义词b,d,q).同义词的同义词计为同义词.
我尝试过的方法是首先制作一本左侧只有独特药物的字典.要做到这一点,我会循环通过字典$ drug,grep in dictionary $ drug和dictionary $ synonyms,取出那些并取代药物$同义词的联合,然后从字典中删除其他行.
bigdf=dictionary
small_df=data.frame("drug"=NA,"names"=NA)
for(i in 1:nrow(bigdf)){
search_term=sprintf("*%s*",bigdf$drug[i])
index=grep(search_term,bigdf$names)
list=bigdf$names[index]
list=Reduce(union,list)
list=paste(list, collapse=";")
if(!list==""){
new_row=data.frame("drug"=bigdf$drug[index][1],"names"=list)
small_df=rbind(small_df,new_row)
#small_df
bigdf=bigdf[-index,]
#dim(bigdf)
}
else{
new_row=data.frame("drug"=bigdf$drug[index][1],"names"="alreadycounted")
small_df=rbind(small_df,new_row)
}
}
Run Code Online (Sandbox Code Playgroud)
这不起作用(small_df中缺少一些药物),即使它我不知道如何使用我的新词典计算我的列表中的独特药物数量.
我如何计算my_drugs中独特药物的数量?
感谢您的帮助,如果需要进一步说明,请与我们联系.
数据集大小:my_drugs中的200个元素,字典中的2000个行,每个药物有10-12个同义词.
我正在尝试使用 从辅助电子邮件地址发送电子邮件RDCOMClient。我听取了如何使用 R RDCOMClient 检索 Outlook 收件箱电子邮件?并尝试用 VBA 编写并翻译,但无法获得正确的命令。
注意:我无法使用,SentOnBehalfOfName因为我没有必要的权限。
以下 VBA 和 Python 代码均成功从辅助收件箱发送电子邮件。
编程语言
Sub SendUsingAccount()
Dim oAccount As Outlook.Account
Dim oMail As Outlook.MailItem
Set oAccount = Application.Session.Accounts.Item(2) 'Index of Mailbox
Set oMail = Application.CreateItem(olMailItem)
oMail.Subject = "Sent using MAPI Account"
oMail.Recipients.Add "email@email.com"
oMail.Recipients.ResolveAll
oMail.SendUsingAccount = oAccount
oMail.Send
End Sub
Run Code Online (Sandbox Code Playgroud)
Python
import win32com.client
o = win32com.client.Dispatch("Outlook.Application")
oacctouse = None
for oacc in o.Session.Accounts:
if oacc.SmtpAddress == "myemail@email.com":
oacctouse = oacc
break
#print …Run Code Online (Sandbox Code Playgroud)