Azzera filtri
Azzera filtri

Error using matlab.int​ernal.math​.checkData​Variables Invalid grouping variables.

14 visualizzazioni (ultimi 30 giorni)
kindly help me solve this issue
load("stormData");
summaryRegionCosts = groupsummary(stormData, "stormData.Region",['min','max','median','mean'] , "stormData.Total_Cost")
stormDataPos = stormData.Total_cost> 0
summaryRegionPosCosts = groupsummary(stormData, "stormData.Region", ['min','max','median','mean'],"stormData.stormDataPos")
  1 Commento
Juan Carlos Hernandez
Juan Carlos Hernandez il 18 Feb 2023
Hi,
Here is your problem solved:
load("stormData");
summaryRegionCosts=groupsummary(stormData,"Region",["min","median","mean","max"],"Total_Cost")
stormDataPos=stormData(stormData.Total_Cost>=1,:)
summaryRegionPosCosts=groupsummary(stormDataPos,"Region",{"min","median","mean","max"},"Total_Cost")

Accedi per commentare.

Risposte (1)

Steven Lord
Steven Lord il 20 Ago 2022
The second input for the groupsummary function as you're calling it should be the name of a variable in your table. "stormData.Region" isn't the name of a variable, it's an expression that would extract a variable in the table. Try using just "Region" in your call instead.
  15 Commenti
Walter Roberson
Walter Roberson il 23 Ago 2022
You are attempting to pass in a logical mask stormDatapos as the 4th parameter to groupsummary, with the first parameter being a table
When you use 4 parameters to groupsummary and the first one is a table, the permitted syntaxes are
G = groupsummary(T,GROUPVARS,GROUPBINS,METHOD)
G = groupsummary(T,GROUPVARS,METHOD,DATAVARS)
Your {'min', 'max', 'median', 'mean'} or ["min", "max", "median", "mean"] is not grouping bins, so the first of the two possibilities does not apply.
Your logical vector is not a data variable name within the table, so the second of the two possibilities does not appy.
If you want to summarize only for a subset of a table, you need to construct the subset first and summarize on it. For example,
sdss = stormData(stormDataPos, :);
summaryRegionPostCosts = groupsummary(sdss, "Region", ["min", "max", "median", "mean"])
In practice you will probably need to add a list of variables to apply the summary to, as it is not clear that taking mean() of your categorical SuperRegion is meaningful.

Accedi per commentare.

Prodotti


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by