Greetings listeRs -
Given a data frame such as
times
time1time2 time3time4
1 70.408543 48.92378 7.399605 95.93050
2 17.231940 27.48530 82.962916 10.20619
3 20.279220 10.33575 66.209290 30.71846
4 NA 53.31993 12.398237 35.65782
5 9.295965 NA
On Jan 19, 2007, at 12:54 PM, Ben Fairbank wrote:
Given a data frame such as
times
time1time2 time3time4
1 70.408543 48.92378 7.399605 95.93050
2 17.231940 27.48530 82.962916 10.20619
3 20.279220 10.33575 66.209290 30.71846
4 NA 53.31993 12.398237 35.65782
Try this using the builtin data set anscombe:
transform(anscombe, rowMeans = rowMeans(anscombe))
On 1/19/07, Ben Fairbank [EMAIL PROTECTED] wrote:
Greetings listeRs -
Given a data frame such as
times
time1time2 time3time4
1 70.408543 48.92378 7.399605 95.93050
Ben,
transform() is probably the wrong tool if what you want is to
'apply a function'
to the corresponding elements of time1, time2, ... , and return a vector
of results.
If this is what you are after, the 'apply' family of functions is what you
want.
See
?apply
and
On Fri, 2007-01-19 at 11:54 -0600, Ben Fairbank wrote:
Greetings listeRs -
Here are two solutions, depending on whether you wanted the NA's or not,
and I assume you wanted the row means:
times3 - transform(times, meantime = rowMeans(times))
times3
time1time2 time3time4