[R] Reimplement order somehow

XpeH sw0rdf1sh_i at yahoo.com
Wed Oct 3 17:32:48 CEST 2007


I have found how to reimplement order method from R language in PHP:

<?php

$str = "0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11
11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 13 13
13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 255 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8
8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9";

$array = explode(" ", $str);
foreach ($array as $key => $value) {
    $array_new[$key + 1] = $value;
}

$array = $array_new;

print "\n ------\n";
$uniq_arr = array_unique($array);
ksort($uniq_arr);

foreach ($array as $key => $value) {
    if ($key !== ($key +1)) {
        $array[$key] = $value;
    }
    print " $array[$key]";
}

?>
-- 
View this message in context: http://www.nabble.com/Reimplement-order-somehow-tf4561576.html#a13021346
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list