Question: Replacing column one values in R
0
gravatar for waqasnayab
2.7 years ago by
waqasnayab180
Pakistan
waqasnayab180 wrote:

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.

alignment next-gen R • 850 views
ADD COMMENTlink written 2.7 years ago by waqasnayab180
2
... cvrge[,1] == 'genome'... tests for equality. It doesn't update the values. You need to use


   cvrge[, 1] <- 'genome'
ADD REPLYlink written 2.7 years ago by russhh4.3k
1

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

cvrge$V1 <- "genome"
ADD REPLYlink written 2.7 years ago by Neilfws48k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1905 users visited in the last hour