Dear All,
  I am having some problem in apply function.
I have some data like below. I want to get a range vector (which is max-min
value for each row , ignoring NA values.)
> Species.all[1:10,]
       V2     V3     V4     V5    V6   V7    V8   V9
1   57543  55938  47175  54922 36032 5785 29497 7286
2   42364  40472  29887  40107 19723 2691 14445 3258
3   19461  19646  18538  22392  6744  794  4919 1024
4      45     41     28     34    33   NA    26   NA
5      45     41     28     34    33   NA    26   NA
6      45     41     28     34    33   NA    26   NA
7      14      9     14     14     7   NA    10   NA
8      20     25     10     15    21   NA    10   NA
9      20     25     10     15    21   NA    10   NA
10    578    566    478    753   361  150   262  170
> dim(Species.all)
[1] 1862    8

I used apply function like below. I used this same function for some other
data, there it worked. But here its not working (giving error message).

> Range.j=apply(Species.all,1,max,na.rm =
TRUE)-apply(Species.all,1,min,na.rm = TRUE)
Error in apply(Species.all, 1, max, na.rm = TRUE) - apply(Species.all,  :
    non-numeric argument to binary operator

When i tried to check, you can see from the steps it is giving totally wrong
results.

> apply(Species.all[1:10,],1,max)
     1      2      3      4      5      6      7      8      9     10
"7286" "3258" "1024"     NA     NA     NA     NA     NA     NA " 753"
> apply(Species.all[1:10,],1,min)
       1        2        3        4        5        6        7
8        9       10
" 47175" " 29887" " 18538"       NA       NA       NA       NA
NA       NA  "  262"


Main problem is, this code is working for some cases, but not for all. Does
any body have an idea, why it is so? Or can anyone show me some other way to
do the same.
Thanks in advance,
With best regard,
Suparna

	[[alternative HTML version deleted]]


