s-news
[Top] [All Lists]

[S] Looping Problem

To: "'s-news@wubios.wustl.edu'" <s-news@wubios.wustl.edu>
Subject: [S] Looping Problem
From: "Rohini S." <rohini@hssit.po.my>
Date: Mon, 22 Jun 1998 18:11:22 +0800
Comments: Routed through UUCP Mailserver, Mailcoach V2.20
Sender: owner-s-news@wubios.wustl.edu
Hi there

I have a S-Plus script (attached below) that generates a range of values for 
two variables : cp and cpk (this is generated by using the looping function). 
Now I would like to do a "sort" and other analysis on these variables. How do I 
extract the cpk values and convert them into a vector? Is there an error in the 
way I have written my script file? 

Thanks.

Regards,
Rohini

  
  



Attachment: Script1.ssc
Description: Binary data

function(n,mu,sigma)
{
                sum.cpk<-c(0)
                sum.counts1<-c(0)
                sum.counts2<-c(0)
                set.seed(10)
                y<-rnorm(n,mu,sigma)
                for (i in 1:10)
                {
                        z<-sample(y,replace=T)
                        x<-matrix(z,ncol=5)
                        cp<-(min(60-mean(y),mean(y)-40))/(3*sqrt(var(y)))
                        cpk<-(min(60-mean(z),mean(z)-40))/(3*sqrt(var(z)))
                        sum.cpk<-sum.cpk+cpk
                        mean.cpk<-sum.cpk/10
                        Scpk<-(cpk-mean.cpk)^2/(10-1)
                        counts1<-(cp<=cpk)
                        counts2<-(cp>cpk)
                        sum.counts1<-sum.counts1+counts1
                        mean.counts1<-sum.counts1/10
                        sum.counts2<-sum.counts2+counts2
                        mean.counts2<-sum.counts2/10
                        write.table(round(x,4),sep=("\t")
                        
cat("\n","cpk=",round(cpk,4),"\n","cp=",round(cp,4),"\n",
                        "counts1=",round(counts1,4),"\n",
                        "sum.counts1=",round(sum.counts1,4),"\n",
                        "mean.counts1=",round(sum.counts1,4),"\n",
                                "counts2=",round(counts2,4),"\n",
                        "sum.counts2=",round(sum.counts2,4),"\n",
                        "mean.counts2=",round(sum.counts2,4),"\n",
                        
"mean.cpk",round(mean.cpk,4),"\n","Scpk=",round(Scpk,4),"\n")
                }
}
<Prev in Thread] Current Thread [Next in Thread>
  • [S] Looping Problem, Rohini S. <=