[R] Can anyone please tell me how to strip the white spaces from a character vector?

2005-10-25 Thread roger bos
for example:
 a$tic[1:10]
[1] AIR  ABCB  ABXA  ACMR  ADCT  ADEX 
[7] ABM  AFCE  AG  ATG 
 Can anyone please tell me how to strip the white spaces from a$tic?
 Thanks,
 Roger

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Can anyone please tell me how to strip the white spaces from a character vector?

2005-10-25 Thread Sean Davis
On 10/25/05 8:51 AM, roger bos [EMAIL PROTECTED] wrote:

 for example:
 a$tic[1:10]
 [1] AIR  ABCB  ABXA  ACMR  ADCT  ADEX 
 [7] ABM  AFCE  AG  ATG 
 Can anyone please tell me how to strip the white spaces from a$tic?
 Thanks,
 Roger
 
 [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

See ?gsub.

gsub(' ','',a$tic)

Sean

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Can anyone please tell me how to strip the white spaces from a character vector?

2005-10-25 Thread cgb
Quoting roger bos [EMAIL PROTECTED]:

 for example:
 a$tic[1:10]
 [1] AIR  ABCB  ABXA  ACMR  ADCT  ADEX 
 [7] ABM  AFCE  AG  ATG 
 Can anyone please tell me how to strip the white spaces from a$tic?
 Thanks,
 Roger

   [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


 a - c(ab , cd, ef )
 gsub( , , a)
[1] ab cd ef

Carlos J. Gil Bellosta
http://www.datanalytics.com

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Can anyone please tell me how to strip the white spaces from a character vector?

2005-10-25 Thread Marc Schwartz
On Tue, 2005-10-25 at 08:51 -0400, roger bos wrote:
 for example:
  a$tic[1:10]
 [1] AIR  ABCB  ABXA  ACMR  ADCT  ADEX 
 [7] ABM  AFCE  AG  ATG 
  Can anyone please tell me how to strip the white spaces from a$tic?
  Thanks,
  Roger

Roger, 

See the next to last set of examples in ?sub.

 a - c(ABM , AFCE , AG , ATG )
 a
[1] ABM   AFCE  AGATG 

 a.new - sub(' +$', '', a)
 a.new
[1] ABM  AFCE AG   ATG


Also, if this data was generated using read.table() or one of it's
variants, note the use of the 'strip.white' argument in ?read.table.

HTH,

Marc Schwartz

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Can anyone please tell me how to strip the white spaces from a character vector?

2005-10-25 Thread Romain Francois
Le 25.10.2005 14:51, roger bos a écrit :

for example:
  

a$tic[1:10]


[1] AIR  ABCB  ABXA  ACMR  ADCT  ADEX 
[7] ABM  AFCE  AG  ATG 
 Can anyone please tell me how to strip the white spaces from a$tic?
 Thanks,
 Roger
  

gsub(' ','',a$tic)

-- 
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
+---+
| Romain FRANCOIS - http://francoisromain.free.fr   |
| Doctorant INRIA Futurs / EDF  |
+---+

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Can anyone please tell me how to strip the white spaces from a character vector?

2005-10-25 Thread roger bos
Thanks to everyone for the gsub function. The white spaces were generated by
reading in the file, but its a fixed width file and I only need some of the
columns, so this was the easiest way to do it.
 Thanks,
 Roger

 On 10/25/05, Marc Schwartz [EMAIL PROTECTED] wrote:

 On Tue, 2005-10-25 at 08:51 -0400, roger bos wrote:
  for example:
   a$tic[1:10]
  [1] AIR  ABCB  ABXA  ACMR  ADCT  ADEX 
  [7] ABM  AFCE  AG  ATG 
  Can anyone please tell me how to strip the white spaces from a$tic?
  Thanks,
  Roger

 Roger,

 See the next to last set of examples in ?sub.

  a - c(ABM , AFCE , AG , ATG )
  a
 [1] ABM  AFCE  AG  ATG 

  a.new - sub(' +$', '', a)
  a.new
 [1] ABM AFCE AG ATG


 Also, if this data was generated using read.table() or one of it's
 variants, note the use of the 'strip.white' argument in ?read.table.

 HTH,

 Marc Schwartz




[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Can anyone please tell me how to strip the white spaces from a character vector?

2005-10-25 Thread Wuming Gong
Try trim() in gdata package.

Wuming

On 10/25/05, roger bos [EMAIL PROTECTED] wrote:
 for example:
  a$tic[1:10]
 [1] AIR  ABCB  ABXA  ACMR  ADCT  ADEX 
 [7] ABM  AFCE  AG  ATG 
  Can anyone please tell me how to strip the white spaces from a$tic?
  Thanks,
  Roger

 [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Can anyone please tell me how to strip the white spaces from a character vector?

2005-10-25 Thread Uwe Ligges
roger bos wrote:

 for example:
 
a$tic[1:10]
 
 [1] AIR  ABCB  ABXA  ACMR  ADCT  ADEX 
 [7] ABM  AFCE  AG  ATG 
  Can anyone please tell me how to strip the white spaces from a$tic?


Not beeing an expert for regular expressions, I'd try
sub( *$, , sub(^ *, , a$tic))
to strip from beginnings and ends but there may be far better approches.
In order to remove *all* blanks, try
gsub( , , a$tic)

Uwe Ligges


  Thanks,
  Roger
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html