Not able to make dummy variables
이전 댓글 표시
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?

답변 (1개)
C = readcell('data.csv')
dummy_gender = strcmp(C(2:end,4),'''M''')
댓글 수: 2
Malene Brautaset
2022년 3월 25일
You're welcome!
Sure, here is a table version:
T = readtable('data.csv')
dummy_gender = strcmp(T{:,'gender'},'''M''')
카테고리
도움말 센터 및 File Exchange에서 Tables에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!