Dear Rolf and Adams, Thanks for your help! works perfectly.though all columns are of the same type, for "safe", it is changed from data.frame to data.matrix as follows: dmatrix <- data.matrix(dailyrecord[c("a", "e", "f")]) colnames(dmatrix) <- c("x5", "x6", "x7") apply(dmatrix, 1, function(row) fun3(list1, list2, as.list(row))) Thanks again! Bests,LQ From: Rolf Turner <r.tur...@auckland.ac.nz> To: "Adams, Jean" <jvad...@usgs.gov>; liqun...@yahoo.com Cc: "r-help@r-project.org" <r-help@r-project.org> Sent: Friday, October 9, 2015 7:28 PM Subject: Re: [FORGED] Re: [R] R lappy, sapply or mapply question On 10/10/15 10:56, Adams, Jean wrote:
> You were very close. Try this. > > df <- data.frame(x5=dailyrecord$a, x6 = dailyrecord$e, x7 = dailyrecord$f) > apply(df, 1, function(row) fun3(list1, list2, as.list(row))) There could in general be problems with this approach. The apply() function works on *matrices* and if handed a data frame coerces it to a matrix. This is (usually!) OK if all columns of the data frame are of the same type, but the world could end if they are not. It is a good idea to *start* with a matrix if a matrix is what is required. And do not confuse data frames with matrices. They are very different animals. cheers, Rolf Turner -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.