BioMan
BioMan

Reputation: 704

Add additional text to string

How do I add the additional text p= before the values in the data frame? Do you use gsub?

> pvaluesmir21
   Seqbuster_Filter_MM_miR21_5p$FDR
1                      8.326135e-02
2                      6.336574e-05
3                      3.233019e-17
4                      4.800951e-22
5                      3.054728e-10
6                      6.697357e-11

Upvotes: 0

Views: 50

Answers (1)

akrun
akrun

Reputation: 887038

It is more natural to use paste or sprintf

 pvaluemir21[,1] <- paste('p =', pvaluemir21[,1])

Or

 pvaluemir21[,1] <- sprintf('p = %f', pvaluemir21[,1])

But sub can be used

 pvaluemir21[,1] <- sub('(.*)', 'p=\\1', pvaluesmir21[,1])

Upvotes: 3

Related Questions