Hi I am having a problem with outputting text inside an if function. I have the following code:
for (j in 20:length(bb.up)) { if (up[j]==1 && up[j-1]==0) { sprintf("Long on %s at a price of %f",dates[j],data[j]) } if (down[j]==1 && down[j-1]==0) { sprintf("Short on %s at a price of %f",dates[j],data[j]) } } The loop runs fine and the sprintf function runs fine on its own, but the problem I am having is that there is no output if I run the loop with the sprintf inside it. Does anyone know what could be wrong? Is there a way for the code to output data within this loop? I can't seem to find anything on the internet for this problem. Thanks in advance. -- Tian Pan Tel: +27 (0)21 670 5295 [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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.