Suppose I build mystring in a for loop as followings in r:
mystring = "" colorIndex = 17 for(i in 1:ncol(myTable)){ mystring = paste(mystring, paste("$('td:eq(",i, ")', nRow).attr('title', full_text);", sep = "")) mystring = paste(mystring, paste("$('td:eq(",i,")', nRow).css('cursor', 'pointer');", sep = "")) mystring = paste(mystring, "if(aData[",colorIndex,"] == 0){ $(nRow).css('background-color','#f8f8ff') }else if(aData[",colorIndex,"]==1){ $(nRow).css('background-color','#9EFAC5') }else{ $(nRow).css('background-color','#FAF99E') };", sep ="") } Now, suppose my table had 60 columns. I'm trying to figure out the easiest way to do this. Do I need to make one large string, with a special character and then grep out the character? How to iterate over the i efficiently is throwing me. However, given how slow R is with strings, I would prefer not to do this in a loop.