Why does the gsub function in R doesn't work on '.' operator? -
Why does the gsub function in R doesn't work on '.' operator? -
i have array named myfile has dates in character format. eg - "2014.01.29" "2014.02.02" "2014.01.09" "2014.01.23" "2014.01.09" "2014.01.29"
now, want replace '.' operator '-'. want "2014.01.29" "2014-01-29". when utilize code
gsub('.' , '-' , myfile[1])
i output '----------'. command works absolutely normal when replace '.' in gsub else. help appreciated.
you need escape .
can done either putting in [.]
or \\.
.
gsub('[.]', '-', myfile[1])
or
gsub('\\.', '-', myfile[1])
r gsub
Comments
Post a Comment