Re: [R] invalid 'mode' of argument?

From: Jari Oksanen <>
Date: Wed 10 Aug 2005 - 22:28:24 EST

On Wed, 2005-08-10 at 08:13 -0400, Kang, Sang-Hoon wrote:

> As a novice I was trying to calculate Shannon diversity index using
> diversity function in vegan package and kept having same error message.
> Error in sum(..., na.rm = na.rm) : invalid 'mode' of argument
This error (which is from sum()) seems to come if you have non-numeric data (factors, character variables etc.). Check that your data are strictly numeric. Some of the most common cases I've seen are that row or column names are not read as row and column names but as data rows or columns.
> My dataset is from microarray and have abundant missing values, so I
> tried labeling them as NA and 0, but still same error message.

> Shannon index is negative sum of proportion times log of proportion, so
> I put 1 for missing values to avoid log 0, but still same error message.
You shouldn't forge your data: the function handles zeros.

PLEASE do read the posting guide!

cheers, jari oksanen

Jari Oksanen -- Dept Biology, Univ Oulu, 90014 Oulu, Finland
email, homepage

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Wed Aug 10 22:34:18 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:12:05 EST