[R] choosing a particular object

2006-03-31 Thread Adrian DUSA

Hello all,

I'd like to create a function which would do some analysis on a particular 
object, which should be specified in advance. Something like:

 ls()
[1] aa bb cc

Object - bb
var.name - q2
testfunction - function(obj.name, var.name) {
  temp - give.me.the.object.called(Object)
  table(temp[, var.name])
}

This should perfom the same thing as:
table(bb$q2)

Is this possible?
TIA,
Adrian

-- 
Adrian DUSA
Romanian Social Data Archive
1, Schitu Magureanu Bd
050025 Bucharest sector 5
Romania
Tel./Fax: +40 21 3126618 \
  +40 21 3120210 / int.101

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] choosing a particular object

2006-03-31 Thread Adaikalavan Ramasamy
Try

 test.fn - function(obj.name, var.name=q2){

  stopifnot( is.character(obj.name)  is.character(var.name) )
  x - subset( get(obj), select=var.name )
  table(x)
 }



On Fri, 2006-03-31 at 12:44 +0300, Adrian DUSA wrote:
 Hello all,
 
 I'd like to create a function which would do some analysis on a particular 
 object, which should be specified in advance. Something like:
 
  ls()
 [1] aa bb cc
 
 Object - bb
 var.name - q2
 testfunction - function(obj.name, var.name) {
   temp - give.me.the.object.called(Object)
   table(temp[, var.name])
 }
 
 This should perfom the same thing as:
 table(bb$q2)
 
 Is this possible?
 TIA,
 Adrian


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] choosing a particular object

2006-03-31 Thread Adrian DUSA
Thanks, it's exactly what I want.
Adrian

On Friday 31 March 2006 12:59, Adaikalavan Ramasamy wrote:
 Try

  test.fn - function(obj.name, var.name=q2){

   stopifnot( is.character(obj.name)  is.character(var.name) )
   x - subset( get(obj), select=var.name )
   table(x)
  }

-- 
Adrian DUSA
Romanian Social Data Archive
1, Schitu Magureanu Bd
050025 Bucharest sector 5
Romania
Tel./Fax: +40 21 3126618 \
  +40 21 3120210 / int.101

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html