On 26-Aug-04 Kevin Wang wrote:
> Hi,
> 
> If a value like 8e-04 is in a data frame, is the following behaviour
> normal?
> 
>    > final.df
>       Chr P.values
>    1    1   0.0379
>    2    6    0.068
>    3    2   0.0025
>    4   13    8e-04
>    5   14   0.0244
>    6    3   0.0279
>    7    4   0.1561
>    8    5   0.9261
>    9    7   0.0011
>    10   9   0.5125
>    11  10   0.2196
>    12  11   0.6457
>    13  18   0.9272
> 
>    > final.sorted <- data.frame(final.df[order(final.df$P.values), ],
>    +                            row.names = 1:13)
>    > final.sorted
>       Chr P.values
>    1    7   0.0011
>    2    2   0.0025
>    3   14   0.0244
>    4    3   0.0279
>    5    1   0.0379
>    6    6    0.068
>    7    4   0.1561
>    8   10   0.2196
>    9    9   0.5125
>    10  11   0.6457
>    11   5   0.9261
>    12  18   0.9272
>    13  13    8e-04
> 
> I'd think 8e-04 should be the smallest value...?  It's R 1.9.1 on 
> Windows XP if that helps.

It looks to me as though you have managed somehow to get the
"numerical" data into the dataframe as character strings, which
will be sorted alphabetically rather than numerically by 'order'.

The first clue is that if you read in a (e.g.) CSV file with your
original data as displayed above, then print it out with 'final.df',
then the value "8e-04" shows as "0.008". Sorting this DF with your
command shows "0.008" in its proper place, at the top of the list.

The next clue is that if you then assign final final.df[4,2] with

  final.df[4,2]<-"8e-04"

and then sort the DF in the same way, then "8e-04" comes out where
you found it, i.e. at the bottom of the list. This is consistent
with alphabetical sorting, since "8" follows "0" (and in any case
"e" follows ".").

So I think you should have a look at how the data got into final.df
in the first place.

Good luck,
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 167 1972
Date: 26-Aug-04                                       Time: 09:43:10
------------------------------ XFMail ------------------------------

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to