MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

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


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", 

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.

 {name = Null, age = Null, livingalone = Null, religion = Null, 
  recordnumber, findrecordnumber},
 findrecordnumber[name_] :=
   pos = Position[datacollection, {name, __}];
   If[pos === {}, False, Part[pos, 1, 1]]
     {"Name: ",
      InputField[Dynamic[name], String, FieldSize -> {8, 1.2}],
      Button["New", {name, age, livingalone, religion} = {Null, Null, 
         Null, Null}],
      Button["Insert", recordnumber = findrecordnumber[name];
       If[recordnumber === False, 
         datacollection, {name, age, livingalone, religion}]]],
      Spacer[10], Button["Fetch",
       recordnumber = findrecordnumber[name];
        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 *),
     {"Age: ", InputField[Dynamic[age], FieldSize -> {3, 1.2}]}](* 
    age row *),
     {"Living Alone: ", 
      SetterBar[Dynamic[livingalone], {"alone" -> "alone",
        "not alone" -> "not alone",
        Null -> "Clear"}]}](* livealone row *),
     {"Religion: ", SetterBar[Dynamic[religion],
       {"protestant" -> "protestant",
        "catholic" -> "catholic",
        "islamic" -> "islamic",
        "rational" -> "rational",
        Null -> "Clear"}]}](* religion row *)
    }](*  Column *),
  Style["Data Collection Form", 16]
  ](* Panel *)


David Park
djmpark at 

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

In article <gebm2r$gp$1 at>,
 Marc Heusser <marc.heusser at byeheusser.commercialspammers.invalid> 

> 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", 

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)


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



remove bye and from mercial to get valid e-mail

  • 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