1
$\begingroup$

I've imported a table using the following:

dataset = Dataset[SemanticImport["C:/Downloads/test.xlsx"]]

Then I am using Manipulate as follows:

Manipulate[ dataset [Select [ #C1 > n1 & ]], {n1, 1, 100}]

I would like to concurrently do likewise for a second column, C2. So there would be two sliders. That would require putting in an "AND", and basically a repeat of the Select, except this time using C2 and n2.

Here are the first few lines of the dataset:

X   C1  C2
_22704_1    53  97
_21801_0    28  47
_21405_0    2   25
_21506_0    58  49
_21704_1    93  65
_21504_0    64  46
_21101_0    9   6
_21301_0    72  90
_23003_0    14  20

Can someone please tell me how to write the compound command? Hopefully extensible for far more than just two columns.

Thanks, Nicholas Kormanik


Thought the following looked logical and would work. But, no. Error message: Too few arguments given. (??)

Manipulate[
dataset[
Select[
And[
#C1 > n1 &, {n1, 1, 100}, 
#C2 > n2 &, {n2, 1, 100}
]]]]

@Kuba, your suggestion above didn't work. Please offer another? Manipulate is essential to this problem, by the way.

$\endgroup$
3
  • $\begingroup$ To where are you referring, @Kuba? I haven't been able to find any examples of such. reference.wolfram.com/language/ref/Select.html $\endgroup$
    – nkormanik
    Feb 22, 2017 at 11:24
  • $\begingroup$ Mod[#, 3] == 1 && Mod[#, 5] == 1 & - isn't this a compound condition? $\endgroup$
    – Kuba
    Feb 22, 2017 at 11:25
  • $\begingroup$ Not familiar with that one. Care to show with above coding I provided? Thanks. $\endgroup$
    – nkormanik
    Feb 22, 2017 at 11:27

1 Answer 1

4
$\begingroup$
tr = "X   C1  C2
 _22704_1    53  97
 _21801_0    28  47
 _21405_0    2   25
 _21506_0    58  49
 _21704_1    93  65
 _21504_0    64  46
 _21101_0    9   6
 _21301_0    72  90
 _23003_0    14  20"

You say my suggestion didn't work but I don't see you using it. Moreover, where did you get a tip to use , {n1, 1, 100} inside select. Please focus on documentation of all related symbols, like Select, And, Manipulate.

dataset =  Dataset@(
   Function[triplet,  AssociationThread[# -> triplet]] /@ {##2}
) & @@  ImportString[tr, "Table"] 


Manipulate[
 dataset[Select[And[#C1 > n1, #C2 > n2] &]], 
 {n1, 1, 100}, 
 {n2, 1, 100}
]

enter image description here

$\endgroup$
3
  • $\begingroup$ Great job, @Kuba. I've been thoroughly frustrated all day trying different arrangements. $\endgroup$
    – nkormanik
    Feb 23, 2017 at 11:35
  • $\begingroup$ The following arrangement works as well: Manipulate[ Select[dataset, #C1 > n1 && #C2 > n2 &], {n1, 1, 100}, {n2, 1, 100}] $\endgroup$
    – nkormanik
    Feb 23, 2017 at 23:19
  • $\begingroup$ Just curious, @Kuba, you chose to use a much longer more complex Import method than SemanticImport. Is there any reason to not use SemanticImport to quickly grab a simple Excel spreadsheet? As the actual spreadsheets I'm dealing with have many columns and rows, not sure I could configure what you've done for the cases at hand. Guidance appreciated. $\endgroup$
    – nkormanik
    Feb 23, 2017 at 23:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.