I'm trying to create a function in R to simulate the experiment of tossing four coins as many times as m times, each experiment records the appearance of "numbers" or "images" on each coin.
Present the results of m experiments in tabular form, and add the "number of sides of the number that appears" in the last column of the table.
Sim_Coin<-function(m){
c1<-c()
c2<-c()
cs<-c()
for(i in 1:m)
{
c1<-rbind(d1,sample(0:1,size=1)
c2<-rbind(d2,sample(0:1,size=1)
}
cs<-c1+c2
v<-cbind(c1,c2,cs)
v<-as.data.frame(v)
names(v)<-c("coin1","coin2","sum")
return(v)
}
But it fails and I don't know how to create the table