Not able to make dummy variables
Mostrar comentarios más antiguos
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?

Respuestas (1)
C = readcell('data.csv')
dummy_gender = strcmp(C(2:end,4),'''M''')
2 comentarios
Malene Brautaset
el 25 de Mzo. de 2022
You're welcome!
Sure, here is a table version:
T = readtable('data.csv')
dummy_gender = strcmp(T{:,'gender'},'''M''')
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!