Re: [R] How to left or right truncate a character string?

2010-12-14 Thread Henrique Dallazuanna
Try this: noquote(lm(y ~ X2 + X3 + X4)) To remove X characters: gsub(^.|.$, , lm(y ~ X2 + X3 + X4)) On Tue, Dec 14, 2010 at 6:27 PM, Mark Na mtb...@gmail.com wrote: Hi R-helpers, I have a character string, for example: lm(y ~ X2 + X3 + X4) from which I would like to strip off the

Re: [R] How to left or right truncate a character string?

2010-12-14 Thread Phil Spector
Mark - Since regular expressions in R are just character strings, it's pretty easy to assemble a regular expression to delete leading or trailing characters. For example: delchars = function(str,n,lead=TRUE){ +dots = paste(rep('.',n),collapse='') +pat =