[R] Finding ranges on a per-row basis from several objects
Steve Murray
smurray444 at hotmail.com
Fri Feb 5 11:21:29 CET 2010
Dear all,
I'm attemping to find the overall range of values from column 5 of a series of data frames, on a per-row basis, and assign the results to a new object. At present, I'm only able to receive the overall range of all values, whereas I'm intending to get the results of the range for each corresponding row. This is what I have so far:
for (i in seq(nrow(dframe[1])))
range_models <- rbind(range(c(dframe1[i,5]), range(dframe2[i,5]), range(dframe3[i,5]), range(dframe4[i,5]), range(dframe5[i,5]), range(dframe6[i,5])))
}
If it's of any help, the structure of each of the data frames is:
> str(dframe1)
'data.frame': 61538 obs. of 6 variables:
$ Latitude : num -0.25 -0.25 -0.25 -0.25 -0.25 -0.25 -0.25 -0.25 -0.25 -0.25 ...
$ Longitude : num -48.8 -49.2 -49.8 -50.2 -50.8 ...
$ Runoff_fut : num 1549 1335 1254 1111 1066 ...
$ Runoff_bline: num 1877 1719 1550 1438 1362 ...
$ Difference : num -328 -383 -296 -327 -297 ...
$ PerctDiff : num -17.5 -22.3 -19.1 -22.7 -21.8 ...
So, just to clarify, I'm trying to find the range of values for row 1 based on dframe1 through to dframe6, then row 2, row 3 etc etc. and put the range results for each row into a new object of equal row number to the dframe objects.
Many thanks for any help offered,
Steve
_________________________________________________________________
Got a cool Hotmail story? Tell us now
More information about the R-help
mailing list