[R] subsetting
    Matthias Wendel 
    office at matthiaswendel.de
       
    Fri Jan  4 19:36:44 CET 2008
    
    
  
I'm using R Version 2.6.1 under Windows XP.
> search()
 [1] ".GlobalEnv"            "s"                     "s"                     "package:cairoDevice"  
 [5] "package:datasets"      "package:foreign"       "package:graphics"      "package:grDevices"    
 [9] "package:gWidgetsrJava" "package:gWidgets"      "package:Hmisc"         "package:JGR"          
[13] "package:JavaGD"        "package:rJava"         "package:stats"         "package:utils"        
[17] "package:methods"       "Autoloads"             "package:base"  
The Problem: I'm using a function which is constructing a subset of a dataframe. This dataframe is used in another function. The
structure is like this:
> inner = function (){
+ print('inner:')
+ print(s)
+ }
> outer = function(){
+ t = data.frame(list(X=1:10, Y=LETTERS[1:10]))
+ s = t[t[,'X'] < 5, ]
+ print('outer:')
+ print(t[, 'Y'])
+ inner()
+ }
> outer()
And the response in the R-Console is:
[1] "outer:"
 [1] A B C D E F G H I J
Levels: A B C D E F G H I J
[1] "inner:"
Fehler in print(s) : objekt "s" nicht gefunden
(Error in print(s) : object "s" not found)
How can I make s reachable in inner?
Regards,
Matthias
    
    
More information about the R-help
mailing list