Hello,

I come from using different programming languages (C++, Mathematica, Perl) but have been using R extensively for several months.  I see the data frame as a key piece of the language and wanted to inquire people's experience regarding its use.

Say you have a data frame D

D <- data.frame(some columns)

and you define a function that needs the information from this data frame and is supposed to return a calculation based on some columns of such data frame D.

func <- function(d) {}
#EFFECT: Does calculation X from some columns of d

QUESTION: Would you consider better practice to return the same data.frame but expanded, or would you return a small data frame that consists of the newly computed columns?

Some might say, either way, personal preference.  But after using and seeing other's code for some time, I am thinking that returning the result that consists of ONLY the relevant columns is a better practice as it defines the function as only returning what it was intended to return, and leaves it up to the user of the function to do whatever they were intending to do with it (including naming of the new columns, adding them to a data frame, etc.).  This might be a question for a computer programming theory group, but if anybody has any insight from their experience please share.

Thanks in advance,

Ramiro

	[[alternative HTML version deleted]]

