How do I add column headers (variable names) to a dummyvar table?
古いコメントを表示
I could use some help adding column headers (variable names) to a dummyvar table? My code is attached. The table (tbl) once converted to an array, below, shows only 1 column header, but I need to show 4 distinct column headers and then add that matrix to another table. Thank you.
tempSector = dummyvar(categorical(ImpactWind));
WindOther = tempSector(:,1);
WindRail = tempSector(:,2);
WindAirport = tempSector(:,3);
WindRoad = tempSector(:,4);
tbl = table(WindOther,WindRail,WindAirport,WindRoad);
% tbl.Properties.VariableNames = {'WindOther','WindRail','WindAirport','WindRoad'};
IW = tbl{:,:}; % IW = table of ImpactWind dummyvars
CMET4 = addvars(CMET3, IW); % CMET3 is a matrix of other meterological parameters
8 件のコメント
Douglas Leaffer
2023 年 6 月 13 日
Douglas Leaffer
2023 年 6 月 13 日
Let me try to run it:
tempSector = dummyvar(categorical(ImpactWind));
WindOther = tempSector(:,1);
WindRail = tempSector(:,2);
WindAirport = tempSector(:,3);
WindRoad = tempSector(:,4);
tbl = table(WindOther,WindRail,WindAirport,WindRoad);
% tbl.Properties.VariableNames = {'WindOther','WindRail','WindAirport','WindRoad'};
IW = tbl{:,:}; % IW = table of ImpactWind dummyvars
CMET4 = addvars(CMET3, IW); % CMET3 is a matrix of other meterological parameters
Oops! It looks like you forgot to attach data. We'll check back later. In the meantime, setting properties and using addvars should work.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Deepak Gupta
2023 年 6 月 13 日
@Image Analyst I don't think you need data to understand the problem user is trying to demostrate. It's evidently clear from the output and writeup he has written.
Deepak Gupta
2023 年 6 月 13 日
@Douglas Leaffer Simplest way to do it is convert your table back to an array using x = table2array(CMET4) and than convert back to a table y = array2table(x). It will separate out each column. You can assign new variable names using y.Properties.VariableNames = {'a' 'b' 'c' 'd' 'e'}
Douglas Leaffer
2023 年 6 月 13 日
回答 (1 件)
Douglas Leaffer
2023 年 6 月 13 日
移動済み: Image Analyst
2023 年 6 月 13 日
カテゴリ
ヘルプ センター および File Exchange で Analysis of Variance and Covariance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
