0

I am looking for values in temp that match with values in temp1 . Code is working fine but there is no output on console. Can anyone help me with this ?

for(i in 1:nrow(useit)){
  for(j in 1:nrow(useit)){
    ifelse(useit$temp[2]==useit$temp1[3],"Yes","No")
  }
}
MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • That is not the same question as the one you pointed to because it is failing for a completely different reason: `a=ifelse(useit$temp[2]==useit$temp1[3],"Yes","No") ` `print(c("temp: ", i, " temp1: ", j , a))`. This will give you the temp row i index, the temp1 row j index and the y/n value in a single line of output for each pair. – sconfluentus Mar 08 '17 at 21:45
  • Yes this is embedded in an if else statement and not in a print statement .I am still not getting why this isn't working in loops .Please help – Aadish Chopra Mar 08 '17 at 22:06
  • From a loop it will not printout to the console unless you tell it to like above. It is doing the ifelse, but it is not assigned to a persistent variable and not told to print to the console, so it does the calculations, but you get nothing from it. You either need to expressly tell it to print it to the console with `print` or `cat` or write the responses to a data table to view later or append it to a list...you need to ask it to give you the results in some way. The loop is a temporary environment, so each pass through what it does is lost on the next pass...you must ask it for output. – sconfluentus Mar 08 '17 at 22:24
  • Thanks so much bethany ! Your answer is easy to understand . – Aadish Chopra Mar 10 '17 at 13:55

0 Answers0