Following this thread computing probabilities
the verified answer contained a for loop and prop.tables. I want to combine both into one single function such that every "b" should represent a column of a dataframe.
For example :
df.base<-as.data.frame(ncol(dataframe0),replicate(vector("numeric",1000)))
where each column in dataframe0 contains integer or continuous values that would be sampled 1000 times.I would also like to point out that when the first column in dataframe0 was sampled ,its values must be stored in df.base[,1]
computeFun<-function(dataframe){
set.seed(1234)
for (i in 1:1000){
df.base[i] <- sample(dataframe0[,1:ncol(dataframe)], size=1, replace = T)
return(df.base]}
I was really trying to figure out a way for days now but I couldn't.
Thank you