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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -