I just needed to come up with a name for my blog, so as most of the times, when I'm working in the lab I got some help from my favourite programming language, R. See if you could find a better name with playing a round with the seedNumber, and nameSize parameters. You might find another unique name that no one have ever herd before, such as gattaca. OK, maybe this wouldn't be a unique name to choose after all !
Open R programming language environment
type
dnaSeqRandGenerator<- function(
seedNumber=NULL,
nameSize=4
){
DNAseqs<- c("A","C","G","T")
set.seed(seedNumber)
generatedName<-
paste(sample(DNAseqs, nameSize, replace=T),
collapse="")
return(
generatedName
)
}
You'll first see the result of my run, i.e. my blogs name. Try running the function dnaSeqRandGenerator with other parameters.
RNGkind(sample.kind="Rounding")
dnaSeqRandGenerator(seedNumber=13, nameSize=7)
#[1] "GACATAG"
RNGkind(sample.kind="default")
Update!
The earlier codes (i.e. green codes above) no longer produces "GACATAG" as there were some changes made to the way that sample() function works in R 3.6.0 . To be able to reproduce, we will need to change the random number generator to the old way by adding RNGkind(sample.kind="Rounding") command. You can reset the random numbr generator to the current default by using RNGkind(sample.kind="default") .
(Last updated on 2nd, Jan, 2023)
Add a comment