[S] FW: Looping Problem

Rohini S. (rohini@hssit.po.my)
Tue, 23 Jun 1998 18:46:03 +0800


------ =_NextPart_000_01BD9ED7.30078B80
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

-----Original Message-----
From: Rohini S. [SMTP:rohini@hssit.po.my]
Sent: Monday, June 22, 1998 6:11 PM
To: 's-news@wubios.wustl.edu'
Subject: Looping Problem

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?=20

Thanks.

Regards,
Rohini

=20
=20

------ =_NextPart_000_01BD9ED7.30078B80
Content-Type: application/octet-stream; name="Script1.ssc"
Content-Transfer-Encoding: base64

ZnVuY3Rpb24obixtdSxzaWdtYSkNCnsNCgkJc3VtLmNwazwtYygwKQ0KCQlzdW0uY291bnRzMTwt
YygwKQ0KCQlzdW0uY291bnRzMjwtYygwKQ0KCQlzZXQuc2VlZCgxMCkNCgkJeTwtcm5vcm0obixt
dSxzaWdtYSkNCgkJZm9yIChpIGluIDE6MTApew0KCQkJejwtc2FtcGxlKHkscmVwbGFjZT1UKQ0K
CQkJeDwtbWF0cml4KHosbmNvbD01KQ0KCQkJY3A8LShtaW4oNjAtbWVhbih5KSxtZWFuKHkpLTQw
KSkvKDMqc3FydCh2YXIoeSkpKQ0KCQkJY3BrPC0obWluKDYwLW1lYW4oeiksbWVhbih6KS00MCkp
LygzKnNxcnQodmFyKHopKSkNCgkJCXN1bS5jcGs8LXN1bS5jcGsrY3BrDQoJCQltZWFuLmNwazwt
c3VtLmNway8xMA0KCQkJU2NwazwtKGNway1tZWFuLmNwayleMi8oMTAtMSkNCgkJCWNvdW50czE8
LShjcDw9Y3BrKQ0KCQkJY291bnRzMjwtKGNwPmNwaykNCgkJCXN1bS5jb3VudHMxPC1zdW0uY291
bnRzMStjb3VudHMxDQoJCQltZWFuLmNvdW50czE8LXN1bS5jb3VudHMxLzEwDQoJCQlzdW0uY291
bnRzMjwtc3VtLmNvdW50czIrY291bnRzMg0KCQkJbWVhbi5jb3VudHMyPC1zdW0uY291bnRzMi8x
MA0KCQkJd3JpdGUudGFibGUocm91bmQoeCw0KSxzZXA9KCJcdCIpDQoJCQljYXQoIlxuIiwiY3Br
PSIscm91bmQoY3BrLDQpLCJcbiIsImNwPSIscm91bmQoY3AsNCksIlxuIiwNCgkJCSJjb3VudHMx
PSIscm91bmQoY291bnRzMSw0KSwiXG4iLA0KCQkJInN1bS5jb3VudHMxPSIscm91bmQoc3VtLmNv
dW50czEsNCksIlxuIiwNCgkJCSJtZWFuLmNvdW50czE9Iixyb3VuZChzdW0uY291bnRzMSw0KSwi
XG4iLA0KCQkJCSJjb3VudHMyPSIscm91bmQoY291bnRzMiw0KSwiXG4iLA0KCQkJInN1bS5jb3Vu
dHMyPSIscm91bmQoc3VtLmNvdW50czIsNCksIlxuIiwNCgkJCSJtZWFuLmNvdW50czI9Iixyb3Vu
ZChzdW0uY291bnRzMiw0KSwiXG4iLA0KCQkJIm1lYW4uY3BrIixyb3VuZChtZWFuLmNwayw0KSwi
XG4iLCJTY3BrPSIscm91bmQoU2Nwayw0KSwiXG4iKQoKCQl9Cn0=

------ =_NextPart_000_01BD9ED7.30078B80
Content-Type: text/plain; name="Script.txt"
Content-Transfer-Encoding: 7bit

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")
}
}
------ =_NextPart_000_01BD9ED7.30078B80--

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news