How do I add column headers (variable names) to a dummyvar table?

조회 수: 17 (최근 30일)
Douglas Leaffer
Douglas Leaffer 2023년 6월 13일
편집: Matt J 2023년 6월 13일
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
Matt J
Matt J 2023년 6월 13일
편집: Matt J 2023년 6월 13일
please Run your code here in the forum, using the instructions in the link I gave you. Example,
T=array2table(rand(5,3))
T = 5×3 table
Var1 Var2 Var3 _______ _______ _______ 0.7859 0.65929 0.65119 0.25801 0.1189 0.7871 0.1786 0.42362 0.54381 0.84239 0.74138 0.20506 0.79453 0.51149 0.8186
newvar=rand(5,1);
T=addvars(T,newvar)
T = 5×4 table
Var1 Var2 Var3 newvar _______ _______ _______ ________ 0.7859 0.65929 0.65119 0.91629 0.25801 0.1189 0.7871 0.82619 0.1786 0.42362 0.54381 0.16378 0.84239 0.74138 0.20506 0.1588 0.79453 0.51149 0.8186 0.088069

댓글을 달려면 로그인하십시오.

답변 (1개)

Douglas Leaffer
Douglas Leaffer 2023년 6월 13일
이동: Image Analyst 2023년 6월 13일
Code file is too large to upload ... ... I did it the 'brute force' method
WindOther = tbl.WindOther; WindRail = tbl.WindRail;
WindAirport = tbl.WindAirport; WindRoad = tbl.WindRoad;
IW = table2array(tbl,'VariableNames', {'WindOther','WindRail','WindAirport','WindRoad'});
%IW = tbl{:,:}; % table of wind impact dummyvars
CMET4 = addvars(CMET3, WindAirport, WindRoad, WindRail, WindOther );

카테고리

Help CenterFile Exchange에서 Analysis of Variance and Covariance에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by