How do I add column headers (variable names) to a dummyvar table?
Mostrar comentarios más antiguos
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 comentarios
Douglas Leaffer
el 13 de Jun. de 2023
Douglas Leaffer
el 13 de Jun. de 2023
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
el 13 de Jun. de 2023
@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
el 13 de Jun. de 2023
@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
el 13 de Jun. de 2023
Respuestas (1)
Douglas Leaffer
el 13 de Jun. de 2023
Movida: Image Analyst
el 13 de Jun. de 2023
Categorías
Más información sobre Analysis of Variance and Covariance en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
