0

I'm have an issue with my analysis and would like to replace all of the 1's in a particular column with .9999, for example:

  SNP Pvalue
 rs11 0.6516
 rs12 0.3311
 rs13 1.0000

would become

  SNP Pvalue
rs11 0.6516
rs12 0.3311
rs13 0.9999

Thanks in advance for your replies.

Paul Sonier
  • 38,903
  • 3
  • 77
  • 117

1 Answers1

4

Assuming your data.frame is called mydf:

mydf$Pvalue[mydf$Pvalue==1] <- 0.9999

See help('[<-') or any number of introduction to R manuals such as this one:

http://cran.r-project.org/doc/manuals/R-intro.pdf

Ari B. Friedman
  • 71,271
  • 35
  • 175
  • 235
  • There is a question of what is 1, as in `b=1-10^(-(1:20)); b[b==1]=0.9999; b` – Henry Aug 01 '11 at 21:17
  • 1
    Indeed. @margaux note that if you care or are having trouble with floating point errors, replace the equality statement in brackets with something that has a slight tolerance. For suggestions see here http://stackoverflow.com/questions/4752275/test-for-equality-among-all-elements-of-a-single-vector – Ari B. Friedman Aug 01 '11 at 21:30