set.seed(nchar(first_name)+nchar(last_name))

n.pop<-10000

subscribe<-sample(c(1,0),n.pop,replace=TRUE,prob=c(0.5,0.5))

pb1<-sample(65:75,1)/100

pb2<-0.5

ad.l1<-0.0

ad.l2<-sample(10:20,1)/100

ap1<-sample(65:75,1)/100

ap2<-0.5

set.seed(nchar(last_name))

see.ad.random<-runif(n.pop)

see.ad<-ifelse(subscribe,1*(see.ad.random<ap1),1*(see.ad.random<ap2))

buy.random<-runif(n.pop)

buy.thres1<-pb1+ad.l1*see.ad
buy.thres2<-pb2+ad.l2*see.ad

buy<-ifelse(subscribe,1*(buy.random<buy.thres1),1*(buy.random<buy.thres2))

data<-cbind.data.frame(subscribe,see.ad,buy)

rm(list = ls(pattern="[^data,first_name,last_name]"))

#the above is my data and I am trying to calculate the average rate for the group that sees the ad and for the ones who don't

# I have the code below

df<-data.frame(see.ad=1, see.ad=0)

mean(df$see.ad)

sapply(df, mean)

but I am not sure if I am doing this correct, any comments?