0

I have a column from a matrix like this:

 Mat[,1]
   1    2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25 
"89" "89"  "2" "87" "77"  "6" "89" "89" "89" "88" "83" "81"  "2" "89" "89" "19" "81" "82" "88" "89" "85" "82" "74" "87"  "5" 
  26   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48 
 "3" "89" "17" "71" "89" "88" "88" "88" "77" "75" "46"  "0" "81" "88" "89"  "0" "89" "89" "89" "89"  "0"  "5"  "9" 

And I want to apply the following function:

ifelse(Mat1[,1]>=40,1,0)

And the output is like this:

 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 
 1  1  0  1  1  1  1  1  1  1  1  1  0  1  1  0  1  1  1  1  1  1  1  1  1  0  1  0  1  1  1  1  1  1  1  1  0  1  1  1  0  1 
43 44 45 46 47 48 
 1  1  1  0  1  1 

Numbers 6, 25 and 47 are wrong. I cannot understad why. Can you help me?

Carpa
  • 412
  • 4
  • 16

0 Answers0