0

I have dataframe tr which contins around 1700 rows. I am trying to replace Type column values wherever they are NA with string "None".

I do a quick count to check how many NAs I have in my Type column.

na_count = tr[which(is.na(tr$Type)), ]

na_count contains 8 records.

Now I replace all the NAs with "None" using

ifelse(is.na(tr$Type), tr$Type <- 'None', 0)

The above command is replacing all the 1700 rows with None instead of just the 8. I'm not sure why that is happening.

alistaire
  • 40,464
  • 4
  • 71
  • 108
Pirate X
  • 2,839
  • 5
  • 32
  • 55

0 Answers0