[R] Looping with looping

ani jaya g@@@uu| @end|ng |rom gm@||@com
Thu Apr 18 07:44:33 CEST 2019


Dear R community,

I'm trying to create a looping to see the effect of number of samples from
one dataset.
Lets say I have 10 values in a single data frame and I want to see the mean
of each sampling let say from 2-9 number of sampling. But I want to do the
repetition let say up to 100 for each number of sampling and put it in a
different dataframe, let say a2,a3,a4,... which contain a2[1] is the mean
of first repetition and so on. I believe this is possible but I'm newbie
here.

> version

platform       x86_64-w64-mingw32
arch           x86_64
os             mingw32
system         x86_64, mingw32
status
major          3
minor          5.3
year           2019
month          03
day            11
svn rev        76217
language       R
version.string R version 3.5.3 (2019-03-11)
nickname       Great Truth


 The simple code that I have:

sam<-c(9,7,8,6,6,7,8,6,7,3)
for (k in seq(2,9,1)){
    a <- numeric(100)
      for (i in 1:100){
      a[i] <- mean(sample(sam,k,replace=T))

      }
  }

I can do enough with this code but i want to the variable name also
move based on k.

I have googling enough and meet assign and paste command but not really help.
Any help would be appreciate.



Best,

Saat M.

	[[alternative HTML version deleted]]



More information about the R-help mailing list