I have several data frames containing similar data. I'd like to pass these data frames to a function for processing. The function would create newly named "global" data frames containing the processed data. I cannot figure out how to assign names to the data frames in Step 1 or Step 2 in the following example:
# sample function in pseudo code processdf <- function(df, prefix) { # df - data frame containing data for processing # prefix - string to become the first part of the names of the resulting data frames # Step 1 - processs df into several subsets df1 <<- subset(df, df$cond1 & df$cond2 & ...) df2 <<- subset(df, df$cond3 & df$cond4 & ...) df3 <<- subset(df, df$cond5 & df$cond6 & ...) # and so on....for many more steps with resulting data frames # Step 2 - rename the resulting global data frames rename "df1" to prefix + "cond1cond2" rename "df2" to prefix + "cond3cond4" rename "df3" to prefix + "cond5cond6" # and so on for the remaining data frames } Example using data frames: frame1 and frame2: processdf(frame1, "frame1") # produces these data frames: frame1cond1cond2 frame1cond3cond4 frame1cond5cond6 processdf(frame2, "frame2") # produces these data frames: frame2cond1cond2 frame2cond3cond4 frame2cond5cond6 Thank you for your thoughts, Matt [[alternative HTML version deleted]] ______________________________________________ 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.