How do I split a table into multiple sub-tables based on the frequency of a variable?
Mostrar comentarios más antiguos
I have an existing table and would like to make subsets of this table conditionally based on how often entries appear in one of the variables. How do I do this?
For instance, if I have table, T, and in variable Var1, entries A, B, C, and D appear with frequency 1,1,2,3, respectively:
>> Var1 = ["A";"B";"C";"C";"D";"D";"D"];
>> Var2 = ["data1";"data2";"data3";"data4";"data5";"data6";"data7"];
>> T = table(Var1,Var2)
T =
7×2 table
Var1 Var2
____ _______
A "data1"
B "data2"
C "data3"
C "data4"
D "data5"
D "data6"
D "data7"
I would like to obtain table which would include the rows with frequency of 1 from T (A and B), another table with the entries that had a frequency of 2 (C), and a table with entries that had a frequency of 3 (D).
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!