1
首先輸出之間的差異,我有大小15的2個載體: lb_result:KnitR:控制檯和PDF(編碼)
cap-color
cap-color
odor
odor
odor
odor
gill-spacing
gill-size
gill-color
stalk-surface-above-ring
stalk-color-above-ring
spore-print-color
spore-print-color
population
population
AND: vl_result:
buff
pink
creosote
foul
musty
pungent
close
narrow
buff
silky
cinnamon
chocolate
green
scattered
several
現在,我想輸出爲:
cap-color ∈ {buff, pink}
odor ∈ {creosote, foul, musty, pungent}
gill-spacing = {close}
gill-size = {narrow}
gill-color = {buff}
stalk-surface-above-ring = {silky}
stalk-color-above-ring = {cinnamon}
spore-print-color ∈ {chocolate, green}
population ∈ {scattered, several}
我寫了一個Rscript爲:
dt <- data.table("Name"=lb_result,"Var"=vl_result)
res <- dt[,paste(Var,collapse=","),by=Name]
for(i in 1:length(res$V1)){
if (length(grep(",",res$V1[i],value=T)) == 0) {
res$V1[i] = paste("= ", res$V1[i])
} else
# {res$V1[i] = paste(" \u2208 {", res$V1[i], "}")}
{res$V1[i] = paste(" ∈ {", res$V1[i], "}")}
}
for(i in 1:length(res$V1)){
print(paste(res$Name[i],res$V1[i]))
}
在康壽R,我得到的結果是:
[1] "cap-color ∈ { buff,pink }"
[1] "odor ∈ { creosote,foul,musty,pungent }"
[1] "gill-spacing = close"
[1] "gill-size = narrow"
[1] "gill-color = buff"
[1] "stalk-surface-above-ring = silky"
[1] "stalk-color-above-ring = cinnamon"
[1] "spore-print-color ∈ { chocolate,green }"
[1] "population ∈ { scattered,several }"
但是,當我在一個文件中插入此RSCRIPT。與knitR的Rnw。
輸出的PDF文件:
它顯示的<U+2208>
代替∈