data$year[which (data$dataID == 'H00-0022’)]<- 2000
Adding a variable value to a specific record in R
Pregunta
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!
Solución 2
Otros consejos
Assuming column dataID
has unique variables, this can be done simply with:
data[data$dataID == 'H00-0022',]$year = 2000
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow