Below piece of code works as i want
d=c(0,1)
A1=c(0,1)
A2=c(0,1)
d=as.data.frame(d)
A1=as.data.frame(A1)
A2=as.data.frame(A2)
d=merge(d,A1)
d=merge(d,A2)
It produces below d
> d
d A1 A2
1 0 0 0
2 1 0 0
3 0 1 0
4 1 1 0
5 0 0 1
6 1 0 1
7 0 1 1
8 1 1 1
I want below piece of code to behave exactly like above code
steps=3
ball_numbers=c(4,5,6)
d=as.data.frame(c(0,1))
for (i in (1:length(ball_numbers)-1))
{
assign(paste("A", i, sep = ""),c(0,1))
#how to convert variables on earlier step to dataframes?
d=merge(d,get(paste("A", i, sep = "")))
}
this code produces different d, when I am expecting d as shown in the first set above
y c(0, 1)
1 0 0
2 0 1
3 1 0
4 1 1
How could i ensure that I get same d in case of the second set of code?