dataset create categorical variables from existing variable
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi I have a dataset containing a column(variable) of strings. From this strings I want to ad new variables of the uniqe string and create a categorical variable of it. Here is an example of what I want to do: ds=['a';'b';'c';'a';'a';'b';'c']. Final result I want is a dataset with a,b and c as added categorical variables to the dataset and as observations assign the values 0 and 1. So The categorical variabel a in the dataset should be a new column in ds a [1;0;0;0;1;1;0;0], b [0;1;0;0;0;0;1;0], c [0;0;1;0;0;0;0;1].
Please help
0 commentaires
Réponses (1)
Tom Lane
le 15 Mar 2013
Start with this and see if it gets you anywhere:
d = dataset;
d.a = (ds=='a')
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!