[R] How to visualise what code is processed within a for loop

Luca Meyer luc@m1968 @ending from gm@il@com
Tue Apr 24 09:30:25 CEST 2018


Hi,

I am trying to debug the following code:

for (i in 1:10){
  t <- paste("d0$V",i,sep="")
  t <- ifelse(regexpr(d1[i,1],d0$X0)>0,1,0)
}

and I would like to see what code is actually processing R, how can I do
that?

More to the point, I am trying to update my variables d0$V1 to d0$V10
according to the presence or absence of some text (contained in the file
d1) within the d0$X0 variable.

The code seem to run ok, if I add print(table(t)) within the loop I can see
that the ifelse procedure is working and to some cases within the d0$V1 to
d0$V10 variable range a 1 is assigned. But when checking my d0$V1 to d0$V10
after the for loop they are all still equal to zero...

Thanks,

Luca

	[[alternative HTML version deleted]]




More information about the R-help mailing list