how to save 10 values created randomly for use

hey i want generate 10 random numbers only if p is greater than 0.5 and save them for use as data frame half code what i understood is written but i donot understand how to save 10 values generated at different times.

p=runif(1, 0, 1)
if(p>0.5){i=runif(10,1,10)
  print(i)
}else{
  print("NO INSTORE CUSTOMER APPEARED")
}
#> [1] "NO INSTORE CUSTOMER APPEARED"

Created on 2020-08-15 by the reprex package (v0.3.0)

You have saved your 10 values as I so you have them. If p <= .5, perhaps you want I to be zeroes? i <- c(rep(0, 10))

p=runif(1, 0, 1)
if(p>0.5){i=runif(10,1,10)
  result <- i
}else{
  print("NO INSTORE CUSTOMER APPEARED")
} 
ifelse(!result,NA,result)
#>  [1] 2.925270 9.351274 9.965122 2.805564 5.931588 4.327491 2.021371 9.054118
#>  [9] 5.454375 7.262764

Created on 2020-08-16 by the reprex package (v0.3.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.