[R] Easiest way to get the mean of a row of a data.frame?

Sven C. Koehler schween at snafu.de
Wed Dec 17 08:27:41 CET 2003


Dear r-helpers!

I am kind of new to R.
I would like to calculate the mean of the numbers of this expression:

    data(USArrests)
    USArrests[row.names(M) == "Alabama",]

class() tells me it's a ``data.frame,'' what I actually desire is to get
all numbers of a row as a vector or a list to let mean() calculate the mean
of the whole row.  (I know this doesn't make sense with USArrests, I just
used it here instead of my very own data.frame.)

Thank you very much!

Bye

Sven




More information about the R-help mailing list