Re: Dataframes as arguments to functions?

Erin Hodgess (
Wed, 28 Jan 1998 14:43:17 -0600

From: "F.Tusell" <>
Subject: Dataframes as arguments to functions?
Status: R

F. Tusell Writes:
I would like to code a program in such a way dat a dataframe is worked
upon by a number of different functions. Something like,

M <- as.dataframe(xxxx)

where function1() in turn calls function2(M) and so on, up to a three
or four level deeps nesting. Now, in the invocation of function1(M),
the dataframe M is found correctly, but further nested calls (to
function2(M), etc.) do not seem to propagate the argument.

I have read the S-Plus manual, and I understand that this is not a
bug, but a design decision --as it should be. My question is: how can
I do what I want (basically, pass dataframes as in a FORTRAN
call-by-reference subroutine)? Is there any other way to go around?

Any help appreciated.


Fernando TUSELL
Departamento de Econometria y Estadistica
Facultad de CC.EE. y Empresariales Tel. (94) 4797433
Avenida Lendakari Aguirre, 83 +34,4,4797433
E-48015 BILBAO (Spain) Fax: 4797554

What you might want to do is use the assign statement; i.e.,

M <- as.dataframe(xxx)

This should take care of your problem.

Good Luck!

Erin Hodgess
Assistant Professor
Dept. of Computer and Mathematical Sciences
University of Houston -- Downtown