Question

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!

Was it helpful?

Solution 2

data$year[which (data$dataID == 'H00-0022’)]<- 2000

OTHER TIPS

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

data[data$dataID == 'H00-0022',]$year = 2000
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top