`cgFraction` <- function(dna) {
# get the first element of the list returned from "strsplit"
letters <- strsplit( toupper( dna), split="", fixed=TRUE)
out <- sapply( letters, function(x) {
at <- sum( x %in% c( "A","T"))
cg <- sum( x %in% c( "C","G"))
return( cg / (at+cg))
})
names(out) <- names(dna)
out
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.