Hi all,
I have the following df:
$ Protocol : Factor w/ 48 levels "DP FS QTSE SAG",..: 2 3 43 42 31 36 37 30 28 5 ...
$ Speed : chr "SLOW" "SLOW" "SLOW" "VerySLOW" ...
How can I get the most frequent Protocol when Speed is "SLOW"?
Thanks for any help!
Elahe
Factor Variable frequency
3 messages · Elahe chalabi, Rui Barradas, S Ellison
Hello, Maybe the following (untested). table(df$Protocol[df$Speed == "SLOW"]) Hope this helps, Rui Barradas ? Citando ch.elahe via R-help <r-help at r-project.org>:
Hi all, I have the following df: ? ?$ Protocol? ? ? ?: Factor w/ 48 levels "DP FS QTSE SAG",..: 2 3 43 42 31 36 37 30 28 5 ... ? ?$ Speed? ? ? ? ?: chr? "SLOW" "SLOW" "SLOW" "VerySLOW" ... How can I get the most frequent Protocol when Speed is "SLOW"? Thanks for any help! Elahe
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
?
ruipbarradas at sapo.pt Maybe the following (untested). table(df$Protocol[df$Speed == "SLOW"])
Could also use which.max to get the particular item: ... tprot <- table(df$Protocol[df$Speed == "SLOW"]) tprot[which.max(tprot)] S Ellison ******************************************************************* This email and any attachments are confidential. Any use, copying or disclosure other than by the intended recipient is unauthorised. If you have received this message in error, please notify the sender immediately via +44(0)20 8943 7000 or notify postmaster at lgcgroup.com and delete this message and any copies from your computer and network. LGC Limited. Registered in England 2991879. Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK