Example data:
> DF
A B C
1 11 22 88
2 11 22 47
3 2 30 21
4 3 30 21
> r
[1] "A==A[i] & B==B[i] " "A==A[i] & C==C[i] "
[3] "B==B[i] & C==C[i] " "A==A[i] & B==B[i] & C==C[i] "
Executed code:
> output=list()
> for (j in r){
+ for (i in 1:nrow(DF)){
+
+ output[[j]][i]=j
+ }
+ }
> output
$`A==A[i] & B==B[i] `
[1] "A==A[i] & B==B[i] " "A==A[i] & B==B[i] " "A==A[i] & B==B[i] "
[4] "A==A[i] & B==B[i] "
$`A==A[i] & C==C[i] `
[1] "A==A[i] & C==C[i] " "A==A[i] & C==C[i] " "A==A[i] & C==C[i] "
[4] "A==A[i] & C==C[i] "
$`B==B[i] & C==C[i] `
[1] "B==B[i] & C==C[i] " "B==B[i] & C==C[i] " "B==B[i] & C==C[i] "
[4] "B==B[i] & C==C[i] "
$`A==A[i] & B==B[i] & C==C[i] `
[1] "A==A[i] & B==B[i] & C==C[i] " "A==A[i] & B==B[i] & C==C[i] "
[3] "A==A[i] & B==B[i] & C==C[i] " "A==A[i] & B==B[i] & C==C[i] "
> output=purrr::flatten_chr(output)
> output
[1] "A==A[i] & B==B[i] " "A==A[i] & B==B[i] "
[3] "A==A[i] & B==B[i] " "A==A[i] & B==B[i] "
[5] "A==A[i] & C==C[i] " "A==A[i] & C==C[i] "
[7] "A==A[i] & C==C[i] " "A==A[i] & C==C[i] "
[9] "B==B[i] & C==C[i] " "B==B[i] & C==C[i] "
[11] "B==B[i] & C==C[i] " "B==B[i] & C==C[i] "
[13] "A==A[i] & B==B[i] & C==C[i] " "A==A[i] & B==B[i] & C==C[i] "
[15] "A==A[i] & B==B[i] & C==C[i] " "A==A[i] & B==B[i] & C==C[i] "
My target was to get the same output with the specific values A[i], B[i] and C[i] from DF, i.e., the final output would be the following:
> output
[1] "A==11 & B==22 " "A==11 & B==22 "
[3] "A==2 & B==30 " "A==3 & B==30 "
[5] "A==11 & C==88 " "A==11 & C==47 "
[7] "A==2 & C==21 " "A==3 & C==21 "
[9] "B==22 & C==88 " "B==22 & C==47 "
[11] "B==30 & C==21 " "B==30 & C==21 "
[13] "A==11 & B==22 & C==88 " "A==11 & B==22 & C==47 "
[15] "A==2 & B==30 & C==21 " "A==3 & B==30 & C==21 "
I would be grateful if someone could help me with this matter.