0

I am working with a large data frame (see example below), where a value is missing in the year variable. I assume that the missing value is 2000 and i would like to add it. I don't like the idea to add the value by hand, is there any other possibility?

    dataID dataOrigin year breedSummary breedFCI SNP sex age postcode 
1 H00-0012  IVPZ-APPX 2000         1018        3   7   1  12     7000           
4 H00-0022  IVPZ-APPX NA           1217        1   5   3   9     7514

Many thanks!

Roland
  • 127,288
  • 10
  • 191
  • 288
Gion Mors
  • 313
  • 1
  • 3
  • 20
  • 1
    Please see this link http://stackoverflow.com/questions/13172711/replace-na-values-from-a-column-with-0-in-data-frame-r – priyanka Mar 13 '14 at 11:50

2 Answers2

0

Assuming column dataID has unique variables, this can be done simply with:

data[data$dataID == 'H00-0022',]$year = 2000
Nikita Barsukov
  • 2,957
  • 3
  • 32
  • 39
0
data$year[which (data$dataID == 'H00-0022’)]<- 2000
Gion Mors
  • 313
  • 1
  • 3
  • 20