Re: [R] gsub syntax

2005-11-27 Thread Dimitris Rizopoulos
you could use something like: dates - c(73, 74, 02, 1973, 1974, 2002) ### nd - nchar(dates) substr(dates, ifelse(nd == 2, 1, 3), nd) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven

Re: [R] gsub syntax

2005-11-27 Thread Sundar Dorai-Raj
John Logsdon wrote: Hello I know that R's string functions are not as extensive as those of Unix but I need to do some text handling totally within an R environment because the target is a Windows system which will not have the corresponding shell utilities, sed, awk etc. Can anyone

Re: [R] gsub syntax

2005-11-27 Thread Gabor Grothendieck
On 11/27/05, John Logsdon [EMAIL PROTECTED] wrote: Hello I know that R's string functions are not as extensive as those of Unix but I don't think this statement is true although I have seen it repeated. I need to do some text handling totally within an R environment because the target is a

Re: [R] gsub syntax

2005-11-27 Thread Prof Brian Ripley
R is blameless here: it works as documented and in the same way as POSIX tools. It agrees with 'sed' using the same syntax (modulo the shell-specific quoting rules) e.g. in csh % echo 1973 | sed 's/[19|20]\([0-9][0-9]\)/\1/g' 973 % echo 1973 | sed