the condition has length > 1 and only the first element will be used in if else statement

If I understand you correctly you want to multiply all values matching a condition with a factor. For your example it would be:

pred=data.frame(seq(1,100,by=2))
obs=data.frame(seq(1,100,by=3))
pr=data.frame(seq(1,200,by=4))
condition <- pr[,1] > max(pred[,1],na.rm=T)
#set NA values false
condition[is.na(condition)] <- F
fac <- max(obs[,1],na.rm=T)/max(pred[,1],na.rm=T)
pr[condition,1] <- pr[condition,1]*fac
#do other stuff if the condition is false

Leave a Comment