Summarizing timetable data when categorical variables are present
3 次查看(过去 30 天)
显示 更早的评论
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'
0 个评论
回答(2 个)
Peter Perkins
2018-12-11
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 个评论
Walter Roberson
2020-9-5
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
2020-9-10
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!
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!