This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Replacing column one values in R

Hi,

I want to replace column one values with genome string.

I did the following:

cvrge <- read.table("genome_cvrge_hist_nochr.txt")
> head (cvrge)
  V1 V2       V3        V4        V5
1  1  0 36163905 249250621 0.1450910
2  1  1  7607795 249250621 0.0305227
3  1  2  8370524 249250621 0.0335828
4  1  3  9328821 249250621 0.0374275
5  1  4 10150841 249250621 0.0407254
6  1  5 10750946 249250621 0.0431331
> gcov = cvrge[cvrge[,1] == 'genome',]
> gcov
[1] V1 V2 V3 V4 V5
<0 rows> (or 0-length row.names)

I am expecting the following output:

> head (cvrge)
      V1 V2       V3        V4        V5
    1  genome  0 36163905 249250621 0.1450910
    2  genome  1  7607795 249250621 0.0305227
    3  genome  2  8370524 249250621 0.0335828
    4  genome  3  9328821 249250621 0.0374275
    5  genome  4 10150841 249250621 0.0407254
    6  genome  5 10750946 249250621 0.0431331

where I am wrong,

Thanks,

Waqas.

r next-gen alignment
... cvrge[,1] == 'genome'... tests for equality. It doesn't update the values. You need to use


   cvrge[, 1] <- 'genome'

As it's a data frame, this should also work:

cvrge$V1 <- "genome"

0 answers

No answers yet.

Log in to answer this question.