Hi all, I have a question about apply function. Is that possible to pass some non-default arguments in the function we want to apply ? For example: if "mat" is a matrix and I want to use the "tabulate" function on its row. The command apply(mat,1,tabulate) works but I have problem with this one apply(mat, 1, tabulate(nbins=4)). Any clue ? Thanks, Eric -- Eric Pellegrini, PhD Computer-Chemie-Centrum University of Erlangen-N??rnberg N??gelbachstra??e, 25 D-91052 Erlangen Germany
Try apply(mat, 1, tabulate, nbins=4). HTH, Andy> From: Eric Pellegrini > > Hi all, > > I have a question about apply function. Is that possible to pass some > non-default arguments in the function we want to apply ? > > For example: > > if "mat" is a matrix and I want to use the "tabulate" > function on its row. > > The command apply(mat,1,tabulate) works but I have problem > with this one > apply(mat, 1, tabulate(nbins=4)). > > Any clue ? > > Thanks, > > Eric > > > > -- > Eric Pellegrini, PhD > Computer-Chemie-Centrum > University of Erlangen-N??rnberg > N??gelbachstra??e, 25 > D-91052 Erlangen > Germany > > ______________________________________________ > R-help at 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 > >
Eric Pellegrini <eric.pellegrini at chemie.uni-erlangen.de> writes:> Hi all, > > I have a question about apply function. Is that possible to pass some > non-default arguments in the function we want to apply ? > > For example: > > if "mat" is a matrix and I want to use the "tabulate" function on its row. > > The command apply(mat,1,tabulate) works but I have problem with this one > apply(mat, 1, tabulate(nbins=4)). > > Any clue ?You might have gotten one by R'ing TFHP.... apply(mat, 1, tabulate, nbins=4) There's even an example! -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907