Re: Re: Mathematica 6.0: How to collect data with Manipulate?

• To: mathgroup at smc.vnet.net
• Subject: [mg93317] Re: [mg93309] Re: Mathematica 6.0: How to collect data with Manipulate?
• From: "David Park" <djmpark at comcast.net>
• Date: Tue, 4 Nov 2008 06:14:22 -0500 (EST)
• References: <gebm2r\$gp\$1@smc.vnet.net> <32402353.1225710121049.JavaMail.root@m02>

```Marc,

Throw Manipulate in the ashcan.

It is quite a lot of work to design and program good data collection
systems, but here is a reasonable start.

First, I think you need a key for each record so the record can be
identified, retrieved and updated or deleted. In this case I am going to use
the name of the person as the key. A fancier system would have data
checking, and perhaps a message box to indicate actions that couldn't be
completed. Here are the bare bones.

First some sample data:

datacollection =
{{"Able, James", 25, "alone", "protestant"}, {"Baker, Bob", 30,
"not alone", "rational"}, {"Smith, Ted", 50, "not alone",
"islamic"}};

The following generates the data collection form that updates the
datacollection set. The 'New' button will clear the current record. 'Insert'
will insert the current record in datacollection after checking that it is
not a duplicate. 'Fetch' will retrieve an existing record by name. 'Update'
will replace an existing record in datacollection by name. 'Delete' will
delete an existing record in datacollection by name.

Module[
{name = Null, age = Null, livingalone = Null, religion = Null,
recordnumber, findrecordnumber},

findrecordnumber[name_] :=
Module[{pos},
pos = Position[datacollection, {name, __}];
If[pos === {}, False, Part[pos, 1, 1]]
];

Panel[
Column[
{Row[
{"Name: ",
InputField[Dynamic[name], String, FieldSize -> {8, 1.2}],
Spacer[10],
Button["New", {name, age, livingalone, religion} = {Null, Null,
Null, Null}],
Spacer[10],
Button["Insert", recordnumber = findrecordnumber[name];
If[recordnumber === False,
AppendTo[
datacollection, {name, age, livingalone, religion}]]],
Spacer[10], Button["Fetch",
recordnumber = findrecordnumber[name];
If[
recordnumber =!= False, {name, age, livingalone, religion } =
Part[datacollection, recordnumber]]],
Spacer[10], Button["Update",
recordnumber = findrecordnumber[name];
If[recordnumber =!= False,
datacollection[[recordnumber]] = {name, age, livingalone,
religion }]],
Spacer[10], Button["Delete",
recordnumber = findrecordnumber[name];
If[recordnumber =!= False,
datacollection[[recordnumber]] = Sequence[]]]
}] (* name row *),
Row[
{"Age: ", InputField[Dynamic[age], FieldSize -> {3, 1.2}]}](*
age row *),
Row[
{"Living Alone: ",
SetterBar[Dynamic[livingalone], {"alone" -> "alone",
"not alone" -> "not alone",
Null -> "Clear"}]}](* livealone row *),
Row[
{"Religion: ", SetterBar[Dynamic[religion],
{"protestant" -> "protestant",
"catholic" -> "catholic",
"islamic" -> "islamic",
"rational" -> "rational",
Null -> "Clear"}]}](* religion row *)
}](*  Column *),
Style["Data Collection Form", 16]
](* Panel *)
]

datacollection

David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark

From: Marc Heusser
[mailto:marc.heusser at byeheusser.commercialspammers.invalid]

In article <gebm2r\$gp\$1 at smc.vnet.net>,
Marc Heusser <marc.heusser at byeheusser.commercialspammers.invalid>
wrote:

> I need to collect data, do statistical analyses and create graphics for
> the results for my MD thesis (suicides in elderly people).
>
> This means maybe 1500 cases with many variables known like age,
> residence address, religion, method etc ...
>
> The data must be collected, ie exists in paper form only.
>
> I just got Mathematica 6, and found nice user interface options.

like Manipulate.

> I'd like using Mathematica to build a data collection mask
> (ie one case, with drop boxes for most data, checking eg birth date for
> validity etc), and collecting those 1500 cases with it in a notebook or
> external file ...

I have played with Mathematica 6 for a few hours and come as far as
this, but now I am stuck:

dataRaw = Manipulate[{ age, livingAlone, religion},
{age, 60, 120, 1},
Delimiter, {{livingAlone, "alone", "living alone"}, {"alone",
"not alone"}},
{{religion, "catholic"}, {"protestant", "catholic", "islamic",
"unknown"}}
]

This displays a graphical representation of the above, and a result of
eg {60,"alone","catholic"} inside the graphical representation.

How would I go about to either

take an element of a case list containing such lists of items per case,
display them like above with the possibility to change some items, and
then store this list again at the same place in the case list
(ie how to get data into Manipulate - and out of it again)

or

create a new element of the case list with input such as the above
Manipulate?

TIA

Marc

--
remove bye and from mercial to get valid e-mail
<http://www.heusser.com>

```

• Prev by Date: Re: Expressions with ellipsis (...)
• Next by Date: Re: Trinomial decics x^10+ax+b = 0; Help with Mathematica code
• Previous by thread: Re: Mathematica 6.0: How to collect data with Manipulate?
• Next by thread: Data fitting from coupled differential equations