I have seen a lot of this close to this but nothing has actually solved the issue I am running into. So my question is how do you address the vector value within a function such as a mean function, and how could you place the vector value into a title. I recently switched from SAS to R so im a little confused.
###### parameters #####
nphase1=50
nphase2=1000
varcount=5
meanshift= 0
sigmashift= 1
##### phase1 dataset/ control limits #####
for (i in 1:varcount)
{
assign (paste("x",i, sep=""), (rnorm(nphase1,0,1)))
mean_var[i]=mean(x[i])
std_var[i]=sd(x[i])
Upper_SPC_Limit_Method1_var[i]= mean_var[i] + (3 * std_var[i])
Lower_SPC_Limit_Method1_var[i]= mean_var[i] - (3 * std_var[i])
moving_range_var[i]= abs(diff(x[i]))
MR_mean[i]= mean(moving_range_var[i])
Upper_SPC_Limit_Method2_var[i] =mean_var[i] + (3 * MR_mean[i])
Lower_SPC_Limit_Method2_var[i] =mean_var[i] - (3 * MR_mean[i])
}
I am sure i will have to do something similar to the (assign(paste("x",i, sep="") for labeling individual the individual limits, but i can't get to that step without being able to calculate the mean of each variable inside the for loop. what i am trying to do is create 5 variables that have 50 observations each(normal random dist). I want to take the mean & Sd of each variable to construct control limits using these numbers.
Thanks for your insight!