indexing - Replacing part of date in R column -


there examples of replacing values in single vector of data frame in r other value. e.g. replace value in data frame based on conditional (`if`) statement in r & replace numbers in data frame column in r?

i have slight variation of problem, data frame (athletes) errors in year of dob, , want go through , replace instances year 00yy-mm-dd 19yy-mm-dd

i tried athletes$dob[athletes$dob == 00] subset values didn't work

              name                    country height weight sex        dob gold silver bronze 1         lamusi people's republic of china    170     60   m 0089-06-02    0      0      0 2       g kruger   united states of america    193    125   m 1979-02-18    0      0      0 3   jamale aarrass                     france    187     76   m 1981-11-15    0      0      0 4 abdelhak aatakni                    morocco     na     na   m 0088-02-09    0      0      0 5  maria abakumova         russian federation    178     85   f 1986-01-15    0      0      0 6        luc abalo                     france    182     80   m 0084-09-06    0      0      0 

try sub

athletes$dob <- as.date(sub('^0{2}', '19', athletes$dob)) athletes$dob #[1] "1989-06-02" "1979-02-18" "1981-11-15" "1988-02-09" "1986-01-15" #[6] "1984-09-06" 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -