|
James, the behavior of NOMINAL here is intentional. Just because you've
removed all elements whose value is 'James', doesn't mean the vector no
longer "knows" that 'James' is a value it should care about. Imagine,
for example, that you had done this:
> ds1 = ds(ds.Height < 180, :);
> summary(ds1.Name)
> ds2 = ds(ds.Height < 170, :);
> summary(ds2.Name)
You'd want both of thos to return 3 counts, right? Otherwise the length
of table would be data-dependent. That's a bit artificial, but tere are
lots of other similar situations.
The DROPLEVELS method, with one input, will remove any levels for which
there are no elements having that value. So another way to do what you
did would be
ds.Name = droplevels(ds.Name);
Hope this helps.
On 6/30/2011 5:44 AM, James wrote:
> I'm wondering if this is a case of sloppy coding or something that
> shouldn't be happening
>
> % Create a dataset
> ds = dataset({{'Henri'; 'John'; 'James'}, 'Name'}, {[175; 168; 180]
> 'Height'});
> ds.Name = nominal(ds.Name);
>
> % Remove a name
> ds = ds(ds.Name ~= 'James', :);
>
> %..and it's still there (in a sense)
> getlabels(ds.Name)
>
> % I need to rename to solve the problem
> ds.Name = nominal(ds.Name);
> getlabels(ds.Name)
|