[R] Manipulations of a data frame or list -- rename or re-assign?

2013-08-03 Thread Ben Harrison
If I am to do a lot of pre-processing operations on some data,
comprising many steps such as:

-- despike a set of signals
-- smooth a set of signals
-- filter
-- subset
-- impute missing values

etc... Should I be assigning the result of each operation to a new
object, and then destroying the old one, or is it fine to reassign the
object to itself?

df - sapply(df, someFunction, arg=10)
OR
df.new - sapply(df, someFunction, arg=10)

Ben
University of Melbourne

__
R-help@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.


Re: [R] Manipulations of a data frame or list -- rename or re-assign?

2013-08-03 Thread Rui Barradas

Hello,

Maybe you could keep the original, and reuse only one (another) object 
for the intermidiate steps. That's how I would do it.


Hope this helps,

Rui Barradas

Em 03-08-2013 12:27, Ben Harrison escreveu:

If I am to do a lot of pre-processing operations on some data,
comprising many steps such as:

-- despike a set of signals
-- smooth a set of signals
-- filter
-- subset
-- impute missing values

etc... Should I be assigning the result of each operation to a new
object, and then destroying the old one, or is it fine to reassign the
object to itself?

df - sapply(df, someFunction, arg=10)
OR
df.new - sapply(df, someFunction, arg=10)

Ben
University of Melbourne

__
R-help@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.



__
R-help@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.


Re: [R] Manipulations of a data frame or list -- rename or re-assign?

2013-08-03 Thread Jim Lemon

On 08/03/2013 09:27 PM, Ben Harrison wrote:

If I am to do a lot of pre-processing operations on some data,
comprising many steps such as:

-- despike a set of signals
-- smooth a set of signals
-- filter
-- subset
-- impute missing values

etc... Should I be assigning the result of each operation to a new
object, and then destroying the old one, or is it fine to reassign the
object to itself?

df- sapply(df, someFunction, arg=10)
OR
df.new- sapply(df, someFunction, arg=10)


Hi Ben,
If you have read the initial data in from a file you can just use the 
original name. If you don't have another copy of the initial data, it is 
best to save it (e.g. write.table, save) before overwriting the object. 
Fundamentally, don't destroy an object that you can't easily recreate.


Jim

__
R-help@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.