Writing loops are the bane of my existence. I have this function, which
works:

rnd.data<-function(x){ min.x<-min(x[,2]) max.x<-max(x[,2])
min.y<-min(x[,3]) max.y<-max(x[,3]) data.table(x = runif(34, min.x,
max.x))[, y := runif(34, min.y, max.y)] }

it's purpose is to simulate data within parameters that are dependent on
the column of the dataframe in question for the first data set I wrote it
for had only 2 columns I wanted to simulate samples for however i have
additional dataframes with different numbers of columns ideally i would
write one function with a for loop that could compute samples for all
dataframes I want to input as I need to simulate more than 1000 samples per
dataframe

I tired manipulating the beginning to read as: rnd2.data<-function(x){
n<-dim(x)[2] for(i in 1:n){ if(n > 3){ but then got stuck as to what to do
next

Any help would be greatly appreciated Thanks!

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to