Dear Mailing-List, I think this is a newbie question. However, i would like to integrate a loop in the function below. So that the script calculates for each variable within the dataframe df1 the connecting data in df2. Actually it takes only the first row. I hope that's clear. My goal is to apply the function for each data in df1. Many thanks in advance. An example is as follows:
df1 <-data.frame(b=c(1,2,3,4,5,5,6,7,8,9,10)) df2 <-data.frame(x=c(1,2,3,4,5), y=c(2,5,4,6,5), z=c(10, 8, 7, 9, 3)) attach(df2) myfun = function(yxz) (x + y)/(z * df1$b) df1$goal <- apply(df2, 1, myfun) df1$goal regards, kay ______________________________________________ R-help@stat.math.ethz.ch 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.