user3091668
user3091668

Reputation: 2310

Substitute all rows in a column to NA

Probably this is a simple problem, but I really can´t deal with that.

I am trying to put NA in all rows in df$start:

start  end   ok
100    200   yes
200    320   no 
230    300   no

I had tried df[df$start] <- NA but it seem to enter in one eternal loop.

My expected output:

   start  end   ok
    NA    200   yes
    NA    320   no 
    NA    300   no

Upvotes: 0

Views: 41

Answers (1)

nrussell
nrussell

Reputation: 18612

DF <- data.frame(
  start=c(100,200,230),
  end=c(200,320,300),
  ok=c("yes","no","no"),
  stringsAsFactors=FALSE)
##
DF$start <- NA
DF
  start end  ok
1    NA 200 yes
2    NA 320  no
3    NA 300  no

Upvotes: 3

Related Questions