Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #8976 > unrolled thread
| Started by | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| First post | 2012-03-12 09:11 +0000 |
| Last post | 2012-03-13 08:06 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Dynamically create Select criteria Bob Hanlon <hanlonr357@gmail.com> - 2012-03-12 09:11 +0000
Re: Dynamically create Select criteria Jack McInerney <ejmcinerney@gmail.com> - 2012-03-13 08:06 +0000
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Date | 2012-03-12 09:11 +0000 |
| Subject | Re: Dynamically create Select criteria |
| Message-ID | <jjkek8$1cb$1@smc.vnet.net> |
data = {
{"Fido", "dog", 8},
{"Sparky", "dog", 2},
{"Shadow", "cat", 1},
{"Cuddles", "cat", 3},
{"Cutey", "rabbit", 1}};
types = Union[data[[All, 2]]];
ages = Union[data[[All, 3]]];
Manipulate[selection = Select[data,
(age != {} || type != {}) &&
(age != {} && type == {} ||
MemberQ[type, #[[2]]]) &&
(type != {} && age == {} ||
MemberQ[age, #[[3]]]) &],
{{type, {}, Style["Type", Blue, 12]}, types},
{{age, {}, Style["Age", Blue, 12]}, ages},
ControlType -> CheckboxBar]
Dynamic[selection]
Bob Hanlon
On Fri, Mar 9, 2012 at 6:10 AM, Jack McInerney <ejmcinerney@gmail.com> wrote:
> I have a database in the form of a big list, and want to select a
> subset of this list, by allowing the user to click on checkboxes. The
> example below shows the idea. Given a list of animals, lets say I
> want to select all the cats that are 1 year old, or all of the dogs
> and cats. I can't figure out how to use the output of my checkboxes
> to dynamically create a selection criteria for the Select function.
> Is this possible? Any thoughts would be appreciated.
>
> data={{"fido", "dog",8},
> {"Sparky", "dog",2},
> {"Shadow", "cat",1},
> {"Cuddles", "cat",3},
> {"Cutey", "rabbit",1}};
>
> CheckboxBar[Dynamic[type], DeleteDuplicates[data[[All,2]] ]]
>
> CheckboxBar[Dynamic[age], Sort[DeleteDuplicates[data[[All,3]] ]]]
>
> Dynamic[Select[data, #[[2]]==type[[1]] && #[[3]]==age[[1]]&]] (*<--
> criteria should depend on which boxes have been checked by user *)
>
>
> Thanks,
> Jack
[toc] | [next] | [standalone]
| From | Jack McInerney <ejmcinerney@gmail.com> |
|---|---|
| Date | 2012-03-13 08:06 +0000 |
| Message-ID | <jjmv5r$chm$1@smc.vnet.net> |
| In reply to | #8976 |
On Mar 12, 2:11 am, Bob Hanlon <hanlonr...@gmail.com> wrote:
> data = {
> {"Fido", "dog", 8},
> {"Sparky", "dog", 2},
> {"Shadow", "cat", 1},
> {"Cuddles", "cat", 3},
> {"Cutey", "rabbit", 1}};
>
> types = Union[data[[All, 2]]];
>
> ages = Union[data[[All, 3]]];
>
> Manipulate[selection = Select[data,
> (age != {} || type != {}) &&
> (age != {} && type == {} ||
> MemberQ[type, #[[2]]]) &&
> (type != {} && age == {} ||
> MemberQ[age, #[[3]]]) &],
> {{type, {}, Style["Type", Blue, 12]}, types},
> {{age, {}, Style["Age", Blue, 12]}, ages},
> ControlType -> CheckboxBar]
>
> Dynamic[selection]
>
> Bob Hanlon
>
>
>
> On Fri, Mar 9, 2012 at 6:10 AM, Jack McInerney <ejmciner...@gmail.com> wrote:
> > I have a database in the form of a big list, and want to select a
> > subset of this list, by allowing the user to click on checkboxes. The
> > example below shows the idea. Given a list of animals, lets say I
> > want to select all the cats that are 1 year old, or all of the dogs
> > and cats. I can't figure out how to use the output of my checkboxes
> > to dynamically create a selection criteria for the Select function.
> > Is this possible? Any thoughts would be appreciated.
>
> > data={{"fido", "dog",8},
> > {"Sparky", "dog",2},
> > {"Shadow", "cat",1},
> > {"Cuddles", "cat",3},
> > {"Cutey", "rabbit",1}};
>
> > CheckboxBar[Dynamic[type], DeleteDuplicates[data[[All,2]] ]]
>
> > CheckboxBar[Dynamic[age], Sort[DeleteDuplicates[data[[All,3]] ]]]
>
> > Dynamic[Select[data, #[[2]]==type[[1]] && #[[3]]==age[[1]]&]] (*<--
> > criteria should depend on which boxes have been checked by user *)
>
> > Thanks,
> > Jack- Hide quoted text -
>
> - Show quoted text -
Hi Bob,
This is an amazing piece of Mathematica code you produced. It works
perfectly, but I have only a partial grasp on how it works. I will
need to study it some more. A lot more...
Jack
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web