On Mon, 8 Sep 2014 07:55:23 -0700
William Dunlap <wdun...@tibco.com> wrote:

Again, feed the output of menu() directly into "[".  Do not use
switch(). Bill Dunlap

The function was changed to:

testdataextract1<-function (testdata) {
selectionresult<-menu(c(unique(levels(testdata[,1]))),graphics=FALSE,title='Select
something') return (testdata[selectionresult,])
}
testdataextract1(testdata)

testdataextract1(testdata)
Select something

1: text test1
2: text test2
3: text test3

Selection: 2
   variablea   variableb variablec
2 text test2 other texty       200

However, how to adjust the function 'return' so that _all_ values that
match the selected value from the menu are returned (as below)?


Although the menu must show only unique values to be chosen, the
resultant output must show all values that match the chosen value in
this example:

text test2 other texty       200
text test2 other texty       700
text test2 other texty       300
text test2 other texty       250

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to