作者angela79979 (mini)
看板R_Language
标题[问题] 比对两个list
时间Thu Nov 5 23:34:15 2015
[问题类型]:
程式谘询(我想用R 做某件事情,但是我不知道要怎麽用R 写出来)
[软体熟悉度]:
入门(写过其他程式,只是对语法不熟悉)
[问题叙述]:
有两个list : a.list , b.list
>head(a.list)
$'1'
[1] 3 4 5 8 15
$'3'
[1] 2 3 6 9 12 14
...
>head(b.list)
$'2'
[1] 2 3 5 13 24
$'1'
[1] 2 3 5 6 7 8 9 12
...
想比较a.list和b.list中 相同编号的list的重复element个数
例如:
similarity<-sum(table(a.list$'1'[a.list$'1' %in% b.list$'1']))
欲对每一个编号的list都作去最比对
但使用loop却没办法对a.list$'i' 或 b.list$'i'作回圈
想请问有没有其他的方法
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 118.165.19.199
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/R_Language/M.1446737658.A.388.html