An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100128/f570d48e/attachment.pl>
random permuted block randomization
6 messages · Ayesha Khan, Ayesha, Greg Snow
Take a look at the blockrand package, it may do what you want.
library(blockrand) #after installing myrand <- blockrand(40, block.sizes=4) myrand
hope this helps,
From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of Ayesha Khan [ayesha.diamondash at gmail.com]
Sent: Thursday, January 28, 2010 5:12 PM
To: r-help at r-project.org
Subject: [R] random permuted block randomization
Sent: Thursday, January 28, 2010 5:12 PM
To: r-help at r-project.org
Subject: [R] random permuted block randomization
Hi,
I am very new to R. Just started yesterday. I have to generate a sequence of
40 random treatments using permuted block randomization with a block size of
8. Then I have to plot moving averages for the resulting sequence. I have
tried the sample function but I dont know if wht i did is right or not
> sample(c(1,1,1,1,2,2,2,2),8)
Any ideas please?
--
Ayesha Khan
MS Bioinformatics
Dept. of Bioengineering
Rice University, TX
[[alternative HTML version deleted]]
______________________________________________
R-help at 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.
I have tried blockrand but it works in a way that it keeps altering the block size.. like it alternates between 8,6,12. I want a constant block size of 8 :(
View this message in context: http://n4.nabble.com/random-permuted-block-randomization-tp1401407p1401496.html Sent from the R help mailing list archive at Nabble.com.
Sorry, that is a stupid bug in the blockrand function. I will hunt down the author and slap him upside the head until he fixes it (actually I will probably just raid his freezer and eat his ice cream). In the mean time there is a simple work around, if you run blockrand like:
blockrand(40, block.sizes=c(4,4))
Then it will force all the block sizes to be 8. Look for a new version of blockrand on CRAN soon with this fixed.
From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of Ayesha [ayesha.diamondash at gmail.com]
Sent: Thursday, January 28, 2010 8:06 PM
To: r-help at r-project.org
Subject: Re: [R] random permuted block randomization
Sent: Thursday, January 28, 2010 8:06 PM
To: r-help at r-project.org
Subject: Re: [R] random permuted block randomization
I have tried blockrand but it works in a way that it keeps altering the block size.. like it alternates between 8,6,12. I want a constant block size of 8 :( -- View this message in context: http://n4.nabble.com/random-permuted-block-randomization-tp1401407p1401496.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at 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.
oki :D and do you know if there is an inbuilt R pacakage that calculate moving averages over time? i found this , "Calculate various moving averages (MA) of a series." Usage SMA(x, n=10) EMA(x, n=10, wilder=FALSE) but when i tried SMA , R wouldnt recognize it! and there isnt such a package as SMA in the install packages list either.
View this message in context: http://n4.nabble.com/random-permuted-block-randomization-tp1401407p1401504.html Sent from the R help mailing list archive at Nabble.com.
you might want to look at the rollmean function in the zoo package if you want a fixed window. If you want a cumulative mean then you can do something like
cumsum(x)/seq_along(x)
If neither of those work, then give us some more detail.
From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of Ayesha [ayesha.diamondash at gmail.com]
Sent: Thursday, January 28, 2010 8:38 PM
To: r-help at r-project.org
Subject: Re: [R] random permuted block randomization
Sent: Thursday, January 28, 2010 8:38 PM
To: r-help at r-project.org
Subject: Re: [R] random permuted block randomization
oki :D and do you know if there is an inbuilt R pacakage that calculate moving averages over time? i found this , "Calculate various moving averages (MA) of a series." Usage SMA(x, n=10) EMA(x, n=10, wilder=FALSE) but when i tried SMA , R wouldnt recognize it! and there isnt such a package as SMA in the install packages list either. -- View this message in context: http://n4.nabble.com/random-permuted-block-randomization-tp1401407p1401504.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at 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.