your problem is in the statement:
if(mat.all[i,(j-int):(j-1)]0){
you have multiple values in the comparison and the 'if' statement can only
use a single value. Do you want the statement to read:
if(all(mat.all[i,(j-int):(j-1)]0)){
which will test for 'all' the comparisons to be true?
On 6/6/07, Melanie Ann Harsch [EMAIL PROTECTED] wrote:
I have a matrix and am trying to write a code to
1. identify all neg values along each line
2. for each neg value I need to identify min(j+3)
3. end with this code: eq[i,j]- ifelse(mat.r[i,j] (0.5*mat.s[i,j]),
mat.all[i,j], 0)
This is the code I have so far. I have tried several different methods
but I
keep getting the same error message that the condition has length 1 and
only the first element will be used.
Any suggestions?
int - 3
for(i in 1:nrow(mat.all)) {
start.year - min(which(is.na(mat.all[i,])==F (mat.all[i,]0)))
fin.year - max(which(is.na(mat.all[i,])==F))
for(j in start.year:fin.year) {
if(mat.all[i,(j-int):(j-1)]0){
mat.s[i,j] - ifelse((mat.all[i,(j-int):(j-1)])==pmin, mat.all[i,j],
0);
mat.r [i,j] - which.max((mat.all[i,(j+1):(j+int)]) 0)
}
}}
__
R-help@stat.math.ethz.ch 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.
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
[[alternative HTML version deleted]]
__
R-help@stat.math.ethz.ch 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.