Dear List,

Thankyou to Jim and Marc for their help on my previous question.

I have a data frame of five columns, the first being a list of dates and the 
other four columns are numeric values. I wanted to list the days where all 4 
columns of values are less than in the previous row. I used the following 
which works fine, except it doesnt show the dates for each row (the values 
from column 1).

differences <- apply(x, 2, diff)
all.lower.diffs <- subset(differences, apply(differences, 1, 
function(x){all(x<0)}

I tried using the following loop instead, but it would only apply to the 
first column of every row("warning condition has length>1 and only first 
element will be used"):

for ( i in 2:length(x[,1]))  if (x[i,]<x[i-1,]) {print(x[i,])}

How can I resolve with either method? Any help much appreciated.

Regards,
Alf Sammassimo.

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to