Displaying 2 results from an estimated 2 matches for "filtered_new".
2011 Mar 11
1
Generation of random numbers in a function - (Return command)
Dear R helpers
I have following data.frame and for each product_name, I have associated mean and standard deviation. I need to generate 1000 random no.s for each of these products and find the respective mean and standard deviation.
My R code is as follows.
library(plyr)
library(reshape2)
filtered_new <- data.frame(product_name = c("P1", "P2", "P3", "P4", "P5"),
output_avg = c(22.71078,22.16979,21.34420,20.17421,19.83799),
output_stdev = c(23.59924,21.21430,22.01025,18.88877,18.80436))
n <- 100
myfunction_mc = function(product_name, outp...
2012 Sep 12
6
How to append the random no.s for different variables in the same data.frame
Dear R helpers,
(At the outset I sincerely apologize if I have not put forward my following query properly, though I have tried to do so.)
Following is a curtailed part of my R - code where I am trying to generate say 100 random no.s for each of the products under consideration.
library(plyr)
n = 100
my_code = function(product, output_avg, output_stdev)
{
BUR_mc = rnorm(n, output_avg,