Dear Burns Replacing comma through tilde has not helped; I got the message:
Error in cor.test.formula(frm, alternative = "two.sided", method = "pearson") : 'formula' missing or invalid. As you know, the syntax for test for corelation coefficient b/w variables x1 & x2 is as: cor=cor.test(x1,x2,alternative = "two.sided", method = "pearson") That is, the variables essentially need be separated by a comma. So please help. --- On Sat, 25/10/08, Patrick Burns <[EMAIL PROTECTED]> wrote: > From: Patrick Burns <[EMAIL PROTECTED]> > Subject: Re: [R] Repetitive correlation test > To: [EMAIL PROTECTED] > Date: Saturday, 25 October, 2008, 2:39 PM > I think you mean to paste a tilde rather than a > comma in the command that creates 'frm'. > > Patrick Burns > [EMAIL PROTECTED] > +44 (0)20 8525 0696 > http://www.burns-stat.com > (home of S Poetry and "A Guide for the Unwilling S > User") > > Amarjit Singh Sethi wrote: > > Dear all, > > Through the following code, I wanted to perform > correlation test repetedly (through loop) on different > combinations of variables of a data set. > > > > Code: > > > > > x=read.table("sample.txt",header=T,sep="\t") > > out="corout.txt" > > sink(out) > > nm = names(x) > > print(nm) > > nvr=3 > > # nvr=Total no. of variables in the input data file > > for (i in 1:(nvr-1)) > > { > > for(j in (i+1):nvr) > > { > > frm= > as.formula(paste(nm[i+1],",",nm[j+1],sep="")) > ($$) > > > crl=cor.test(frm,alternative="two.sided",method="pearson") > > > smr=summary(crl) > > print(smr) > > } > > } > > sink() > > > > Sample Data: > > > > S No V1 V2 V3 > > 1 15 10 4 > > 2 6 4 7 > > 3 10 5 2 > > 4 8 6 6 > > > > But the code does not work; there seems to be some > problem in the statement marked ($$) above. The message I > get is: > > > > Error in parse(text = x) : unexpected ',' in > "V1," > > > > Kindly help to get rid of the bug > > > > Regards > > > > ajss > > > > > > Unlimited freedom, unlimited storage. Get it > now, on > http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/ > > > > ______________________________________________ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, > reproducible code. > > > > > > Download prohibited? No problem. CHAT from any browser, without download. Go to http://in.webmessenger.yahoo.com/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.