[R] for loop over dataframe without indices

Gabor Grothendieck ggrothendieck at myway.com
Fri Dec 19 01:20:04 CET 2003



One can perform a for loop without indices over the columns
of a dataframe like this:

   for( v in df ) ... some statements involving v ...

Is there some way to do this for rows other than using indices:

   for( i in 1:nrow(df) ) ... some statements involving df[i,] ...

If the dataframe had only numeric entries I could transpose it
and then do it over columns but what about the general case?




More information about the R-help mailing list