[ 
https://issues.apache.org/jira/browse/KNOX-2052?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16944810#comment-16944810
 ] 

Ljmiv commented on KNOX-2052:
-----------------------------

[~krisden] [~smolnar] I've hit a wall with this and want to see if you guys 
have any ideas. In order to use the Apache Commons math library, columns needs 
to be converted from lists of Comparable to double arrays, which requires that 
each Comparable datapoint be sent toString in order for it to then be parsed to 
Double. You can see my code below, which even though it's ugly and expensive, 
is the only way I can currently get it to work. Is there any other way to 
convert from Comparable to double?

 

  *public* *double*[] toArray(String colName) {

      List<Comparable<? *extends* Object>> col = values(colName);

      *double*[] colArray = *new* *double*[col.size()];

      *for* (*int* i = 0; i < col.size(); i++) {

          colArray[i] = Double.parseDouble(col.get(i).toString());

      }

      *return* colArray;

  }

> KnoxShellTable mean, median, and mode methods
> ---------------------------------------------
>
>                 Key: KNOX-2052
>                 URL: https://issues.apache.org/jira/browse/KNOX-2052
>             Project: Apache Knox
>          Issue Type: Improvement
>          Components: KnoxShell
>            Reporter: Ljmiv
>            Assignee: Ljmiv
>            Priority: Major
>             Fix For: 1.4.0
>
>
> Would be beneficial to be able to get the mean, median, and mode values from 
> columns in a table. No such functions exist as of now. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to