Vector Operators
> a=c("AA","V")
> a[0]
character(0)
> a[-1]
[1] "V"
> a[-2]
[1] "AA"
> a[-3]
[1] "AA" "V"
Functions
> seq = "atGCTGGATGAGaGCGAaaGAGCAGAGAGCCA"
> toupper(seq)
[1] "ATGCTGGATGAGAGCGAAAGAGCAGAGAGCCA"
> tolower(seq)
[1] "atgctggatgagagcgaaagagcagagagcca"
Substring
> seq=toupper(seq)
> substr(seq, start = 1, stop = 3)
[1] "ATG"
Joining strings
> x <-"AAA"
> x
[1] "AAA"
> y <- "BBB"
> c(x,y)
[1] "AAA" "BBB"
> paste(x,y)
[1] "AAA BBB"
> paste(x,y,sep="")
[1] "AAABBB"
Statistical operations on string vectors
> x=c("Orange","Apple","Banana")
> min(x)
[1] "Apple"
> max(x)
[1] "Orange"
> sort(x)
[1] "Apple" "Banana" "Orange"
Summary statistics
> x=c("A","T","A","G","C","A","A","T")
> summary(x)
Length Class Mode
8 character character
> y=factor(x)
> summary(y)
A C G T
4 1 1 2
> y[0]
factor(0)
Levels: A C G T