Amelia of Aukland writes: > Suppose instead of having above dataframe having single data for > variable 1 and variable 2, I have following data as > > variable_1 variable_2 > > 10 20 > 40 30 > 3 11
And so you do: foo <- data.frame(variable_1=c(10,40,3), variable_2=c(20,30,11)) > I need to run the function 'fun' for each pair of values taken by > variable_1 and variable_2 separately. Also, the results (= 30, 70 > and 14) obtained for each of above pairs should be stored in > different csv files, say "ans1.csv", "ans2.csv" and "ans3.csv" > respectively which I can use for further analysis. (In reality each > of these output files will consists of 1000 records). No function is necessary, though apply() would work as has been pointed out. foo$answer <- foo$variable_1 + foo$variable_2 Writing to a csv is another matter-- write.csv(foo, 'foo.csv') -- Curt Seeliger, Data Ranger Raytheon Information Services - Contractor to ORD seeliger.c...@epa.gov 541/754-4638 [[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.