Hi,
I have a data.frame that is date ordered by row number - earliest
date first and most current last. I want to create a couple of new
columns that show the max and min values from other columns *so far* -
not for the whole data.frame.
It seems this sort of question is really coming from m
> More generally, you can always write a loop. They aren't necesssrily
fast
> or elegant, but they're pretty general. For example, to calculate
the max
> of the previous 50 observations (or fewer near the start of a
vector), you
> could do
>
> x <- ... some vector ...
>
> result <- numeric(le
On 01/07/2009 11:49 AM, Mark Knecht wrote:
Hi,
I have a data.frame that is date ordered by row number - earliest
date first and most current last. I want to create a couple of new
columns that show the max and min values from other columns *so far* -
not for the whole data.frame.
It seems
On Wed, Jul 1, 2009 at 9:39 AM, Duncan Murdoch wrote:
> On 01/07/2009 11:49 AM, Mark Knecht wrote:
>>
>> Hi,
>> I have a data.frame that is date ordered by row number - earliest
>> date first and most current last. I want to create a couple of new
>> columns that show the max and min values from
On 01/07/2009 1:26 PM, Mark Knecht wrote:
On Wed, Jul 1, 2009 at 9:39 AM, Duncan Murdoch wrote:
On 01/07/2009 11:49 AM, Mark Knecht wrote:
Hi,
I have a data.frame that is date ordered by row number - earliest
date first and most current last. I want to create a couple of new
columns that show
On Wed, Jul 1, 2009 at 12:54 PM, Duncan Murdoch wrote:
> On 01/07/2009 1:26 PM, Mark Knecht wrote:
>>
>> On Wed, Jul 1, 2009 at 9:39 AM, Duncan Murdoch
>> wrote:
>>>
>>> On 01/07/2009 11:49 AM, Mark Knecht wrote:
Hi,
I have a data.frame that is date ordered by row number - earliest
For another generic approach, you might be interested in the Reduce
function,
rolling <- function( x, window=seq_along(x), f=max){
Reduce(f, x[window])
}
x= c(1:10, 2:10, 15, 1)
rolling(x)
#15
rolling(x, 1:10)
#10
rolling(x, 1:12)
#10
Of course this is only part of the solution to the
Hi
what about do inside some function a subset of your whole data frame
fff <- function( data, rows) {
data.1 <- data[1:rows,]
get all necessary stuf on data.1
return what you want
}
You can put a dimension check if you want the function to be more robust
Regards
Petr
r-help-boun...@r-pr
On 01/07/2009 9:10 PM, Carl Witthoft wrote:
> More generally, you can always write a loop. They aren't necesssrily
fast
> or elegant, but they're pretty general. For example, to calculate
the max
> of the previous 50 observations (or fewer near the start of a
vector), you
> could do
>
Belated answer:
A few remarks regarding your questions:
Your running max problem could be solved in the following way:
(which is a soution based o Duncan Murdoch's suggestion,
but a little bit more general.
foldOrbit<-function(x,fun){
res<-numeric(length(x))
res[1]<-x[1]
10 matches
Mail list logo