Not able to make dummy variables
Ältere Kommentare anzeigen
Hello.
We have a problem making dummy variables since our variables has ' ' around them ('M'). We have a column with 'M' and 'F' and have to make dummy variables in order to use it in our regression.
How do we fix this?

Antworten (1)
C = readcell('data.csv')
dummy_gender = strcmp(C(2:end,4),'''M''')
2 Kommentare
Malene Brautaset
am 25 Mär. 2022
You're welcome!
Sure, here is a table version:
T = readtable('data.csv')
dummy_gender = strcmp(T{:,'gender'},'''M''')
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!