A set of curlies should help. As in > replicate(5, {y <- runif(20); mean(y)}) [1] 0.4926800 0.5356511 0.5343938 0.5313422 0.5287927
-pd BTW: sum(replicate(10000,...))/10000 is simpler and less error-prone written as mean(replicate(10000,....)) > On 09 Oct 2015, at 01:37 , Curtis Browne <curtis_brown...@hotmail.com> wrote: > > I would like to essentially do a randomization p-test (10,000 replications in > this case) to check how often I would see a linear correlation in my data as > strong or stronger than I did with the original data (with a correlation > value of 0.9796619). The code which I thought would work is below: > > sum(replicate(10000,data$Scram <- sample(data$Changeinmass,10, replace = > FALSE); with(data,cor(Current,data$Scram))>=0.9796619))/10000 > > With the error: > > Error: unexpected ';' in "sum(replicate(10000,data$Scram <- > sample(data$Changeinmass,10, replace = FALSE);" > > Is there any method of replicating both the function of assigning a random > sample of the data to a column, and the function of then performing a Pearson > correlation test between data$Current and data$Scram? > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd....@cbs.dk Priv: pda...@gmail.com ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.