s-news
[Top] [All Lists]

[no subject]

To: s-news@wubios.wustl.edu
Subject:
From: "Alastair Dempster" <demp2979@mach1.wlu.ca>
Date: Fri, 23 Mar 2001 14:13:38 -0500
Reply-to: demp2979@mach1.wlu.ca
My thanks to: 

Rolf Turner
Sam Buttrey
Bill Dunlap (Insightful Corp)
Dan Rie
Mark Durst

for their quick responses and for setting me straight!
All pointed out that I need to use the where argument to assign the object to
a dataframe.

Rolf also pointed out that I could clean up my code and get rid of the 
concatenation.
He also suggested that it was better practice to return the object from the
function than to create the object inside the function.

I now understand that I could write the code this way:

myfunc<-function(theData)
{
y<-paste(deparse(substitute(theData)),".spp",sep="")
assign(y,spp(theData),where=1,immediate=T)
}

but that it would better to write:

myfunc<-function(theData)
{
return(spp(theData))
}

and call this from elsewhere (e.g. the command line) with: 

my_object_name<-myfunc(name_of_data)

I have tried both methods and they work just fine.

Thanks to Mark for some code he sent as well which was helpful.

Greatly appreciated

Cheers,

Alastair

Alastair Dempster

<Prev in Thread] Current Thread [Next in Thread>
  • [no subject], Alastair Dempster <=