Filter löschen
Filter löschen

dataset create categorical variables from existing variable

2 Ansichten (letzte 30 Tage)
jonas
jonas am 15 Mär. 2013
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

Antworten (1)

Tom Lane
Tom Lane am 15 Mär. 2013
Start with this and see if it gets you anywhere:
d = dataset;
d.a = (ds=='a')

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by