Not able to make dummy variables
Afficher commentaires plus anciens
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?

Réponses (1)
C = readcell('data.csv')
dummy_gender = strcmp(C(2:end,4),'''M''')
2 commentaires
Malene Brautaset
le 25 Mar 2022
You're welcome!
Sure, here is a table version:
T = readtable('data.csv')
dummy_gender = strcmp(T{:,'gender'},'''M''')
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!