| Contents | Index |
Unique observations in dataset array
Note In a future release, the behavior of dataset.unique will change to be consistent with the MATLAB function unique. This behavior change is optional in R2012a. For a demonstration of using the 'R2012a' flag to preview the future behavior, or the 'legacy' flag to preserve the current behavior in your existing code, see the documentation for unique. |
C = unique(A)
[C,ia,ic] = unique(A)
C = unique(A,vars)
[C,ia,ic] = unique(A,vars)
[...] = unique(A,vars,occurrence)
[...] = unique(...,'R2012a')
[...] = unique(...,'legacy')
[...] = unique(A,vars,setOrder)
C = unique(A) returns a copy of the dataset A that contains only the sorted unique observations. A must contain only variables whose class has a unique method, including:
numeric
character
logical
categorical
cell arrays of strings
For a variable with multiple columns, its class's unique method must support the 'rows' flag.
[C,ia,ic] = unique(A) also returns index vectors ia and ic such that C = A(ia,:) and A = C(ic,:).
C = unique(A,vars) returns a dataset that contains only one observation for each unique combination of values for the variables in A specified in vars. vars is a positive integer, a vector of positive integers, a variable name, a cell array containing one or more variable names, or a logical vector. C includes all variables from A. The values in C for the variables not specified in vars are taken from the last occurrence among observations in A with each unique combination of values for the variables specified in vars.
[C,ia,ic] = unique(A,vars) also returns index vectors ia and ic such that C = A(ia,:) and A(:,vars) = C(ic,vars).
[...] = unique(A,vars,occurrence) specifies which index is returned in ia in the case of repeated observations in A. The default value is occurrence='last', which returns the index of the last occurrence of each repeated observation in A. occurrence='first' returns the index of the first occurrence of each repeated observation in A. The values in C for variables not specified in vars are taken from the observations A(ia,:). Specify vars as [] to use the default value of all variables.
[...] = unique(...,'R2012a') adopts the future behavior of unique. You can specify the flag as the final argument with any previous syntax that accepts A, vars, or occurrence.
[...] = unique(...,'legacy') preserves the current behavior of unique. You can specify the flag as the final argument with any previous syntax that accepts A, vars, or occurrence.
[...] = unique(A,vars,setOrder) returns the observations of C in a specific order. setOrder='sorted' returns the values of C in sorted order. setOrder='stable' returns the values of C in the same order as A. If there are repeated observations in A, then ia returns the index of the first occurrence of each repeated observation. Specify vars as [] to use the default value of all variables.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |