[R] Calling object outside function

jim holtman jholtman at gmail.com
Wed Sep 24 21:05:43 CEST 2008


You have to assign the value of the function to an object.  You probably want:

TAZDetermine <- Testdata(....)  # I am not sure what your arguments to

On Wed, Sep 24, 2008 at 1:16 PM, PDXRugger <J_R_36 at hotmail.com> wrote:
>
> What i thought was a simple process isnt working for me.  After i create an
> multiple objects in a function (see below), how to i use those objects later
> in the program.  I tried calling the function again and then the object i
> wanted and it worked the first time but now it doesnt( i think i defined the
> object outside the function accidently so then it worked but when run
> properly it doesnt).  I did this using
> Testdata(TAZDetermine) to first recall the function then the object i wanted
> to use.  This deosnt work and it errors that the object cannot be found.  Do
> i use attach?  this didnt seem to work either.  I just want to call an
> object defined in a function outside of the function.  Hope you can help
>
> Cheers,
> JR
>
>
> #Function to create hypothetical numbers for process testing
> Testdata=function(TAZ_VAC_ACRES,Loc_Mod_TAZ,Dev_Size,TAZDetermine,Dev_Size){
>
> #Loads TAZ and corresponding vacant acres data
> TAZ_VAC_ACRES=
> read.csv(file="I:/Research/Samba/urb_transport_modeling/LUSDR/Workspace/BizLandPrice/data/TAZ_VAC_ACRES.csv",header=TRUE);
>
>
> #Test Location Choice Model selected TAZ
> Loc_Mod_TAZ = 120
> #Create test Development
> Dev_Size=58
>
> #Determines vacant acres by TAZ
> TAZDetermine=TAZ_VAC_ACRES[TAZ_VAC_ACRES$TAZ==Loc_Mod_TAZ,2]
>
> #Displays number of vacant acres in Location Choice Model selected TAZ
> TAZDetermine
>
> }
>
> Testdata(TAZDetermine)
>
> error indicating the that function cannot be found even thoug its part of
> the argument list in the main function.
>
> --
> View this message in context: http://www.nabble.com/Calling-object-outside-function-tp19653634p19653634.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list