请原谅我对语言的可怕了解 - 几小时前才开始查看它。
我正在尝试理解这段代码及其产生的内容,但非常不确定。鉴于inclusions
的值是10,为什么输出是什么?
seps <- tapply(diff, nonCore, function(x) sort(x)[inclusions])
输出
"","x"
"ab",23
"ad",15
diff
的值是
"","x"
"1",31
"2",43
"3",37
"4",22
"5",27
"6",13
"7",24
"8",7
"9",26
"10",29
"11",2
"12",15
"13",10
"14",38
"15",23
"16",21
"17",46
"18",10
"19",20
"20",46
"21",20
"22",32
"23",26
"24",11
"25",16
"26",2
"27",13
"28",4
"29",15
"30",18
"31",13
"32",26
"33",1
"34",27
"35",12
"36",10
"37",35
"38",21
"39",9
"40",35
nonCore
的值是
"","x"
"1","ab"
"2","ab"
"3","ab"
"4","ab"
"5","ab"
"6","ab"
"7","ab"
"8","ab"
"9","ab"
"10","ab"
"11","ab"
"12","ab"
"13","ab"
"14","ab"
"15","ab"
"16","ab"
"17","ab"
"18","ab"
"19","ab"
"20","ab"
"21","ad"
"22","ad"
"23","ad"
"24","ad"
"25","ad"
"26","ad"
"27","ad"
"28","ad"
"29","ad"
"30","ad"
"31","ad"
"32","ad"
"33","ad"
"34","ad"
"35","ad"
"36","ad"
"37","ad"
"38","ad"
"39","ad"
"40","ad"
答案 0 :(得分:1)
您应该提供构建向量diff
和nonCore
的代码,因为它可以帮助您进行大量编辑......
那就是说,正在发生的事情是你根据ab
和ad
对矢量组合进行排序。 ab匹配diff中的前20个和后20个匹配。然后,您只是使用包含的元素编号创建的列表的子集。
与没有[inclusion]
的函数运行相同,然后执行此操作:
sep[[1]][10]
sep[[2]][10]