s-news
[Top] [All Lists]

Working with menu()

To: <s-news@lists.biostat.wustl.edu>
Subject: Working with menu()
From: "Jon Monteleone" <monte@ihug.co.nz>
Date: Mon, 28 Apr 2003 15:46:19 +1200
Reply-to: "Jon Monteleone" <monte@ihug.co.nz>
Greetings,
I want to create a dynamic menu that allows selecting different data files for further analysis.
 
Here is the input file, minval.out
DC200d100r_a15cl00.tmp    -9.14    3.19
DC200d100r_p15cl00.tmp    -8.38    1.35
DC200d100r_m15cl00.tmp   -6.69    2.64
...
100 files in all
 
I read this file into s-plus
minval.table <- read.table("minval.out",row.names=NULL,col.names=c("scenario","DOPTmin","MSEmin"))
 
 
I would like to use column 1 to dynamically create a choice list for menu().  Currently, I am hardcoding the filenames.
 
cat("\nSELECT SCENARIOS FOR SURFACE COMPARISON\n")
choices <- c("Done adding scenarios","List selected scenarios","DC200d100r_a15cl00","DC200d100r_p15cl00", 
                   "DC200d100r_m15cl00")
pick <- menu(choices)
switch(pick,
           return(),
          select.list(),
          add.scenario(minval.table[1,1]),
          add.scenario(minval.table[2,1]),
          add.scenario(minval.table[3,1]))
Recall()
Problems I am having...
1) How do I translate minval.table column 1 into a vector - c(file1,file2,...), for use with menu()?
2) In switch(), I want to use add.scenario(file1) instead of hardcoding minval.table[1,1]
 
I know the latest versions of splus have GUI features for creating drop down boxes that would allow what I want, but I have no experience with working with the GUI scripting features.
 
Any help is appreciated.
Cheers -Jon
---
Jonathan Monteleone (MS), j.monteleone@auckland.ac.nz
Dept of Pharmacology & Clinical Pharmacology, School of Medicine
85 Park Rd, Private Bag 92019, Auckland, New Zealand
Work phone: +64 (9) 3737599 ext 86732
Pharmacometric Resources at
http://www.health.auckland.ac.nz/pharmacology/staff/nholford/pkpd/pkpd.htm
---
<Prev in Thread] Current Thread [Next in Thread>
  • Working with menu(), Jon Monteleone <=