I've noticed what I think is curious behavior in using 'sub(fixed = TRUE)' and was wondering if my expectation is incorrect. Here is one example:
v <- paste(0:10, "asdf", sep = ".") sub(".asdf", "", v, fixed = TRUE) The results I get are > sub(".asdf", "", v, fixed = TRUE) [1] "0" "1\0st\0\0" "2\0<af>\001\0\0" "3\0<af>\001\0\0" [5] "4\0mes\0" "5\0<ba>\001\0\0" "6\0\0\0\0\0" "7\0\0\0m\0" [9] "8\0\0\0t\0" "9\0<fe>\0\0\0" "10\0\0\0\0\0" > I expected "0" in the first entry and everything else would be unchanged. Your results may vary since every time I run 'sub()' in this way, I get a slightly different answer in entires 2 through 11. As it turns out, 'gsub(fixed = TRUE)' gives me the answer I *actually* wanted, which was to replace the string in every entry. But I still think the behavior of 'sub(fixed = TRUE) is a bit odd. > version _ platform x86_64-unknown-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 2.1 year 2005 month 12 day 20 svn rev 36812 language R > -roger -- Roger D. Peng | http://www.biostat.jhsph.edu/~rpeng/ ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel