Re: [R] printing text within if functions inside a for loop

2010-03-23 Thread Mario Valle
Use: cat(sprintf("Long on %s at a price of %f\n",dates[j],data[j])) Hope it helps mario Tian Pan wrote: > 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]=

[R] printing text within if functions inside a for loop

2010-03-23 Thread Tian Pan
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",d