Summarizing timetable data when categorical variables are present

3 views (last 30 days)
I have a table with repeating timestamped ('long-form') data and categorical variables that are assigned to each measurement (in this case temperature and humidity). What I want to do is summarize daily means while nesting within the categorical variables. Is this possible to do using the retime function?
'06/01/2015 00:00' 9.16300000000000 100 'Control' 'C1' 'S1' 'Open' 'Treatment' 'Year 0'
'06/01/2015 00:15' 9.21300000000000 100 'Control' 'C1' 'S1' 'Open' 'Treatment' 'Year 0'
'06/01/2015 00:30' 9.21300000000000 100 'Control' 'C1' 'S1' 'Open' 'Treatment' 'Year 0'
'06/01/2015 00:45' 9.16300000000000 100 'Control' 'C1' 'S1' 'Open' 'Treatment' 'Year 0'
'06/01/2015 01:00' 9.06400000000000 100 'Control' 'C1' 'S1' 'Open' 'Treatment' 'Year 0'
'06/01/2015 01:15' 8.81700000000000 100 'Control' 'C1' 'S1' 'Open' 'Treatment' 'Year 0'
'06/01/2015 01:30' 8.71700000000000 100 'Control' 'C1' 'S1' 'Open' 'Treatment' 'Year 0'

Answers (2)

Walter Roberson
Walter Roberson on 1 Dec 2018

Peter Perkins
Peter Perkins on 11 Dec 2018
Cameron, the answer is not really. retime is all about time.
I thik what you want is something like varfun using time and some other variable(s) as GroupingVariables, or as Walter suggests, findgroups and splitapply.
Also, it looks like you have categorical data, but stored as text variables. You might be happier if you explicitly converted those text vars to be categoricals.
  4 Comments
Walter Roberson
Walter Roberson on 5 Sep 2020
When you use splitapply() with a table() object, the function is passed one parameter for each table variable.
Perhaps
splitapply(@(varargin)retimeMonthly(cell2table(varargin, 'VariableNames', TT.Properties.VariableNames), TT, groups)
Christopher Lawson
Christopher Lawson on 10 Sep 2020
Thanks, I had success with this
splitapply(@(varargin)retimeMonthly(table(varargin{1,:}, 'VariableNames', t.Properties.VariableNames)), t, groups)
(but I also had to "re-timeable" the function argument inside the retimeMontly.
THANK YOU!

Sign in to comment.

Categories

Find more on Tables in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!