Dear Mr Weylandt and R helpers, Thanks a lot for your suggestion. Unfortunately the "return" statement in my original R code returns me different results which are obtained after processing the function I have constructed.
My requirement for storing the product-wise random numbers is just a part of my whole exercise. For each of the products, I generate a set of random no.s, process these, construct some statistics and obtain these statistics using the "Return" statement. So for each of the products, I get these set of statistics generated and that is not my problem. My problem is "BESIDES getting my required output (which anyways I am getting)", I need the product-wise random numbers I have already generated and store them together in a single data.frame. So a single data.frame gives me all the product wise random nos. I am reproducing my problem once again - # ____________________________________ library(plyr) n = 100 my_code = function(product, output_avg, output_stdev) { BUR_mc = rnorm(n, output_avg, output_stdev) sim_BUR = data.frame(product, BUR_mc) write.csv(data.frame(sim_BUR), 'sim_BUR.csv', row.names = FALSE) return(list(output_avg, output_stdev)) } result <- dlply(.data = My_data, .variables = "product", .fun = function(x) my_code(product = x$product, output_avg = x$output_avg, output_stdev = x$output_stdev)) There are some 12 products (and this may vary each time). In my original code, the "return" statement returns me some other output. Here for simplicity sake, I am just using the values as given in input. PROBLEM I want to store the random no.s (BUR_mc) as generated above for each of the products and store them in a single data.frame. Now when I access 'sim_BUR.csv', I get the csv file where the random nos. generated for the last product are getting stored. I need something like product random no product1 ....... product1 ....... ............................. product1 ....... # (There will be 100 such values for product1) product2 ....... product2 ....... ............................ ............................ product12 ...... ............................ product12 ....... Thanking you in advance Vincy [[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.