09-26-2017 10:09 AM
Hi -
I am hoping to understand a simple way to calculate grouped summary stats from a table. I'd like to calculate mean, standard deviation, and a number of quantiles (1%,2%, 5%, etc.) from a table. I'd like these results to be grouped by other fields in the table. I am providing a very simple example, but would like to be able to perform this calculation in an efficient way so that it works well for more complicated data sets. My data sets have many grouped by terms and are not sorted by the grouping parameters.
In the example below, I'm showing how to calculate average values grouped by name. I know I could sort them by name and look for changes in this parameter, then use those indeces to create subarrays and calculate averages from there. I would prefer to use a function designed for this purpose like those available in SQL (minus the quantiles), JMP, and matlab.
Maybe the answer is use the mathscript function, but I've had issues with those mathscript windows being buggy in the past.
Is there a clean labview function which can perform these calculations?
Thanks,
Jennifer
Name | Value | Avg |
John | 0.537456 | 0.577731 |
John | 0.91844 | |
John | 0.279187 | |
John | 0.758893 | |
John | 0.394678 | |
Mary | 0.007313 | 0.486202 |
Mary | 0.935343 | |
Mary | 0.432797 | |
Mary | 0.569353 |
Solved! Go to Solution.
09-26-2017 10:53 AM - edited 09-26-2017 10:54 AM
You can do some interesting things using Variant Attributes.
09-26-2017 11:06 AM
Crossrulz beat me to it but variant attributes seems like a good solution here, since you can define the attributes to be any datatype. I'll have to remember this for my own use as well.
09-26-2017 11:18 AM
I get an error?
09-26-2017 11:25 AM - edited 09-26-2017 11:26 AM
I think the first Get Attribute needs an array, not a single value. Crossrulz has auto-indexing turned on for it but I think that was an oversight.
09-26-2017 11:26 AM
I had the empty array hooked to it, but then that for loop doesn't run and the mean/std/name arrays end up empty.
09-26-2017 11:28 AM
attached vi and example data set
09-26-2017 11:36 AM
Sorry, I can't open your VI but this is what I have for the first loop which stores the values into the variant. Like I said, Crossrulz is the same as this except he has auto-indexing turned on for the empty array. It should be turned off so that the datatype stored into the variant is an array.
09-26-2017 11:38 AM
Thanks all! That worked.
09-26-2017 12:21 PM
@aputman wrote:
I think the first Get Attribute needs an array, not a single value. Crossrulz has auto-indexing turned on for it but I think that was an oversight.
Weird. I specifically remember turning that autoindexing tunnel off. Oh well. We got there eventually.