Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To find "row wise" "Mode" of a given data in R [duplicate]

Tags:

r

Unlike rowMeans() and rowMedians(), which give us the calculated figure, mode(x) gives the storage mode of the data.

My Question - For the following data frame, how can I calculate row wise Mode?

Data:

    Item       A    B   C
    Book001    56   32  56
    Book002    95   95  20
    Book003    50   89  50
    Book004    6    65  40

I am reading my worksheet like this:

wk= loadWorkbook (".....xls")
df = readWorksheet (wk, Sheet="Sheet1", header=TRUE)
like image 773
Amrita Das Avatar asked May 19 '15 14:05

Amrita Das


1 Answers

Try this

install.packages("modeest")
library(modeest)

apply(df[ ,2:length(df)], 1, mfv)
like image 87
dimitris_ps Avatar answered Nov 15 '22 10:11

dimitris_ps