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'

回答(2 个)

Walter Roberson
Walter Roberson 2018-12-1

Peter Perkins
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
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
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!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by