2017-02-10 61 views
-1
print(results) 
     symptom1  disease 
     Headache  Chicken pox 
     Fever  Chicken pox 
loss of appetite Chicken pox 
Red Color rashes Chicken pox 
     Scabs  Chicken pox 
    Shivering  Malaria 
     Fever  Malaria 
    vomitings  Malaria 
    muscle pain  Malaria 
    sweating  Malaria 
table<-subset(results,symptom1=="Headache"|symptom1=="Fever"|symptom1=="Scrabs") 
> print(table) 
symptom1  disease 
1 Headache Chicken pox 
2 Fever Chicken pox 
7 Fever  Malaria 
> summary(table) 
       symptom1  disease 
    Fever   :2 Chicken pox:2 
    Headache  :1 Malaria :1 
    loss of appetite:0     
    muscle pain  :0     
    Red Color rashes:0     
     Scabs   :0     
     (Other)   :0 

我如何打印價值水痘。在總結(表) 在這種情況下,水痘
希望我的問題明白。 感謝ü提前如何在R中打印彙總數據?

回答

0

我們可以從dplyr

library(dplyr) 
table %>% 
    group_by(disease) %>% 
    mutate(n = n()) %>% 
    ungroup() %>% 
    filter(n==max(n)) %>% 
    select(-n) 
+0

做到這一點的偉大工程時,只需在R.編碼但不列入與rserve-js和Rserve工作的時候正是在這種形式client.eval( 「result%>%」,function(err,response)。請指導我使用rserve-js和Rserve代碼。 – dpak

+0

@dpak請將這個問題作爲rserve-js和'Rserve'不一樣 – akrun

+0

ok.i發佈了@naruto。如果你有這個想法,請指導我。謝謝 – dpak